Commit Graph

24 Commits

Author SHA1 Message Date
Jana Dönszelmann
5ab5f8a24a make error codes reflect reality better 2025-06-17 23:22:51 +02:00
Jana Dönszelmann
672452d573 use consistent attr errors in all attribute parsers 2025-06-17 23:19:31 +02:00
Jana Dönszelmann
ee976bbbca fix bugs in inline/force_inline and diagnostics of all attr parsers 2025-06-17 23:19:31 +02:00
Jana Dönszelmann
0aade73c50 implement rustc_force_inline parser 2025-06-17 23:19:31 +02:00
Jonathan Dönszelmann
4f73cd0a6c implement inline parser 2025-06-17 23:19:31 +02:00
Pavel Grigorenko
da8d6bbd50 Port #[rustc_as_ptr] to the new attribute system 2025-06-16 18:13:27 +03: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
Jana Dönszelmann
ce0438684d consistently rename (old) attribute groups 2025-06-11 18:46:57 +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
1525f548bc Fix up some comments.
Some are too long (> 100 chars), some are too short, some are missing
full stops, some are missing upper-case letters at the start of
sentences.
2025-05-20 09:17:49 +10:00
Nicholas Nethercote
5b808b7da8 Simplify Accepts.
There only needs to be one `Fn` per symbol, not multiple.
2025-05-20 09:12:24 +10:00
Nicholas Nethercote
e139d268f0 Introduce some typedefs to improve readability. 2025-05-20 08:31:49 +10:00
Nicholas Nethercote
7fe6bc57f5 Use clone to clone DelimArgs in two places. 2025-04-23 20:10:49 +10:00
Mara Bos
5f4d676e70 Remove #[rustc_macro_edition_2021].
It was only temporarily used by pin!(), which no longer needs it.
2025-04-20 11:15:46 +02:00
Nicholas Nethercote
2fef0a30ae Replace infallible name_or_empty methods with fallible name methods.
I'm removing empty identifiers everywhere, because in practice they
always mean "no identifier" rather than "empty identifier". (An empty
identifier is impossible.) It's better to use `Option` to mean "no
identifier" because you then can't forget about the "no identifier"
possibility.

Some specifics:
- When testing an attribute for a single name, the commit uses the
  `has_name` method.
- When testing an attribute for multiple names, the commit uses the new
  `has_any_name` method.
- When using `match` on an attribute, the match arms now have `Some` on
  them.

In the tests, we now avoid printing empty identifiers by not printing
the identifier in the `error:` line at all, instead letting the carets
point out the problem.
2025-04-17 09:50:52 +10:00
Nicholas Nethercote
4c0cbaeb9e Remove TokenStream::flattened and InvisibleOrigin::FlattenToken.
They are no longer needed.

This does slightly worsen the error message for a single test, but that
test contains code that is so badly broken that I'm not worried about
it.
2025-04-02 16:16:51 +11:00
Jana Dönszelmann
7c085f7ffd add rustc_macro_edition_2021 2025-03-19 17:37:35 +01: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
Jana Dönszelmann
4bf66c57fa fix #137589 2025-02-25 18:17:32 +01:00
Jana Dönszelmann
4daa35ce33 lower attr spans and inline some functions to hopefully mitigate perf regressions 2025-02-24 14:37:58 +01:00
Jana Dönszelmann
7e0f5b5016 Introduce new-style attribute parsers for several attributes
note: compiler compiles but librustdoc and clippy don't
2025-02-24 14:31:17 +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