DotDot,
DotDotDot,
DotDotEq,
- DotEq, // HACK(durka42) never produced by the parser, only used for libproc_macro
Comma,
Semi,
Colon,
Dot => match joint {
Dot => DotDot,
DotDot => DotDotDot,
- DotEq => DotDotEq,
_ => return None,
},
DotDot => match joint {
_ => return None,
},
- Le | EqEq | Ne | Ge | AndAnd | OrOr | Tilde | BinOpEq(..) | At | DotDotDot | DotEq |
+ Le | EqEq | Ne | Ge | AndAnd | OrOr | Tilde | BinOpEq(..) | At | DotDotDot |
DotDotEq | Comma | Semi | ModSep | RArrow | LArrow | FatArrow | Pound | Dollar |
Question | OpenDelim(..) | CloseDelim(..) => return None,
let tokens_for_real = nt.1.force(|| {
// FIXME(#43081): Avoid this pretty-print + reparse hack
let source = pprust::token_to_string(self);
- parse_stream_from_source_str(FileName::MacroExpansion, source, sess, Some(span))
+ let filename = FileName::macro_expansion_source_code(&source);
+ parse_stream_from_source_str(filename, source, sess, Some(span))
});
// During early phases of the compiler the AST could get modified
- // directly (e.g. attributes added or removed) and the internal cache
+ // directly (e.g., attributes added or removed) and the internal cache
// of tokens my not be invalidated or updated. Consequently if the
// "lossless" token stream disagrees with our actual stringification
// (which has historically been much more battle-tested) then we go
//
// Instead the "probably equal" check here is "does each token
// recursively have the same discriminant?" We basically don't look at
- // the token values here and assume that such fine grained modifications
- // of token streams doesn't happen.
+ // the token values here and assume that such fine grained token stream
+ // modifications, including adding/removing typically non-semantic
+ // tokens such as extra braces and commas, don't happen.
if let Some(tokens) = tokens {
if tokens.probably_equal_for_proc_macro(&tokens_for_real) {
return tokens
(&DotDot, &DotDot) |
(&DotDotDot, &DotDotDot) |
(&DotDotEq, &DotDotEq) |
- (&DotEq, &DotEq) |
(&Comma, &Comma) |
(&Semi, &Semi) |
(&Colon, &Colon) |
assert_eq!(attr.style, ast::AttrStyle::Outer,
"inner attributes should prevent cached tokens from existing");
+ let source = pprust::attr_to_string(attr);
+ let macro_filename = FileName::macro_expansion_source_code(&source);
if attr.is_sugared_doc {
let stream = parse_stream_from_source_str(
- FileName::MacroExpansion,
- pprust::attr_to_string(attr),
+ macro_filename,
+ source,
sess,
Some(span),
);
// should eventually be removed.
} else {
let stream = parse_stream_from_source_str(
- FileName::MacroExpansion,
- pprust::path_to_string(&attr.path),
+ macro_filename,
+ source,
sess,
Some(span),
);