Restore Opaque behavior to coherence check

This commit is contained in:
Michael Goulet 2022-07-24 10:34:35 +00:00
parent 6dbae3ad19
commit b7cf9f72f6
4 changed files with 75 additions and 2 deletions

View file

@ -0,0 +1,22 @@
// check-pass
#![feature(type_alias_impl_trait)]
struct Outer<T: ?Sized> {
i: InnerSend<T>,
}
type InnerSend<T: ?Sized> = impl Send;
fn constrain<T: ?Sized>() -> InnerSend<T> {
()
}
trait SendMustNotImplDrop {}
#[allow(drop_bounds)]
impl<T: ?Sized + Send + Drop> SendMustNotImplDrop for T {}
impl<T: ?Sized> SendMustNotImplDrop for Outer<T> {}
fn main() {}

View file

@ -0,0 +1,22 @@
// check-pass
#![feature(type_alias_impl_trait)]
struct Send<T> {
i: InnerSend<T>,
}
type InnerSend<T> = impl Sized;
fn constrain<T>() -> InnerSend<T> {
()
}
trait SendMustNotImplDrop {}
#[allow(drop_bounds)]
impl<T: Drop> SendMustNotImplDrop for T {}
impl<T> SendMustNotImplDrop for Send<T> {}
fn main() {}

View file

@ -7,7 +7,7 @@ LL | impl<T: std::fmt::Debug> AnotherTrait for T {}
LL | impl AnotherTrait for D<OpaqueType> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `D<OpaqueType>`
|
= note: downstream crates may implement trait `std::fmt::Debug` for type `OpaqueType`
= note: upstream crates may add a new impl of trait `std::fmt::Debug` for type `OpaqueType` in future versions
error: cannot implement trait on type alias impl trait
--> $DIR/negative-reasoning.rs:19:25