forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#47922 - zackmdavis:and_the_case_of_the_unus…
…ed_field_pattern, r=estebank correct unused field pattern suggestions ![unused_field_pattern_local](https://user-images.githubusercontent.com/1076988/35662336-7a69488a-06cc-11e8-9901-8d22b5cf924f.png) r? @estebank
- Loading branch information
Showing
5 changed files
with
127 additions
and
17 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
34 changes: 34 additions & 0 deletions
34
src/test/ui/lint/issue-47390-unused-variable-in-struct-pattern.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,34 @@ | ||
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT | ||
// file at the top-level directory of this distribution and at | ||
// http://rust-lang.org/COPYRIGHT. | ||
// | ||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | ||
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
||
// must-compile-successfully | ||
|
||
#![warn(unused)] // UI tests pass `-A unused` (#43896) | ||
|
||
struct SoulHistory { | ||
corridors_of_light: usize, | ||
hours_are_suns: bool, | ||
endless_and_singing: bool | ||
} | ||
|
||
fn main() { | ||
let i_think_continually = 2; | ||
let who_from_the_womb_remembered = SoulHistory { | ||
corridors_of_light: 5, | ||
hours_are_suns: true, | ||
endless_and_singing: true | ||
}; | ||
|
||
if let SoulHistory { corridors_of_light, | ||
mut hours_are_suns, | ||
endless_and_singing: true } = who_from_the_womb_remembered { | ||
hours_are_suns = false; | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
src/test/ui/lint/issue-47390-unused-variable-in-struct-pattern.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
warning: unused variable: `i_think_continually` | ||
--> $DIR/issue-47390-unused-variable-in-struct-pattern.rs:22:9 | ||
| | ||
22 | let i_think_continually = 2; | ||
| ^^^^^^^^^^^^^^^^^^^ help: consider using `_i_think_continually` instead | ||
| | ||
note: lint level defined here | ||
--> $DIR/issue-47390-unused-variable-in-struct-pattern.rs:13:9 | ||
| | ||
13 | #![warn(unused)] // UI tests pass `-A unused` (#43896) | ||
| ^^^^^^ | ||
= note: #[warn(unused_variables)] implied by #[warn(unused)] | ||
|
||
warning: unused variable: `corridors_of_light` | ||
--> $DIR/issue-47390-unused-variable-in-struct-pattern.rs:29:26 | ||
| | ||
29 | if let SoulHistory { corridors_of_light, | ||
| ^^^^^^^^^^^^^^^^^^ help: try ignoring the field: `corridors_of_light: _` | ||
|
||
warning: variable `hours_are_suns` is assigned to, but never used | ||
--> $DIR/issue-47390-unused-variable-in-struct-pattern.rs:30:26 | ||
| | ||
30 | mut hours_are_suns, | ||
| ^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: consider using `_hours_are_suns` instead | ||
|
||
warning: value assigned to `hours_are_suns` is never read | ||
--> $DIR/issue-47390-unused-variable-in-struct-pattern.rs:32:9 | ||
| | ||
32 | hours_are_suns = false; | ||
| ^^^^^^^^^^^^^^ | ||
| | ||
note: lint level defined here | ||
--> $DIR/issue-47390-unused-variable-in-struct-pattern.rs:13:9 | ||
| | ||
13 | #![warn(unused)] // UI tests pass `-A unused` (#43896) | ||
| ^^^^^^ | ||
= note: #[warn(unused_assignments)] implied by #[warn(unused)] | ||
|
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