diff options
Diffstat (limited to '')
-rw-r--r-- | src/test/ui/impl-trait/negative-reasoning.rs | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/test/ui/impl-trait/negative-reasoning.rs b/src/test/ui/impl-trait/negative-reasoning.rs new file mode 100644 index 000000000..da69bb349 --- /dev/null +++ b/src/test/ui/impl-trait/negative-reasoning.rs @@ -0,0 +1,24 @@ +// Tests that we cannot assume that an opaque type does *not* implement some +// other trait +#![feature(type_alias_impl_trait)] + +trait OpaqueTrait {} +impl<T> OpaqueTrait for T {} +type OpaqueType = impl OpaqueTrait; +fn mk_opaque() -> OpaqueType { + () +} + +#[derive(Debug)] +struct D<T>(T); + +trait AnotherTrait {} +impl<T: std::fmt::Debug> AnotherTrait for T {} + +// This is in error, because we cannot assume that `OpaqueType: !Debug` +impl AnotherTrait for D<OpaqueType> { + //~^ ERROR conflicting implementations of trait `AnotherTrait` for type `D<OpaqueType>` + //~| ERROR cannot implement trait on type alias impl trait +} + +fn main() {} |