]> git.proxmox.com Git - rustc.git/blob - tests/ui/associated-types/defaults-cyclic-fail-2.rs
New upstream version 1.68.2+dfsg1
[rustc.git] / tests / ui / associated-types / defaults-cyclic-fail-2.rs
1 #![feature(associated_type_defaults)]
2
3 // A more complex version of `defaults-cyclic-fail-1.rs`, with non-trivial defaults.
4
5 // Having a cycle in assoc. type defaults is okay...
6 trait Tr {
7 type A = Vec<Self::B>;
8 type B = Box<Self::A>;
9 }
10
11 impl Tr for () {}
12
13 impl Tr for u8 {
14 type A = u8;
15 }
16
17 impl Tr for u16 {
18 type B = ();
19 }
20
21 impl Tr for u32 {
22 type A = ();
23 type B = u8;
24 }
25
26 impl Tr for bool {
27 type A = Box<Self::B>;
28 //~^ ERROR overflow evaluating the requirement `<bool as Tr>::B == _`
29 }
30 // (the error is shown twice for some reason)
31
32 impl Tr for usize {
33 type B = &'static Self::A;
34 //~^ ERROR overflow evaluating the requirement `<usize as Tr>::A == _`
35 }
36
37 fn main() {
38 // We don't check that the types project correctly because the cycle errors stop compilation
39 // before `main` is type-checked.
40 // `defaults-cyclic-pass-2.rs` does this.
41 }