-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added lint for unnecessary references
- Loading branch information
Aaron Power
committed
May 28, 2018
1 parent
fc008aa
commit bc8229d
Showing
4 changed files
with
80 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#![feature(tool_attributes)] | ||
#![feature(stmt_expr_attributes)] | ||
|
||
struct Outer { | ||
inner: u32, | ||
} | ||
|
||
#[deny(ref_in_deref)] | ||
fn main() { | ||
let outer = Outer { inner: 0 }; | ||
let inner = (&outer).inner; | ||
} |
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,14 @@ | ||
error: Creating a reference that is immediately dereferenced. | ||
--> $DIR/unnecessary_ref.rs:11:17 | ||
| | ||
11 | let inner = (&outer).inner; | ||
| ^^^^^^^^ help: try this: `outer.inner` | ||
| | ||
note: lint level defined here | ||
--> $DIR/unnecessary_ref.rs:8:8 | ||
| | ||
8 | #[deny(ref_in_deref)] | ||
| ^^^^^^^^^^^^ | ||
|
||
error: aborting due to previous error | ||
|