summaryrefslogtreecommitdiffstats
path: root/src/test/ui/consts/const-fn-method.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/ui/consts/const-fn-method.rs')
-rw-r--r--src/test/ui/consts/const-fn-method.rs16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/test/ui/consts/const-fn-method.rs b/src/test/ui/consts/const-fn-method.rs
new file mode 100644
index 000000000..002646db9
--- /dev/null
+++ b/src/test/ui/consts/const-fn-method.rs
@@ -0,0 +1,16 @@
+// run-pass
+
+struct Foo { value: u32 }
+
+impl Foo {
+ const fn new() -> Foo {
+ Foo { value: 22 }
+ }
+}
+
+const FOO: Foo = Foo::new();
+
+pub fn main() {
+ assert_eq!(FOO.value, 22);
+ let _: [&'static str; Foo::new().value as usize] = ["hey"; 22];
+}