-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #125531 - surechen:make_suggestion_for_note_like_drop_l…
…int, r=Urgau Make lint: `lint_dropping_references` `lint_forgetting_copy_types` `lint_forgetting_references` give suggestion if possible. This is a follow-up PR of #125433. When it's merged, I want change lint `dropping_copy_types` to use the same `Subdiagnostic` struct `UseLetUnderscoreIgnoreSuggestion` which is added in this PR. Hi, Thank you(`@Urgau` ) again for your help in the previous PR. If your time permits, please also take a look at this one. r? compiler <!-- If this PR is related to an unstable feature or an otherwise tracked effort, please link to the relevant tracking issue here. If you don't know of a related tracking issue or there are none, feel free to ignore this. This PR will get automatically assigned to a reviewer. In case you would like a specific user to review your work, you can assign it to them by using r? <reviewer name> -->
- Loading branch information
Showing
17 changed files
with
743 additions
and
74 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,31 @@ | ||
//@ check-fail | ||
//@ run-rustfix | ||
|
||
#![deny(dropping_references)] | ||
|
||
struct SomeStruct; | ||
|
||
fn main() { | ||
let _ = &SomeStruct; //~ ERROR calls to `std::mem::drop` | ||
|
||
let mut owned1 = SomeStruct; | ||
let _ = &owned1; //~ ERROR calls to `std::mem::drop` | ||
let _ = &&owned1; //~ ERROR calls to `std::mem::drop` | ||
let _ = &mut owned1; //~ ERROR calls to `std::mem::drop` | ||
drop(owned1); | ||
|
||
let reference1 = &SomeStruct; | ||
let _ = reference1; //~ ERROR calls to `std::mem::drop` | ||
|
||
let reference2 = &mut SomeStruct; | ||
let _ = reference2; //~ ERROR calls to `std::mem::drop` | ||
|
||
let ref reference3 = SomeStruct; | ||
let _ = reference3; //~ ERROR calls to `std::mem::drop` | ||
} | ||
|
||
#[allow(dead_code)] | ||
fn test_generic_fn_drop<T>(val: T) { | ||
let _ = &val; //~ ERROR calls to `std::mem::drop` | ||
drop(val); | ||
} |
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,31 @@ | ||
//@ check-fail | ||
//@ run-rustfix | ||
|
||
#![deny(dropping_references)] | ||
|
||
struct SomeStruct; | ||
|
||
fn main() { | ||
drop(&SomeStruct); //~ ERROR calls to `std::mem::drop` | ||
|
||
let mut owned1 = SomeStruct; | ||
drop(&owned1); //~ ERROR calls to `std::mem::drop` | ||
drop(&&owned1); //~ ERROR calls to `std::mem::drop` | ||
drop(&mut owned1); //~ ERROR calls to `std::mem::drop` | ||
drop(owned1); | ||
|
||
let reference1 = &SomeStruct; | ||
drop(reference1); //~ ERROR calls to `std::mem::drop` | ||
|
||
let reference2 = &mut SomeStruct; | ||
drop(reference2); //~ ERROR calls to `std::mem::drop` | ||
|
||
let ref reference3 = SomeStruct; | ||
drop(reference3); //~ ERROR calls to `std::mem::drop` | ||
} | ||
|
||
#[allow(dead_code)] | ||
fn test_generic_fn_drop<T>(val: T) { | ||
drop(&val); //~ ERROR calls to `std::mem::drop` | ||
drop(val); | ||
} |
Oops, something went wrong.