rust/compiler/rustc_ast/src
bors fae7785b60 Auto merge of #139897 - nnethercote:rm-OpenDelim-CloseDelim, r=petrochenkov
Remove `token::{Open,Close}Delim`

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 {
```

r? `@petrochenkov`
2025-04-22 01:15:06 +00:00
..
attr Auto merge of #139897 - nnethercote:rm-OpenDelim-CloseDelim, r=petrochenkov 2025-04-22 01:15:06 +00:00
expand Rollup merge of #139351 - EnzymeAD:autodiff-batching2, r=oli-obk 2025-04-17 21:53:23 +02:00
util Replace rustc_lexer/unescape with rustc-literal-escaper crate 2025-04-04 14:44:45 +02:00
ast_traits.rs Remove NtBlock, Nonterminal, and TokenKind::Interpolated. 2025-04-02 16:07:02 +11:00
ast.rs Rollup merge of #139392 - compiler-errors:raw-expr, r=oli-obk 2025-04-14 18:15:31 +02:00
entry.rs remove support for the #[start] attribute 2025-01-21 06:59:15 -07:00
format.rs Limit formatting width and precision to 16 bits. 2025-03-10 12:20:05 +01:00
lib.rs Remove recursion_limit increases. 2025-04-02 16:25:27 +11:00
mut_visit.rs Auto merge of #124141 - nnethercote:rm-Nonterminal-and-TokenKind-Interpolated, r=petrochenkov 2025-04-14 03:56:55 +00:00
node_id.rs Reformat use declarations. 2024-07-29 08:26:52 +10:00
ptr.rs Convert some Into impls into From impls 2024-12-31 01:56:33 +00:00
token.rs Remove token::{Open,Close}Delim. 2025-04-21 07:35:56 +10:00
tokenstream.rs Remove TokenStream::flattened and InvisibleOrigin::FlattenToken. 2025-04-02 16:16:51 +11:00
visit.rs Rollup merge of #139112 - m-ou-se:super-let, r=lcnr 2025-04-07 22:29:18 +10:00