]> git.proxmox.com Git - rustc.git/blob - src/test/ui/impl-trait/auto-trait.rs
New upstream version 1.62.1+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 }
11
12 #[derive(Debug)]
13 struct D<T>(T);
14
15 trait AnotherTrait {}
16 impl<T: Send> AnotherTrait for T {}
17
18 // This is in error, because we cannot assume that `OpaqueType: !Send`.
19 // (We treat opaque types as "foreign types" that could grow more impls
20 // in the future.)
21 impl AnotherTrait for D<OpaqueType> {
22 //~^ ERROR conflicting implementations of trait `AnotherTrait` for type `D<OpaqueType>`
23 //~| ERROR cannot implement trait on type alias impl trait
24 }
25
26 fn main() {}