1
Fork 0

Correct unused field warning on box struct match

This commit is contained in:
varkor 2018-04-30 00:51:02 +01:00
parent cc53db8bf9
commit 8e8fe9042c
3 changed files with 24 additions and 11 deletions

View file

@ -430,8 +430,9 @@ fn visit_arm<'a, 'tcx>(ir: &mut IrMaps<'a, 'tcx>, arm: &'tcx hir::Arm) {
}
break;
}
hir::PatKind::Ref(ref deref_pat, _) => {
pat = deref_pat;
hir::PatKind::Ref(ref inner_pat, _) |
hir::PatKind::Box(ref inner_pat) => {
pat = inner_pat;
}
_ => break
}

View file

@ -10,6 +10,8 @@
// compile-pass
#![feature(box_syntax)]
#![feature(box_patterns)]
#![warn(unused)] // UI tests pass `-A unused` (#43896)
struct SoulHistory {
@ -36,11 +38,15 @@ fn main() {
hours_are_suns = false;
}
let bag = &Large::Suit {
let bag = Large::Suit {
case: ()
};
match bag {
match &bag {
&Large::Suit { case } => {}
};
match box bag {
box Large::Suit { case } => {}
};
}

View file

@ -1,24 +1,24 @@
warning: unused variable: `i_think_continually`
--> $DIR/issue-47390-unused-variable-in-struct-pattern.rs:26:9
--> $DIR/issue-47390-unused-variable-in-struct-pattern.rs:28:9
|
LL | 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
--> $DIR/issue-47390-unused-variable-in-struct-pattern.rs:15:9
|
LL | #![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:33:26
--> $DIR/issue-47390-unused-variable-in-struct-pattern.rs:35:26
|
LL | 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:34:26
--> $DIR/issue-47390-unused-variable-in-struct-pattern.rs:36:26
|
LL | mut hours_are_suns,
| ^^^^^^^^^^^^^^^^^^
@ -26,21 +26,27 @@ LL | 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:36:9
--> $DIR/issue-47390-unused-variable-in-struct-pattern.rs:38:9
|
LL | hours_are_suns = false;
| ^^^^^^^^^^^^^^
|
note: lint level defined here
--> $DIR/issue-47390-unused-variable-in-struct-pattern.rs:13:9
--> $DIR/issue-47390-unused-variable-in-struct-pattern.rs:15:9
|
LL | #![warn(unused)] // UI tests pass `-A unused` (#43896)
| ^^^^^^
= note: #[warn(unused_assignments)] implied by #[warn(unused)]
warning: unused variable: `case`
--> $DIR/issue-47390-unused-variable-in-struct-pattern.rs:44:24
--> $DIR/issue-47390-unused-variable-in-struct-pattern.rs:46:24
|
LL | &Large::Suit { case } => {}
| ^^^^ help: try ignoring the field: `case: _`
warning: unused variable: `case`
--> $DIR/issue-47390-unused-variable-in-struct-pattern.rs:50:27
|
LL | box Large::Suit { case } => {}
| ^^^^ help: try ignoring the field: `case: _`