]> git.proxmox.com Git - rustc.git/blob - src/test/ui/impl-trait/auto-trait.rs
New upstream version 1.40.0+dfsg1
[rustc.git] / src / test / ui / impl-trait / auto-trait.rs
1 // Tests that type alias impls traits do not leak auto-traits for
2 // the purposes of coherence checking
3 #![feature(type_alias_impl_trait)]
4
5 trait OpaqueTrait { }
6 impl<T> OpaqueTrait for T { }
7 type OpaqueType = impl OpaqueTrait;
8 fn mk_opaque() -> OpaqueType { () }
9
10 #[derive(Debug)]
11 struct D<T>(T);
12
13 trait AnotherTrait { }
14 impl<T: Send> AnotherTrait for T { }
15
16 // This is in error, because we cannot assume that `OpaqueType: !Send`.
17 // (We treat opaque types as "foreign types" that could grow more impls
18 // in the future.)
19 impl AnotherTrait for D<OpaqueType> {
20 //~^ ERROR conflicting implementations of trait `AnotherTrait` for type `D<OpaqueType>`
21 }
22
23 fn main() {}