-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implement lint for suspicious auto trait impls
- Loading branch information
Showing
8 changed files
with
359 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#![deny(suspicious_auto_trait_impls)] | ||
|
||
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 | ||
|
||
fn main() {} |
Oops, something went wrong.