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
|
@ -89,6 +89,7 @@ impl<'a> State<'a> {
|
|||
Node::TypeBinding(a) => self.print_type_binding(a),
|
||||
Node::TraitRef(a) => self.print_trait_ref(a),
|
||||
Node::Pat(a) => self.print_pat(a),
|
||||
Node::PatField(a) => self.print_patfield(&a),
|
||||
Node::Arm(a) => self.print_arm(a),
|
||||
Node::Infer(_) => self.word("_"),
|
||||
Node::Block(a) => {
|
||||
|
@ -1799,20 +1800,7 @@ impl<'a> State<'a> {
|
|||
if !empty {
|
||||
self.space();
|
||||
}
|
||||
self.commasep_cmnt(
|
||||
Consistent,
|
||||
fields,
|
||||
|s, f| {
|
||||
s.cbox(INDENT_UNIT);
|
||||
if !f.is_shorthand {
|
||||
s.print_ident(f.ident);
|
||||
s.word_nbsp(":");
|
||||
}
|
||||
s.print_pat(f.pat);
|
||||
s.end()
|
||||
},
|
||||
|f| f.pat.span,
|
||||
);
|
||||
self.commasep_cmnt(Consistent, &fields, |s, f| s.print_patfield(f), |f| f.pat.span);
|
||||
if etc {
|
||||
if !fields.is_empty() {
|
||||
self.word_space(",");
|
||||
|
@ -1907,6 +1895,20 @@ impl<'a> State<'a> {
|
|||
self.ann.post(self, AnnNode::Pat(pat))
|
||||
}
|
||||
|
||||
pub fn print_patfield(&mut self, field: &hir::PatField<'_>) {
|
||||
if self.attrs(field.hir_id).is_empty() {
|
||||
self.space();
|
||||
}
|
||||
self.cbox(INDENT_UNIT);
|
||||
self.print_outer_attributes(&self.attrs(field.hir_id));
|
||||
if !field.is_shorthand {
|
||||
self.print_ident(field.ident);
|
||||
self.word_nbsp(":");
|
||||
}
|
||||
self.print_pat(field.pat);
|
||||
self.end();
|
||||
}
|
||||
|
||||
pub fn print_param(&mut self, arg: &hir::Param<'_>) {
|
||||
self.print_outer_attributes(self.attrs(arg.hir_id));
|
||||
self.print_pat(arg.pat);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue