]> git.lizzy.rs Git - rust.git/blob - tests/ui/feature-gates/feature-gate-min_const_fn.rs
Rollup merge of #106707 - ehuss:remove-dupe-sha-1, r=Mark-Simulacrum
[rust.git] / tests / ui / feature-gates / feature-gate-min_const_fn.rs
1 // Test use of min_const_fn without feature gate.
2
3 const fn foo() -> usize { 0 } // stabilized
4
5 trait Foo {
6     const fn foo() -> u32; //~ ERROR functions in traits cannot be declared const
7     const fn bar() -> u32 { 0 } //~ ERROR functions in traits cannot be declared const
8 }
9
10 impl Foo for u32 {
11     const fn foo() -> u32 { 0 } //~ ERROR functions in traits cannot be declared const
12 }
13
14 trait Bar {}
15
16 impl dyn Bar {
17     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
33 fn main() {
34     let x: [usize; foo()] = [];
35 }