1
Fork 0

Use reparsed TokenStream if we captured any inner attributes

Fixes #78675

We now bail out of `prepend_attrs` if we ended up capturing any inner
attributes (which can happen in several places, due to token capturing
for `macro_rules!` arguments.
This commit is contained in:
Aaron Hill 2020-11-02 13:22:03 -05:00
parent 499ebcfdf3
commit 22383b32b8
No known key found for this signature in database
GPG key ID: B4087E510E98B164
4 changed files with 132 additions and 29 deletions

View file

@ -611,11 +611,11 @@ fn prepend_attrs(
}
let mut builder = tokenstream::TokenStreamBuilder::new();
for attr in attrs {
assert_eq!(
attr.style,
ast::AttrStyle::Outer,
"inner attributes should prevent cached tokens from existing"
);
// FIXME: Correctly handle tokens for inner attributes.
// For now, we fall back to reparsing the original AST node
if attr.style == ast::AttrStyle::Inner {
return None;
}
builder.push(
attr.tokens
.as_ref()