rust/compiler/rustc_expand/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
..
mbe Remove token::{Open,Close}Delim. 2025-04-21 07:35:56 +10:00
base.rs Replace infallible name_or_empty methods with fallible name methods. 2025-04-17 09:50:52 +10:00
build.rs Implement super let. 2025-04-04 09:44:19 +02:00
config.rs Remove token::{Open,Close}Delim. 2025-04-21 07:35:56 +10:00
errors.rs Re-export more rustc_span::symbol things from rustc_span. 2024-12-18 13:38:53 +11:00
expand.rs Auto merge of #139897 - nnethercote:rm-OpenDelim-CloseDelim, r=petrochenkov 2025-04-22 01:15:06 +00:00
lib.rs Remove #![warn(unreachable_pub)] from all compiler/ crates. 2025-03-11 13:14:21 +11:00
mbe.rs Re-export more rustc_span::symbol things from rustc_span. 2024-12-18 13:38:53 +11:00
module.rs Reject macro calls inside of #![crate_name] 2025-02-15 16:47:30 +01:00
placeholders.rs Move ast::Item::ident into ast::ItemKind. 2025-04-01 14:08:57 +11:00
proc_macro_server.rs Remove token::{Open,Close}Delim. 2025-04-21 07:35:56 +10:00
proc_macro.rs Remove NtItem and NtStmt. 2025-03-07 14:51:07 +11:00