-
Notifications
You must be signed in to change notification settings - Fork 13k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Lcargo_add::no_default_features::et lint_forgetting_references give …
…the suggestion if possible
- Loading branch information
Showing
10 changed files
with
383 additions
and
46 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
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,40 @@ | ||
//@ check-fail | ||
//@ run-rustfix | ||
|
||
#![deny(forgetting_references)] | ||
|
||
use std::mem::forget; | ||
|
||
struct SomeStruct; | ||
|
||
fn main() { | ||
let _ = &SomeStruct; //~ ERROR calls to `std::mem::forget` | ||
|
||
let mut owned = SomeStruct; | ||
let _ = &owned; //~ ERROR calls to `std::mem::forget` | ||
let _ = &&owned; //~ ERROR calls to `std::mem::forget` | ||
let _ = &mut owned; //~ ERROR calls to `std::mem::forget` | ||
forget(owned); | ||
|
||
let reference1 = &SomeStruct; | ||
let _ = &*reference1; //~ ERROR calls to `std::mem::forget` | ||
|
||
let reference2 = &mut SomeStruct; | ||
let _ = reference2; //~ ERROR calls to `std::mem::forget` | ||
|
||
let ref reference3 = SomeStruct; | ||
let _ = reference3; //~ ERROR calls to `std::mem::forget` | ||
} | ||
|
||
#[allow(dead_code)] | ||
fn test_generic_fn_forget<T>(val: T) { | ||
let _ = &val; //~ ERROR calls to `std::mem::forget` | ||
forget(val); | ||
} | ||
|
||
#[allow(dead_code)] | ||
fn test_similarly_named_function() { | ||
fn forget<T>(_val: T) {} | ||
forget(&SomeStruct); //OK; call to unrelated function which happens to have the same name | ||
let _ = &SomeStruct; //~ ERROR calls to `std::mem::forget` | ||
} |
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,40 @@ | ||
//@ check-fail | ||
//@ run-rustfix | ||
|
||
#![deny(forgetting_references)] | ||
|
||
use std::mem::forget; | ||
|
||
struct SomeStruct; | ||
|
||
fn main() { | ||
forget(&SomeStruct); //~ ERROR calls to `std::mem::forget` | ||
|
||
let mut owned = SomeStruct; | ||
forget(&owned); //~ ERROR calls to `std::mem::forget` | ||
forget(&&owned); //~ ERROR calls to `std::mem::forget` | ||
forget(&mut owned); //~ ERROR calls to `std::mem::forget` | ||
forget(owned); | ||
|
||
let reference1 = &SomeStruct; | ||
forget(&*reference1); //~ ERROR calls to `std::mem::forget` | ||
|
||
let reference2 = &mut SomeStruct; | ||
forget(reference2); //~ ERROR calls to `std::mem::forget` | ||
|
||
let ref reference3 = SomeStruct; | ||
forget(reference3); //~ ERROR calls to `std::mem::forget` | ||
} | ||
|
||
#[allow(dead_code)] | ||
fn test_generic_fn_forget<T>(val: T) { | ||
forget(&val); //~ ERROR calls to `std::mem::forget` | ||
forget(val); | ||
} | ||
|
||
#[allow(dead_code)] | ||
fn test_similarly_named_function() { | ||
fn forget<T>(_val: T) {} | ||
forget(&SomeStruct); //OK; call to unrelated function which happens to have the same name | ||
std::mem::forget(&SomeStruct); //~ ERROR calls to `std::mem::forget` | ||
} |
Oops, something went wrong.