diff options
Diffstat (limited to 'tests/ui/consts/const-fn-method.rs')
-rw-r--r-- | tests/ui/consts/const-fn-method.rs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/ui/consts/const-fn-method.rs b/tests/ui/consts/const-fn-method.rs new file mode 100644 index 000000000..002646db9 --- /dev/null +++ b/tests/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]; +} |