Unconditionally capture tokens for attributes.
This allows us to avoid synthesizing tokens in `prepend_attr`, since we have the original tokens available. We still need to synthesize tokens when expanding `cfg_attr`, but this is an unavoidable consequence of the syntax of `cfg_attr` - the user does not supply the `#` and `[]` tokens that a `cfg_attr` expands to.
This commit is contained in:
parent
1eaadebb3d
commit
b9b2546417
15 changed files with 153 additions and 120 deletions
|
@ -972,7 +972,8 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
|||
AttrKind::DocComment(comment_kind, data) => AttrKind::DocComment(comment_kind, data),
|
||||
};
|
||||
|
||||
Attribute { kind, id: attr.id, style: attr.style, span: attr.span }
|
||||
// Tokens aren't needed after macro expansion and parsing
|
||||
Attribute { kind, id: attr.id, style: attr.style, span: attr.span, tokens: None }
|
||||
}
|
||||
|
||||
fn lower_mac_args(&mut self, args: &MacArgs) -> MacArgs {
|
||||
|
@ -1713,7 +1714,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
|||
pat: self.lower_pat(&l.pat),
|
||||
init,
|
||||
span: l.span,
|
||||
attrs: l.attrs.clone(),
|
||||
attrs: l.attrs.iter().map(|a| self.lower_attr(a)).collect::<Vec<_>>().into(),
|
||||
source: hir::LocalSource::Normal,
|
||||
},
|
||||
ids,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue