]> git.lizzy.rs Git - rust.git/blob - src/test/ui/impl-trait/negative-reasoning.rs
Rollup merge of #98441 - calebzulawski:simd_as, r=oli-obk
[rust.git] / src / test / ui / impl-trait / negative-reasoning.rs
1 // Tests that we cannot assume that an opaque type does *not* implement some
2 // other trait
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: std::fmt::Debug> AnotherTrait for T {}
17
18 // This is in error, because we cannot assume that `OpaqueType: !Debug`
19 impl AnotherTrait for D<OpaqueType> {
20     //~^ ERROR conflicting implementations of trait `AnotherTrait` for type `D<OpaqueType>`
21     //~| ERROR cannot implement trait on type alias impl trait
22 }
23
24 fn main() {}