Honor lint level attributes in more places.
This extends the LintLevelBuilder to handle lint level attributes on struct expression fields and pattern fields. This also updates the early lints to honor lint levels on generic parameters.
This commit is contained in:
parent
b651c1cebe
commit
6c7cb2bb77
6 changed files with 1312 additions and 6 deletions
|
@ -219,9 +219,10 @@ impl<'a, T: EarlyLintPass> ast_visit::Visitor<'a> for EarlyContextAndPass<'a, T>
|
|||
}
|
||||
|
||||
fn visit_generic_param(&mut self, param: &'a ast::GenericParam) {
|
||||
run_early_pass!(self, check_generic_param, param);
|
||||
self.check_id(param.id);
|
||||
ast_visit::walk_generic_param(self, param);
|
||||
self.with_lint_attrs(param.id, ¶m.attrs, |cx| {
|
||||
run_early_pass!(cx, check_generic_param, param);
|
||||
ast_visit::walk_generic_param(cx, param);
|
||||
});
|
||||
}
|
||||
|
||||
fn visit_generics(&mut self, g: &'a ast::Generics) {
|
||||
|
|
|
@ -761,9 +761,26 @@ impl<'tcx> intravisit::Visitor<'tcx> for LintLevelMapBuilder<'tcx> {
|
|||
}
|
||||
|
||||
fn visit_expr(&mut self, e: &'tcx hir::Expr<'tcx>) {
|
||||
self.with_lint_attrs(e.hir_id, |builder| {
|
||||
intravisit::walk_expr(builder, e);
|
||||
})
|
||||
match e.kind {
|
||||
hir::ExprKind::Struct(qpath, fields, base_expr) => {
|
||||
self.with_lint_attrs(e.hir_id, |builder| {
|
||||
builder.visit_qpath(qpath, e.hir_id, e.span);
|
||||
for field in fields {
|
||||
builder.with_lint_attrs(field.hir_id, |field_builder| {
|
||||
field_builder.visit_id(field.hir_id);
|
||||
field_builder.visit_ident(field.ident);
|
||||
field_builder.visit_expr(field.expr);
|
||||
});
|
||||
}
|
||||
if let Some(base_expr) = base_expr {
|
||||
builder.visit_expr(base_expr);
|
||||
}
|
||||
});
|
||||
}
|
||||
_ => self.with_lint_attrs(e.hir_id, |builder| {
|
||||
intravisit::walk_expr(builder, e);
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
fn visit_field_def(&mut self, s: &'tcx hir::FieldDef<'tcx>) {
|
||||
|
@ -801,6 +818,28 @@ impl<'tcx> intravisit::Visitor<'tcx> for LintLevelMapBuilder<'tcx> {
|
|||
intravisit::walk_impl_item(builder, impl_item);
|
||||
});
|
||||
}
|
||||
|
||||
fn visit_pat(&mut self, p: &'tcx hir::Pat<'tcx>) {
|
||||
match &p.kind {
|
||||
hir::PatKind::Struct(qpath, fields, _) => {
|
||||
self.visit_qpath(&qpath, p.hir_id, p.span);
|
||||
for field in *fields {
|
||||
self.with_lint_attrs(field.hir_id, |builder| {
|
||||
builder.visit_id(field.hir_id);
|
||||
builder.visit_ident(field.ident);
|
||||
builder.visit_pat(field.pat);
|
||||
})
|
||||
}
|
||||
}
|
||||
_ => intravisit::walk_pat(self, p),
|
||||
}
|
||||
}
|
||||
|
||||
fn visit_generic_param(&mut self, p: &'tcx hir::GenericParam<'tcx>) {
|
||||
self.with_lint_attrs(p.hir_id, |builder| {
|
||||
intravisit::walk_generic_param(builder, p);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
pub fn provide(providers: &mut Providers) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue