diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:13 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:13 +0000 |
commit | 218caa410aa38c29984be31a5229b9fa717560ee (patch) | |
tree | c54bd55eeb6e4c508940a30e94c0032fbd45d677 /src/test/ui/traits/reservation-impl | |
parent | Releasing progress-linux version 1.67.1+dfsg1-1~progress7.99u1. (diff) | |
download | rustc-218caa410aa38c29984be31a5229b9fa717560ee.tar.xz rustc-218caa410aa38c29984be31a5229b9fa717560ee.zip |
Merging upstream version 1.68.2+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/test/ui/traits/reservation-impl')
-rw-r--r-- | src/test/ui/traits/reservation-impl/coherence-conflict.rs | 14 | ||||
-rw-r--r-- | src/test/ui/traits/reservation-impl/coherence-conflict.stderr | 13 | ||||
-rw-r--r-- | src/test/ui/traits/reservation-impl/no-use.rs | 12 | ||||
-rw-r--r-- | src/test/ui/traits/reservation-impl/no-use.stderr | 13 | ||||
-rw-r--r-- | src/test/ui/traits/reservation-impl/non-lattice-ok.rs | 59 | ||||
-rw-r--r-- | src/test/ui/traits/reservation-impl/ok.rs | 28 |
6 files changed, 0 insertions, 139 deletions
diff --git a/src/test/ui/traits/reservation-impl/coherence-conflict.rs b/src/test/ui/traits/reservation-impl/coherence-conflict.rs deleted file mode 100644 index fa4a30931..000000000 --- a/src/test/ui/traits/reservation-impl/coherence-conflict.rs +++ /dev/null @@ -1,14 +0,0 @@ -// check that reservation impls are accounted for in negative reasoning. - -#![feature(rustc_attrs)] - -trait MyTrait {} -#[rustc_reservation_impl="this impl is reserved"] -impl MyTrait for () {} - -trait OtherTrait {} -impl OtherTrait for () {} -impl<T: MyTrait> OtherTrait for T {} -//~^ ERROR conflicting implementations - -fn main() {} diff --git a/src/test/ui/traits/reservation-impl/coherence-conflict.stderr b/src/test/ui/traits/reservation-impl/coherence-conflict.stderr deleted file mode 100644 index a811d7e32..000000000 --- a/src/test/ui/traits/reservation-impl/coherence-conflict.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0119]: conflicting implementations of trait `OtherTrait` for type `()` - --> $DIR/coherence-conflict.rs:11:1 - | -LL | impl OtherTrait for () {} - | ---------------------- first implementation here -LL | impl<T: MyTrait> OtherTrait for T {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `()` - | - = note: this impl is reserved - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0119`. diff --git a/src/test/ui/traits/reservation-impl/no-use.rs b/src/test/ui/traits/reservation-impl/no-use.rs deleted file mode 100644 index 65a55d9e2..000000000 --- a/src/test/ui/traits/reservation-impl/no-use.rs +++ /dev/null @@ -1,12 +0,0 @@ -// check that reservation impls can't be used as normal impls in positive reasoning. - -#![feature(rustc_attrs)] - -trait MyTrait { fn foo(&self); } -#[rustc_reservation_impl = "foo"] -impl MyTrait for () { fn foo(&self) {} } - -fn main() { - <() as MyTrait>::foo(&()); - //~^ ERROR the trait bound `(): MyTrait` is not satisfied -} diff --git a/src/test/ui/traits/reservation-impl/no-use.stderr b/src/test/ui/traits/reservation-impl/no-use.stderr deleted file mode 100644 index cefb2a879..000000000 --- a/src/test/ui/traits/reservation-impl/no-use.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0277]: the trait bound `(): MyTrait` is not satisfied - --> $DIR/no-use.rs:10:26 - | -LL | <() as MyTrait>::foo(&()); - | -------------------- ^^^ the trait `MyTrait` is not implemented for `()` - | | - | required by a bound introduced by this call - | - = help: the trait `MyTrait` is implemented for `()` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/traits/reservation-impl/non-lattice-ok.rs b/src/test/ui/traits/reservation-impl/non-lattice-ok.rs deleted file mode 100644 index a71051243..000000000 --- a/src/test/ui/traits/reservation-impl/non-lattice-ok.rs +++ /dev/null @@ -1,59 +0,0 @@ -// build-pass - -// Check that a reservation impl does not force other impls to follow -// a lattice discipline. - -// Why did we ever want to do this? -// -// We want to eventually add an `impl<T> From<!> for T` impl. That impl conflicts -// with existing impls - at least the `impl<T> From<T> for T` impl. There are -// 2 ways we thought of for dealing with that conflict: -// -// 1. Using specialization and doing some handling for the -// overlap. The current thought is to require ["intersection -// impls"][ii], specialization", which means providing an -// (higher-priority) impl for the intersection of every 2 conflicting -// impls that determines what happens in the intersection case. That's -// the first thing we thought about - see e.g. -// https://github.com/rust-lang/rust/issues/57012#issuecomment-452150775 -// -// 2. The other way is to notice that `impl From<!> for T` is basically a -// marker trait since its only method is uninhabited, and allow for "marker -// trait overlap", where the conflict "doesn't matter" because it can't -// actually cause any ambiguity. -// -// Now it turned out lattice specialization doesn't work it, because an -// `impl<T> From<T> for Smaht<T>` would require an `impl From<!> for Smaht<!>`, -// breaking backwards-compatibility in a fairly painful way. So if we want to -// go with a known approach, we should go with a "marker trait overlap"-style -// approach. -// -// [ii]: https://smallcultfollowing.com/babysteps/blog/2016/09/24/intersection-impls/ - -#![feature(rustc_attrs, never_type)] - -trait MyTrait {} - -impl MyTrait for ! {} - -trait MyFrom<T> { - fn my_from(x: T) -> Self; -} - -// Given the "normal" impls for From -#[rustc_reservation_impl="this impl is reserved"] -impl<T> MyFrom<!> for T { - fn my_from(x: !) -> Self { match x {} } -} - -impl<T> MyFrom<T> for T { - fn my_from(x: T) -> Self { x } -} - -// ... we *do* want to allow this common pattern, of `From<!> for MySmaht<T>` -struct MySmaht<T>(T); -impl<T> MyFrom<T> for MySmaht<T> { - fn my_from(x: T) -> Self { MySmaht(x) } -} - -fn main() {} diff --git a/src/test/ui/traits/reservation-impl/ok.rs b/src/test/ui/traits/reservation-impl/ok.rs deleted file mode 100644 index 611c8d884..000000000 --- a/src/test/ui/traits/reservation-impl/ok.rs +++ /dev/null @@ -1,28 +0,0 @@ -// run-pass - -// rpass test for reservation impls. Not 100% required because `From` uses them, -// but still. - -#![feature(rustc_attrs)] - -use std::mem; - -trait MyTrait<S> { - fn foo(&self, s: S) -> usize; -} - -#[rustc_reservation_impl = "foo"] -impl<T> MyTrait<u64> for T { - fn foo(&self, _x: u64) -> usize { 0 } -} - -// reservation impls don't create coherence conflicts, even with -// non-chain overlap. -impl<S> MyTrait<S> for u32 { - fn foo(&self, _x: S) -> usize { mem::size_of::<S>() } -} - -fn main() { - // ...and the non-reservation impl gets picked.XS - assert_eq!(0u32.foo(0u64), mem::size_of::<u64>()); -} |