Skip to content

Commit 47ff4af

Browse files
authored
Unrolled build for rust-lang#138434
Rollup merge of rust-lang#138434 - compiler-errors:lint-level-pat-field, r=jieyouxu Visit `PatField` when collecting lint levels Fixes rust-lang#138428 Side-note, I vaguely skimmed over the other nodes we could be visiting here and it doesn't *seem* to me that we're missing anything, though I may be mistaken given recent(?) support for attrs in where clauses(??). Can be fixed in a follow-up PR.
2 parents 523c507 + 8bf33c2 commit 47ff4af

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

compiler/rustc_lint/src/levels.rs

+5
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,11 @@ impl<'tcx> Visitor<'tcx> for LintLevelsBuilder<'_, LintLevelQueryMap<'tcx>> {
299299
intravisit::walk_expr(self, e);
300300
}
301301

302+
fn visit_pat_field(&mut self, f: &'tcx hir::PatField<'tcx>) -> Self::Result {
303+
self.add_id(f.hir_id);
304+
intravisit::walk_pat_field(self, f);
305+
}
306+
302307
fn visit_expr_field(&mut self, f: &'tcx hir::ExprField<'tcx>) {
303308
self.add_id(f.hir_id);
304309
intravisit::walk_expr_field(self, f);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//@ check-pass
2+
3+
// Ensure we collect lint levels from pat fields in structs.
4+
5+
#![deny(unused_variables)]
6+
7+
pub struct Foo {
8+
bar: u32,
9+
baz: u32,
10+
}
11+
12+
pub fn test(foo: Foo) {
13+
let Foo {
14+
#[allow(unused_variables)]
15+
bar,
16+
#[allow(unused_variables)]
17+
baz,
18+
} = foo;
19+
}
20+
21+
fn main() {}

0 commit comments

Comments
 (0)