21 Commits

Author SHA1 Message Date
Pavel Grigorenko
aa80a2b62c Port #[rustc_skip_during_method_dispatch] to the new attribute system 2025-06-23 22:48:20 +03:00
Jana Dönszelmann
5c0a625205
move naked checks out of check_attr.rs 2025-06-23 12:22:57 +02:00
Jana Dönszelmann
6072207a11
introduce new lint infra
lint on duplicates during attribute parsing
To do this we stuff them in the diagnostic context to be emitted after
hir is constructed
2025-06-12 09:56:47 +02:00
Matthias Krüger
c1e8fe760b
Rollup merge of #141271 - nnethercote:attr-streamline, r=jdonszelmann
Streamline some attr parsing APIs

r? ``@jdonszelmann``
2025-06-04 16:24:06 +02:00
Nicholas Nethercote
e5c78de85c Rename MetaItemParser::path_without_args as MetaItemParser::path.
And avoid the clone.
2025-05-21 04:53:31 +10:00
Nicholas Nethercote
2cd2d24967 Remove MetaItemParser::{path,deconstruct}.
They're equivalent, and `path` is unused, and `deconstruct` has only one
call site outside of `path`.
2025-05-21 04:53:31 +10:00
Nicholas Nethercote
ea3b3fdcc1 Remove MetaItemParser::{word,word_without_args,path_is}.
They are unused.
2025-05-21 04:53:31 +10:00
Nicholas Nethercote
a822e557cd Remove an unnecessary lifetime. 2025-05-21 04:53:24 +10:00
Nicholas Nethercote
ee1c2d583a Remove MetaItemListParser::all_{word,path}_list, which are unused. 2025-05-20 11:58:11 +10:00
Nicholas Nethercote
354b1cbcca Avoid rustc_span:: qualifiers.
In several files they are entirely unnecessary, with the relevant names
already imported. And in a few I have added the necessary `use` item.
2025-05-20 09:20:27 +10:00
Nicholas Nethercote
d81472f266 Eliminate word_or_empty methods.
To get rid of the `Ident::empty` uses.

This requires introducing `PathParser::word_sym`, as an alternative to
`PathParser::word`.
2025-05-07 12:56:41 +10:00
Nicholas Nethercote
bf8ce32558 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 {
```
2025-04-21 07:35:56 +10:00
Nicholas Nethercote
bb495d6d3e Remove NtBlock, Nonterminal, and TokenKind::Interpolated.
`NtBlock` is the last remaining variant of `Nonterminal`, so once it is
gone then `Nonterminal` can be removed as well.
2025-04-02 16:07:02 +11:00
Nicholas Nethercote
0b2d7062c4 Introduce sym::dummy and Ident::dummy.
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-12 09:35:11 +11:00
Michael Goulet
34d273b4bf
Rollup merge of #137758 - jdonszelmann:fix-137662, r=nnethercote
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-03-06 12:22:15 -05:00
Jana Dönszelmann
41dd80aeaa
add test to reproduce #137662 (using ty decl macro fragment in an attr) and fix it 2025-02-28 09:43:46 +01:00
Nicholas Nethercote
50076cdeb9 Remove NtPath. 2025-02-28 08:42:14 +11:00
Nicholas Nethercote
7ea59e053b Remove NtMeta.
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-28 08:42:06 +11:00
Jana Dönszelmann
4bf66c57fa
fix #137589 2025-02-25 18:17:32 +01:00
Jana Dönszelmann
2f0652745d
add test to verify that #132391 can be closed 2025-02-24 14:31:19 +01:00
Jana Dönszelmann
dbd3b7928e
Introduce new parsing infrastructure and types for parsed attributes
fixup docs in parser
2025-02-24 14:26:06 +01:00