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 /tests/ui/auto-traits/suspicious-impls-lint.rs | |
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 'tests/ui/auto-traits/suspicious-impls-lint.rs')
-rw-r--r-- | tests/ui/auto-traits/suspicious-impls-lint.rs | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/tests/ui/auto-traits/suspicious-impls-lint.rs b/tests/ui/auto-traits/suspicious-impls-lint.rs new file mode 100644 index 000000000..7712e84f4 --- /dev/null +++ b/tests/ui/auto-traits/suspicious-impls-lint.rs @@ -0,0 +1,50 @@ +#![deny(suspicious_auto_trait_impls)] + +use std::marker::PhantomData; + +struct MayImplementSendOk<T>(T); +unsafe impl<T: Send> Send for MayImplementSendOk<T> {} // ok + +struct MayImplementSendErr<T>(T); +unsafe impl<T: Send> Send for MayImplementSendErr<&T> {} +//~^ ERROR +//~| WARNING this will change its meaning + +struct ContainsNonSendDirect<T>(*const T); +unsafe impl<T: Send> Send for ContainsNonSendDirect<&T> {} // ok + +struct ContainsPtr<T>(*const T); +struct ContainsIndirectNonSend<T>(ContainsPtr<T>); +unsafe impl<T: Send> Send for ContainsIndirectNonSend<&T> {} // ok + +struct ContainsVec<T>(Vec<T>); +unsafe impl Send for ContainsVec<i32> {} +//~^ ERROR +//~| WARNING this will change its meaning + +struct TwoParams<T, U>(T, U); +unsafe impl<T: Send, U: Send> Send for TwoParams<T, U> {} // ok + +struct TwoParamsFlipped<T, U>(T, U); +unsafe impl<T: Send, U: Send> Send for TwoParamsFlipped<U, T> {} // ok + +struct TwoParamsSame<T, U>(T, U); +unsafe impl<T: Send> Send for TwoParamsSame<T, T> {} +//~^ ERROR +//~| WARNING this will change its meaning + +pub struct WithPhantomDataNonSend<T, U>(PhantomData<*const T>, U); +unsafe impl<T> Send for WithPhantomDataNonSend<T, i8> {} // ok + +pub struct WithPhantomDataSend<T, U>(PhantomData<T>, U); +unsafe impl<T> Send for WithPhantomDataSend<*const T, i8> {} +//~^ ERROR +//~| WARNING this will change its meaning + +pub struct WithLifetime<'a, T>(&'a (), T); +unsafe impl<T> Send for WithLifetime<'static, T> {} // ok +unsafe impl<T> Sync for WithLifetime<'static, Vec<T>> {} +//~^ ERROR +//~| WARNING this will change its meaning + +fn main() {} |