-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
liveness: Warn about unused captured variables
- Loading branch information
Showing
12 changed files
with
505 additions
and
64 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 |
---|---|---|
@@ -1,10 +1,11 @@ | ||
// run-pass | ||
#![forbid(warnings)] | ||
|
||
// We shouldn't need to rebind a moved upvar as mut if it's already | ||
// marked as mut | ||
|
||
pub fn main() { | ||
let mut x = 1; | ||
let _thunk = Box::new(move|| { x = 2; }); | ||
//~^ WARN value assigned to `x` is never read | ||
//~| WARN unused variable: `x` | ||
} |
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,20 @@ | ||
warning: value assigned to `x` is never read | ||
--> $DIR/issue-11958.rs:8:36 | ||
| | ||
LL | let _thunk = Box::new(move|| { x = 2; }); | ||
| ^ | ||
| | ||
= note: `#[warn(unused_assignments)]` on by default | ||
= help: maybe it is overwritten before being read? | ||
|
||
warning: unused variable: `x` | ||
--> $DIR/issue-11958.rs:8:36 | ||
| | ||
LL | let _thunk = Box::new(move|| { x = 2; }); | ||
| ^ | ||
| | ||
= note: `#[warn(unused_variables)]` on by default | ||
= help: did you mean to capture by reference instead? | ||
|
||
warning: 2 warnings emitted | ||
|
Oops, something went wrong.