summary refs log tree commit diff
path: root/compiler/rustc_attr_parsing/src/parser.rs
AgeCommit message (Collapse)AuthorLines
2025-05-07Eliminate `word_or_empty` methods.Nicholas Nethercote-13/+2
To get rid of the `Ident::empty` uses. This requires introducing `PathParser::word_sym`, as an alternative to `PathParser::word`.
2025-04-21Remove `token::{Open,Close}Delim`.Nicholas Nethercote-3/+1
By replacing them with `{Open,Close}{Param,Brace,Bracket,Invisible}`. PR #137902 made `ast::TokenKind` more like `lexer::TokenKind` by replacing the compound `BinOp{,Eq}(BinOpToken)` variants with fieldless variants `Plus`, `Minus`, `Star`, etc. This commit does a similar thing with delimiters. It also makes `ast::TokenKind` more similar to `parser::TokenType`. This requires a few new methods: - `TokenKind::is_{,open_,close_}delim()` replace various kinds of pattern matches. - `Delimiter::as_{open,close}_token_kind` are used to convert `Delimiter` values to `TokenKind`. Despite these additions, it's a net reduction in lines of code. This is because e.g. `token::OpenParen` is so much shorter than `token::OpenDelim(Delimiter::Parenthesis)` that many multi-line forms reduce to single line forms. And many places where the number of lines doesn't change are still easier to read, just because the names are shorter, e.g.: ``` - } else if self.token != token::CloseDelim(Delimiter::Brace) { + } else if self.token != token::CloseBrace { ```
2025-04-02Remove `NtBlock`, `Nonterminal`, and `TokenKind::Interpolated`.Nicholas Nethercote-19/+1
`NtBlock` is the last remaining variant of `Nonterminal`, so once it is gone then `Nonterminal` can be removed as well.
2025-03-12Introduce `sym::dummy` and `Ident::dummy`.Nicholas Nethercote-2/+2
The idea is to identify cases of symbols/identifiers that are not expected to be used. There isn't a perfectly sharp line between "dummy" and "not dummy", but I think it's useful nonetheless.
2025-03-06Rollup merge of #137758 - jdonszelmann:fix-137662, r=nnethercoteMichael Goulet-0/+9
fix usage of ty decl macro fragments in attributes See the test case. Due to one missing code path (and also the changes in #137517), using $ty or other specific fragments as part of an attr wouldn't work. $tt used to work since it wouldn't be parsed anywhere along the way. Closes #137662
2025-02-28add test to reproduce #137662 (using ty decl macro fragment in an attr) and ↵Jana Dönszelmann-0/+9
fix it
2025-02-28Remove `NtPath`.Nicholas Nethercote-24/+13
2025-02-28Remove `NtMeta`.Nicholas Nethercote-9/+0
Note: there was an existing code path involving `Interpolated` in `MetaItem::from_tokens` that was dead. This commit transfers that to the new form, but puts an `unreachable!` call inside it.
2025-02-25fix #137589Jana Dönszelmann-5/+8
2025-02-24add test to verify that #132391 can be closedJana Dönszelmann-4/+3
2025-02-24Introduce new parsing infrastructure and types for parsed attributesJana Dönszelmann-0/+625
fixup docs in parser