diff options
| author | Michael Goulet <michael@errs.io> | 2023-11-16 22:50:59 +0000 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2023-11-19 19:20:02 +0000 |
| commit | 488dcb7af3fc394ca438da2a9fe8a40dcae06948 (patch) | |
| tree | 6c20245a4366f757ba7e3a2a6e85c363adb9681b /tests/ui | |
| parent | 0ea7ddcc35a2fcaa5da8a7dcfc118c9fb4a63b95 (diff) | |
| download | rust-488dcb7af3fc394ca438da2a9fe8a40dcae06948.tar.gz rust-488dcb7af3fc394ca438da2a9fe8a40dcae06948.zip | |
Ignore but do not assume region obligations from unifying headers in negative coherence
Diffstat (limited to 'tests/ui')
2 files changed, 44 insertions, 0 deletions
diff --git a/tests/ui/coherence/negative-coherence-placeholder-region-constraints-on-unification.explicit.stderr b/tests/ui/coherence/negative-coherence-placeholder-region-constraints-on-unification.explicit.stderr new file mode 100644 index 00000000000..34f3904443c --- /dev/null +++ b/tests/ui/coherence/negative-coherence-placeholder-region-constraints-on-unification.explicit.stderr @@ -0,0 +1,19 @@ +error: conflicting implementations of trait `FnMarker` for type `fn(&_)` + --> $DIR/negative-coherence-placeholder-region-constraints-on-unification.rs:21:1 + | +LL | impl<T: ?Sized + Marker> FnMarker for fn(T) {} + | ------------------------------------------- first implementation here +LL | impl<T: ?Sized> FnMarker for fn(&T) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `fn(&_)` + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #56105 <https://github.com/rust-lang/rust/issues/56105> + = note: this behavior recently changed as a result of a bug fix; see rust-lang/rust#56105 for details +note: the lint level is defined here + --> $DIR/negative-coherence-placeholder-region-constraints-on-unification.rs:4:11 + | +LL | #![forbid(coherence_leak_check)] + | ^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/tests/ui/coherence/negative-coherence-placeholder-region-constraints-on-unification.rs b/tests/ui/coherence/negative-coherence-placeholder-region-constraints-on-unification.rs new file mode 100644 index 00000000000..26d9d84d8f0 --- /dev/null +++ b/tests/ui/coherence/negative-coherence-placeholder-region-constraints-on-unification.rs @@ -0,0 +1,25 @@ +// revisions: explicit implicit +//[implicit] check-pass + +#![forbid(coherence_leak_check)] +#![feature(negative_impls, with_negative_coherence)] + +pub trait Marker {} + +#[cfg(implicit)] +impl<T: ?Sized> !Marker for &T {} + +#[cfg(explicit)] +impl<'a, T: ?Sized + 'a> !Marker for &'a T {} + +trait FnMarker {} + +// Unifying these two impls below results in a `T: '!0` obligation +// that we shouldn't need to care about. Ideally, we'd treat that +// as an assumption when proving `&'!0 T: Marker`... +impl<T: ?Sized + Marker> FnMarker for fn(T) {} +impl<T: ?Sized> FnMarker for fn(&T) {} +//[explicit]~^ ERROR conflicting implementations of trait `FnMarker` for type `fn(&_)` +//[explicit]~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + +fn main() {} |
