diff options
Diffstat (limited to 'tests/ui/coherence')
11 files changed, 68 insertions, 11 deletions
diff --git a/tests/ui/coherence/coherence-conflicting-negative-trait-impl.rs b/tests/ui/coherence/coherence-conflicting-negative-trait-impl.rs index 24b878927..76a57936e 100644 --- a/tests/ui/coherence/coherence-conflicting-negative-trait-impl.rs +++ b/tests/ui/coherence/coherence-conflicting-negative-trait-impl.rs @@ -13,5 +13,7 @@ impl<T: MyTrait> !Send for TestType<T> {} //~ ERROR found both positive and nega unsafe impl<T: 'static> Send for TestType<T> {} //~ ERROR conflicting implementations impl !Send for TestType<i32> {} +//~^ WARNING +//~| WARNING this will change its meaning fn main() {} diff --git a/tests/ui/coherence/coherence-conflicting-negative-trait-impl.stderr b/tests/ui/coherence/coherence-conflicting-negative-trait-impl.stderr index 2463f38a9..020199da9 100644 --- a/tests/ui/coherence/coherence-conflicting-negative-trait-impl.stderr +++ b/tests/ui/coherence/coherence-conflicting-negative-trait-impl.stderr @@ -16,7 +16,23 @@ LL | unsafe impl<T: MyTrait + 'static> Send for TestType<T> {} LL | unsafe impl<T: 'static> Send for TestType<T> {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `TestType<_>` -error: aborting due to 2 previous errors +warning: cross-crate traits with a default impl, like `Send`, should not be specialized + --> $DIR/coherence-conflicting-negative-trait-impl.rs:15:1 + | +LL | impl !Send for TestType<i32> {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = warning: this will change its meaning in a future release! + = note: for more information, see issue #93367 <https://github.com/rust-lang/rust/issues/93367> + = note: `i32` is not a generic parameter +note: try using the same sequence of generic parameters as the struct definition + --> $DIR/coherence-conflicting-negative-trait-impl.rs:7:1 + | +LL | struct TestType<T>(::std::marker::PhantomData<T>); + | ^^^^^^^^^^^^^^^^^^ + = note: `#[warn(suspicious_auto_trait_impls)]` on by default + +error: aborting due to 2 previous errors; 1 warning emitted Some errors have detailed explanations: E0119, E0751. For more information about an error, try `rustc --explain E0119`. diff --git a/tests/ui/coherence/coherence-impls-copy.stderr b/tests/ui/coherence/coherence-impls-copy.stderr index d40ffc48a..21dbc6063 100644 --- a/tests/ui/coherence/coherence-impls-copy.stderr +++ b/tests/ui/coherence/coherence-impls-copy.stderr @@ -52,19 +52,19 @@ LL | impl Copy for [MyType] {} | = note: define and implement a trait or new type instead -error[E0206]: the trait `Copy` may not be implemented for this type +error[E0206]: the trait `Copy` cannot be implemented for this type --> $DIR/coherence-impls-copy.rs:21:15 | LL | impl Copy for &'static mut MyType {} | ^^^^^^^^^^^^^^^^^^^ type is not a structure or enumeration -error[E0206]: the trait `Copy` may not be implemented for this type +error[E0206]: the trait `Copy` cannot be implemented for this type --> $DIR/coherence-impls-copy.rs:25:15 | LL | impl Copy for (MyType, MyType) {} | ^^^^^^^^^^^^^^^^ type is not a structure or enumeration -error[E0206]: the trait `Copy` may not be implemented for this type +error[E0206]: the trait `Copy` cannot be implemented for this type --> $DIR/coherence-impls-copy.rs:30:15 | LL | impl Copy for [MyType] {} diff --git a/tests/ui/coherence/coherence-orphan.rs b/tests/ui/coherence/coherence-orphan.rs index 3beac04c7..bed782203 100644 --- a/tests/ui/coherence/coherence-orphan.rs +++ b/tests/ui/coherence/coherence-orphan.rs @@ -14,7 +14,8 @@ impl TheTrait<TheType> for isize { } impl TheTrait<isize> for TheType { } -impl !Send for Vec<isize> { } -//~^ ERROR E0117 +impl !Send for Vec<isize> { } //~ ERROR E0117 +//~^ WARNING +//~| WARNING this will change its meaning fn main() { } diff --git a/tests/ui/coherence/coherence-orphan.stderr b/tests/ui/coherence/coherence-orphan.stderr index 01f166a21..9ec1d0dc3 100644 --- a/tests/ui/coherence/coherence-orphan.stderr +++ b/tests/ui/coherence/coherence-orphan.stderr @@ -21,6 +21,19 @@ LL | impl !Send for Vec<isize> { } | = note: define and implement a trait or new type instead -error: aborting due to 2 previous errors +warning: cross-crate traits with a default impl, like `Send`, should not be specialized + --> $DIR/coherence-orphan.rs:17:1 + | +LL | impl !Send for Vec<isize> { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = warning: this will change its meaning in a future release! + = note: for more information, see issue #93367 <https://github.com/rust-lang/rust/issues/93367> + = note: `isize` is not a generic parameter +note: try using the same sequence of generic parameters as the struct definition + --> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL + = note: `#[warn(suspicious_auto_trait_impls)]` on by default + +error: aborting due to 2 previous errors; 1 warning emitted For more information about this error, try `rustc --explain E0117`. diff --git a/tests/ui/coherence/coherence_inherent.stderr b/tests/ui/coherence/coherence_inherent.stderr index 46b128c08..b381b0680 100644 --- a/tests/ui/coherence/coherence_inherent.stderr +++ b/tests/ui/coherence/coherence_inherent.stderr @@ -7,7 +7,7 @@ LL | s.the_fn(); = help: items from traits can only be used if the trait is in scope help: the following trait is implemented but not in scope; perhaps add a `use` for it: | -LL | use Lib::TheTrait; +LL + use Lib::TheTrait; | error: aborting due to previous error diff --git a/tests/ui/coherence/coherence_inherent_cc.stderr b/tests/ui/coherence/coherence_inherent_cc.stderr index af0ef3b69..7b6cb7d43 100644 --- a/tests/ui/coherence/coherence_inherent_cc.stderr +++ b/tests/ui/coherence/coherence_inherent_cc.stderr @@ -7,7 +7,7 @@ LL | s.the_fn(); = help: items from traits can only be used if the trait is in scope help: the following trait is implemented but not in scope; perhaps add a `use` for it: | -LL | use coherence_inherent_cc_lib::TheTrait; +LL + use coherence_inherent_cc_lib::TheTrait; | error: aborting due to previous error diff --git a/tests/ui/coherence/deep-bad-copy-reason.rs b/tests/ui/coherence/deep-bad-copy-reason.rs index 80bbe387a..97fd3f719 100644 --- a/tests/ui/coherence/deep-bad-copy-reason.rs +++ b/tests/ui/coherence/deep-bad-copy-reason.rs @@ -31,7 +31,7 @@ impl<'tcx, T> Clone for List<'tcx, T> { } impl<'tcx, T> Copy for List<'tcx, T> {} -//~^ ERROR the trait `Copy` may not be implemented for this type +//~^ ERROR the trait `Copy` cannot be implemented for this type fn assert_is_copy<T: Copy>() {} diff --git a/tests/ui/coherence/deep-bad-copy-reason.stderr b/tests/ui/coherence/deep-bad-copy-reason.stderr index 168ee5726..7b6dd4b38 100644 --- a/tests/ui/coherence/deep-bad-copy-reason.stderr +++ b/tests/ui/coherence/deep-bad-copy-reason.stderr @@ -1,4 +1,4 @@ -error[E0204]: the trait `Copy` may not be implemented for this type +error[E0204]: the trait `Copy` cannot be implemented for this type --> $DIR/deep-bad-copy-reason.rs:33:24 | LL | pub struct List<'tcx, T>(Interned<'tcx, ListS<T>>); diff --git a/tests/ui/coherence/illegal-copy-bad-projection.rs b/tests/ui/coherence/illegal-copy-bad-projection.rs new file mode 100644 index 000000000..797443a0a --- /dev/null +++ b/tests/ui/coherence/illegal-copy-bad-projection.rs @@ -0,0 +1,16 @@ +trait AsPtr { + type Ptr; +} + +impl AsPtr for () { + type Ptr = *const void; + //~^ ERROR cannot find type `void` in this scope +} + +#[derive(Copy, Clone)] +struct Foo { + p: <() as AsPtr>::Ptr, + // Do not report a "`Copy` cannot be implemented" here. +} + +fn main() {} diff --git a/tests/ui/coherence/illegal-copy-bad-projection.stderr b/tests/ui/coherence/illegal-copy-bad-projection.stderr new file mode 100644 index 000000000..8fed9ba23 --- /dev/null +++ b/tests/ui/coherence/illegal-copy-bad-projection.stderr @@ -0,0 +1,9 @@ +error[E0412]: cannot find type `void` in this scope + --> $DIR/illegal-copy-bad-projection.rs:6:23 + | +LL | type Ptr = *const void; + | ^^^^ not found in this scope + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0412`. |