1 // Test use of min_const_fn without feature gate. 2 foo() -> usize3const fn foo() -> usize { 0 } // stabilized 4 5 trait Foo { foo() -> u326 const fn foo() -> u32; //~ ERROR functions in traits cannot be declared const bar() -> u327 const fn bar() -> u32 { 0 } //~ ERROR functions in traits cannot be declared const 8 } 9 10 impl Foo for u32 { foo() -> u3211 const fn foo() -> u32 { 0 } //~ ERROR functions in traits cannot be declared const 12 } 13 14 trait Bar {} 15 16 impl dyn Bar { baz() -> u3217 const fn baz() -> u32 { 0 } // stabilized 18 } 19 20 static FOO: usize = foo(); 21 const BAR: usize = foo(); 22 23 macro_rules! constant { 24 ($n:ident: $t:ty = $v:expr) => { 25 const $n: $t = $v; 26 } 27 } 28 29 constant! { 30 BAZ: usize = foo() 31 } 32 main()33fn main() { 34 let x: [usize; foo()] = []; 35 } 36