]> git.lizzy.rs Git - rust.git/blob - src/test/ui/consts/miri_unleashed/assoc_const_2.rs
Rollup merge of #64603 - gilescope:unused-lifetime-warning, r=matthewjasper
[rust.git] / src / test / ui / consts / miri_unleashed / assoc_const_2.rs
1 #![allow(const_err)]
2
3 // a test demonstrating that const qualification cannot prevent monomorphization time errors
4
5 trait Foo {
6     const X: u32;
7 }
8
9 trait Bar<U: Foo> {
10     const F: u32 = 100 / U::X;
11 }
12
13 impl Foo for () {
14     const X: u32 = 42;
15 }
16
17 impl Foo for String {
18     const X: u32 = 0;
19 }
20
21 impl Bar<()> for () {}
22 impl Bar<String> for String {}
23
24 fn main() {
25     let x = <() as Bar<()>>::F;
26     // this test only causes errors due to the line below, so post-monomorphization
27     let y = <String as Bar<String>>::F; //~ ERROR erroneous constant
28 }