Fix "field is never used" warning to take unions into account
Rather than saying "struct or union" or adding logic to determine the type of the item, just change the message to "field is never used", dropping the "struct". Update tests accordingly.
This commit is contained in:
parent
d748fa6ecc
commit
fe8438d4a2
2 changed files with 6 additions and 6 deletions
|
|
@ -548,7 +548,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for DeadVisitor<'a, 'tcx> {
|
|||
fn visit_struct_field(&mut self, field: &hir::StructField) {
|
||||
if self.should_warn_about_field(&field) {
|
||||
self.warn_dead_code(field.id, field.span,
|
||||
field.name, "struct field");
|
||||
field.name, "field");
|
||||
}
|
||||
|
||||
intravisit::walk_struct_field(self, field);
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
struct Foo {
|
||||
x: usize,
|
||||
b: bool, //~ ERROR: struct field is never used
|
||||
b: bool, //~ ERROR: field is never used
|
||||
}
|
||||
|
||||
fn field_read(f: Foo) -> usize {
|
||||
|
|
@ -46,8 +46,8 @@ enum IJK {
|
|||
I, //~ ERROR variant is never used
|
||||
J {
|
||||
a: String,
|
||||
b: i32, //~ ERROR struct field is never used
|
||||
c: i32, //~ ERROR struct field is never used
|
||||
b: i32, //~ ERROR field is never used
|
||||
c: i32, //~ ERROR field is never used
|
||||
},
|
||||
K //~ ERROR variant is never used
|
||||
|
||||
|
|
@ -68,9 +68,9 @@ fn field_match_in_patterns(b: XYZ) -> String {
|
|||
}
|
||||
|
||||
struct Bar {
|
||||
x: usize, //~ ERROR: struct field is never used
|
||||
x: usize, //~ ERROR: field is never used
|
||||
b: bool,
|
||||
c: bool, //~ ERROR: struct field is never used
|
||||
c: bool, //~ ERROR: field is never used
|
||||
_guard: ()
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue