]> git.lizzy.rs Git - rust.git/blob - tests/ui/associated-types/defaults-cyclic-fail-1.rs
Rollup merge of #107306 - compiler-errors:correct-sugg-for-closure-arg-needs-borrow...
[rust.git] / tests / ui / associated-types / defaults-cyclic-fail-1.rs
1 #![feature(associated_type_defaults)]
2
3 // Having a cycle in assoc. type defaults is okay...
4 trait Tr {
5     type A = Self::B;
6     type B = Self::A;
7 }
8
9 impl Tr for () {}
10
11 impl Tr for u8 {
12     type A = u8;
13 }
14
15 impl Tr for u16 {
16     type B = ();
17 }
18
19 impl Tr for u32 {
20     type A = ();
21     type B = u8;
22 }
23
24 // ...but not in an impl that redefines one of the types.
25 impl Tr for bool {
26     type A = Box<Self::B>;
27     //~^ ERROR overflow evaluating the requirement `<bool as Tr>::B == _`
28 }
29 // (the error is shown twice for some reason)
30
31 impl Tr for usize {
32     type B = &'static Self::A;
33     //~^ ERROR overflow evaluating the requirement `<usize as Tr>::A == _`
34 }
35
36 fn main() {
37     // We don't check that the types project correctly because the cycle errors stop compilation
38     // before `main` is type-checked.
39     // `defaults-cyclic-pass-1.rs` does this.
40 }