-
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.
- Loading branch information
Showing
8 changed files
with
53 additions
and
50 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 was deleted.
Oops, something went wrong.
29 changes: 29 additions & 0 deletions
29
tests/ui/lint/lint-returning-pointers-to-local-variables.rs
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,29 @@ | ||
//@ check-pass | ||
|
||
#![warn(returning_pointers_to_local_variables)] | ||
|
||
fn foo() -> *const u32 { | ||
let empty = 42u32; | ||
return &empty as *const _; | ||
//~^ WARN returning a pointer to stack memory associated with a local variable | ||
} | ||
|
||
fn bar() -> *const u32 { | ||
let empty = 42u32; | ||
&empty as *const _ | ||
//~^ WARN returning a pointer to stack memory associated with a local variable | ||
} | ||
|
||
fn baz() -> *const u32 { | ||
let empty = 42u32; | ||
return ∅ | ||
//~^ WARN returning a pointer to stack memory associated with a local variable | ||
} | ||
|
||
fn faa() -> *const u32 { | ||
let empty = 42u32; | ||
&empty | ||
//~^ WARN returning a pointer to stack memory associated with a local variable | ||
} | ||
|
||
fn main() {} |
14 changes: 7 additions & 7 deletions
14
...int/lint-return-local-variable-ptr.stderr → ...urning-pointers-to-local-variables.stderr
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