Check attributes on pattern fields.
Attributes on pattern struct fields were not being checked for validity. This adds the fields as HIR nodes so that the `CheckAttrVisitor` can visit those nodes to check their attributes.
This commit is contained in:
parent
b998821e4c
commit
1b464c73b7
10 changed files with 64 additions and 22 deletions
|
@ -652,7 +652,8 @@ impl CheckAttrVisitor<'_> {
|
|||
| Target::ForeignStatic
|
||||
| Target::ForeignTy
|
||||
| Target::GenericParam(..)
|
||||
| Target::MacroDef => None,
|
||||
| Target::MacroDef
|
||||
| Target::PatField => None,
|
||||
} {
|
||||
tcx.sess.emit_err(errors::DocAliasBadLocation { span, attr_str, location });
|
||||
return false;
|
||||
|
@ -2076,6 +2077,15 @@ impl<'tcx> Visitor<'tcx> for CheckAttrVisitor<'tcx> {
|
|||
|
||||
intravisit::walk_param(self, param);
|
||||
}
|
||||
|
||||
fn visit_pat(&mut self, p: &'tcx hir::Pat<'tcx>) {
|
||||
if let hir::PatKind::Struct(_, fields, _) = p.kind {
|
||||
for field in fields {
|
||||
self.check_attributes(field.hir_id, field.span, Target::PatField, None);
|
||||
}
|
||||
}
|
||||
intravisit::walk_pat(self, p);
|
||||
}
|
||||
}
|
||||
|
||||
fn is_c_like_enum(item: &Item<'_>) -> bool {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue