summaryrefslogtreecommitdiffstats
path: root/tests/ui/consts/const-fn-not-in-trait.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/consts/const-fn-not-in-trait.rs')
-rw-r--r--tests/ui/consts/const-fn-not-in-trait.rs13
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/ui/consts/const-fn-not-in-trait.rs b/tests/ui/consts/const-fn-not-in-trait.rs
new file mode 100644
index 000000000..00bae3f3b
--- /dev/null
+++ b/tests/ui/consts/const-fn-not-in-trait.rs
@@ -0,0 +1,13 @@
+// Test that const fn is illegal in a trait declaration, whether or
+// not a default is provided, and even with the feature gate.
+
+trait Foo {
+ const fn f() -> u32;
+ //~^ ERROR functions in traits cannot be declared const
+ const fn g() -> u32 {
+ //~^ ERROR functions in traits cannot be declared const
+ 0
+ }
+}
+
+fn main() {}