diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:20:29 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:20:29 +0000 |
commit | 631cd5845e8de329d0e227aaa707d7ea228b8f8f (patch) | |
tree | a1b87c8f8cad01cf18f7c5f57a08f102771ed303 /tests/ui/auto-traits | |
parent | Adding debian version 1.69.0+dfsg1-1. (diff) | |
download | rustc-631cd5845e8de329d0e227aaa707d7ea228b8f8f.tar.xz rustc-631cd5845e8de329d0e227aaa707d7ea228b8f8f.zip |
Merging upstream version 1.70.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ui/auto-traits')
-rw-r--r-- | tests/ui/auto-traits/suspicious-negative-impls-lint.rs | 21 | ||||
-rw-r--r-- | tests/ui/auto-traits/suspicious-negative-impls-lint.stderr | 52 |
2 files changed, 73 insertions, 0 deletions
diff --git a/tests/ui/auto-traits/suspicious-negative-impls-lint.rs b/tests/ui/auto-traits/suspicious-negative-impls-lint.rs new file mode 100644 index 000000000..34842e594 --- /dev/null +++ b/tests/ui/auto-traits/suspicious-negative-impls-lint.rs @@ -0,0 +1,21 @@ +#![feature(negative_impls)] +#![deny(suspicious_auto_trait_impls)] + +use std::marker::PhantomData; + +struct ContainsVec<T>(Vec<T>); +impl !Send for ContainsVec<u32> {} +//~^ ERROR +//~| WARNING this will change its meaning + +pub struct WithPhantomDataSend<T, U>(PhantomData<T>, U); +impl<T> !Send for WithPhantomDataSend<*const T, u8> {} +//~^ ERROR +//~| WARNING this will change its meaning + +pub struct WithLifetime<'a, T>(&'a (), T); +impl<T> !Sync for WithLifetime<'static, Option<T>> {} +//~^ ERROR +//~| WARNING this will change its meaning + +fn main() {} diff --git a/tests/ui/auto-traits/suspicious-negative-impls-lint.stderr b/tests/ui/auto-traits/suspicious-negative-impls-lint.stderr new file mode 100644 index 000000000..ee03ea125 --- /dev/null +++ b/tests/ui/auto-traits/suspicious-negative-impls-lint.stderr @@ -0,0 +1,52 @@ +error: cross-crate traits with a default impl, like `Send`, should not be specialized + --> $DIR/suspicious-negative-impls-lint.rs:7:1 + | +LL | impl !Send for ContainsVec<u32> {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = 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: `u32` is not a generic parameter +note: try using the same sequence of generic parameters as the struct definition + --> $DIR/suspicious-negative-impls-lint.rs:6:1 + | +LL | struct ContainsVec<T>(Vec<T>); + | ^^^^^^^^^^^^^^^^^^^^^ +note: the lint level is defined here + --> $DIR/suspicious-negative-impls-lint.rs:2:9 + | +LL | #![deny(suspicious_auto_trait_impls)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: cross-crate traits with a default impl, like `Send`, should not be specialized + --> $DIR/suspicious-negative-impls-lint.rs:12:1 + | +LL | impl<T> !Send for WithPhantomDataSend<*const T, u8> {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = 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: `*const T` is not a generic parameter +note: try using the same sequence of generic parameters as the struct definition + --> $DIR/suspicious-negative-impls-lint.rs:11:1 + | +LL | pub struct WithPhantomDataSend<T, U>(PhantomData<T>, U); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: cross-crate traits with a default impl, like `Sync`, should not be specialized + --> $DIR/suspicious-negative-impls-lint.rs:17:1 + | +LL | impl<T> !Sync for WithLifetime<'static, Option<T>> {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = 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: `Option<T>` is not a generic parameter +note: try using the same sequence of generic parameters as the struct definition + --> $DIR/suspicious-negative-impls-lint.rs:16:1 + | +LL | pub struct WithLifetime<'a, T>(&'a (), T); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 3 previous errors + |