Visit PatField when collecting lint levels
This commit is contained in:
parent
0998d4095b
commit
8bf33c213f
2 changed files with 26 additions and 0 deletions
|
@ -299,6 +299,11 @@ impl<'tcx> Visitor<'tcx> for LintLevelsBuilder<'_, LintLevelQueryMap<'tcx>> {
|
||||||
intravisit::walk_expr(self, e);
|
intravisit::walk_expr(self, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn visit_pat_field(&mut self, f: &'tcx hir::PatField<'tcx>) -> Self::Result {
|
||||||
|
self.add_id(f.hir_id);
|
||||||
|
intravisit::walk_pat_field(self, f);
|
||||||
|
}
|
||||||
|
|
||||||
fn visit_expr_field(&mut self, f: &'tcx hir::ExprField<'tcx>) {
|
fn visit_expr_field(&mut self, f: &'tcx hir::ExprField<'tcx>) {
|
||||||
self.add_id(f.hir_id);
|
self.add_id(f.hir_id);
|
||||||
intravisit::walk_expr_field(self, f);
|
intravisit::walk_expr_field(self, f);
|
||||||
|
|
21
tests/ui/lint/unused/unused-field-in-pat-field.rs
Normal file
21
tests/ui/lint/unused/unused-field-in-pat-field.rs
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
//@ check-pass
|
||||||
|
|
||||||
|
// Ensure we collect lint levels from pat fields in structs.
|
||||||
|
|
||||||
|
#![deny(unused_variables)]
|
||||||
|
|
||||||
|
pub struct Foo {
|
||||||
|
bar: u32,
|
||||||
|
baz: u32,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn test(foo: Foo) {
|
||||||
|
let Foo {
|
||||||
|
#[allow(unused_variables)]
|
||||||
|
bar,
|
||||||
|
#[allow(unused_variables)]
|
||||||
|
baz,
|
||||||
|
} = foo;
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {}
|
Loading…
Add table
Add a link
Reference in a new issue