]> git.proxmox.com Git - rustc.git/blob - tests/ui/type-alias-impl-trait/impl_trait_for_same_tait.rs
New upstream version 1.68.2+dfsg1
[rustc.git] / tests / ui / type-alias-impl-trait / impl_trait_for_same_tait.rs
1 #![feature(type_alias_impl_trait)]
2
3 trait Foo {}
4 impl Foo for () {}
5 impl Foo for i32 {}
6
7 type Bar<T: Foo> = impl std::fmt::Debug;
8 fn defining_use<T: Foo>() -> Bar<T> {
9 42
10 }
11
12 trait Bop {}
13
14 impl Bop for Bar<()> {}
15
16 // If the hidden type is the same, this is effectively a second impl for the same type.
17 impl Bop for Bar<i32> {}
18 //~^ ERROR conflicting implementations
19
20 type Barr = impl std::fmt::Debug;
21 fn defining_use2() -> Barr {
22 42
23 }
24
25 // Even completely different opaque types must conflict.
26 impl Bop for Barr {}
27 //~^ ERROR conflicting implementations
28
29 // And obviously the hidden type must conflict, too.
30 impl Bop for i32 {}
31 //~^ ERROR conflicting implementations
32
33 fn main() {}