]> git.lizzy.rs Git - rust.git/blob - src/test/ui/consts/const-eval/issue-50814-2.rs
Rollup merge of #81356 - ehuss:libtest-filters, r=m-ou-se
[rust.git] / src / test / ui / consts / const-eval / issue-50814-2.rs
1 // build-fail
2
3 trait C {
4     const BOO: usize;
5 }
6
7 trait Foo<T> {
8     const BAR: usize;
9 }
10
11 struct A<T>(T);
12
13 impl<T: C> Foo<T> for A<T> {
14     const BAR: usize = [5, 6, 7][T::BOO]; //~ ERROR any use of this value will cause an error
15     //~| WARN this was previously accepted by the compiler but is being phased out
16 }
17
18 fn foo<T: C>() -> &'static usize {
19     &<A<T> as Foo<T>>::BAR //~ ERROR E0080
20 }
21
22 impl C for () {
23     const BOO: usize = 42;
24 }
25
26 impl C for u32 {
27     const BOO: usize = 1;
28 }
29
30 fn main() {
31     println!("{:x}", foo::<()>() as *const usize as usize);
32     println!("{:x}", foo::<u32>() as *const usize as usize);
33     println!("{:x}", foo::<()>());
34     println!("{:x}", foo::<u32>());
35 }