about summary refs log tree commit diff
path: root/compiler/rustc_parse/src/validate_attr.rs
AgeCommit message (Collapse)AuthorLines
2022-05-05Overhaul `MacArgs::Eq`.Nicholas Nethercote-7/+32
The value in `MacArgs::Eq` is currently represented as a `Token`. Because of `TokenKind::Interpolated`, `Token` can be either a token or an arbitrary AST fragment. In practice, a `MacArgs::Eq` starts out as a literal or macro call AST fragment, and then is later lowered to a literal token. But this is very non-obvious. `Token` is a much more general type than what is needed. This commit restricts things, by introducing a new type `MacArgsEqKind` that is either an AST expression (pre-lowering) or an AST literal (post-lowering). The downside is that the code is a bit more verbose in a few places. The benefit is that makes it much clearer what the possibilities are (though also shorter in some other places). Also, it removes one use of `TokenKind::Interpolated`, taking us a step closer to removing that variant, which will let us make `Token` impl `Copy` and remove many "handle Interpolated" code paths in the parser. Things to note: - Error messages have improved. Messages like this: ``` unexpected token: `"bug" + "found"` ``` now say "unexpected expression", which makes more sense. Although arbitrary expressions can exist within tokens thanks to `TokenKind::Interpolated`, that's not obvious to anyone who doesn't know compiler internals. - In `parse_mac_args_common`, we no longer need to collect tokens for the value expression.
2021-11-12rustc_feature: Convert `BuiltinAttribute` from tuple to a structVadim Petrochenkov-6/+5
2021-09-25Check for macros in built-in attributes that don't support them.Eric Huss-1/+13
2021-09-25Move malformed attribute code to a function and fix inner attribute suggestion.Eric Huss-59/+60
Moving to a dedicated function in preparation for other validation. The suggestion given didn't consider if it was an inner attribute.
2021-08-25Use if-let guards in the codebaseLéo Lanteri Thauvin-9/+8
2021-01-09ast: Remove some indirection layers from values in key-value attributesVadim Petrochenkov-2/+3
2020-08-30mv compiler to compiler/mark-0/+163