summary refs log tree commit diff
path: root/compiler/rustc_attr_parsing/src/attributes
AgeCommit message (Collapse)AuthorLines
2025-07-24Mitigate `#[align]` name resolution ambiguity regression with a renameJieyou Xu-1/+1
From `#[align]` -> `#[rustc_align]`. Attributes starting with `rustc` are always perma-unstable and feature-gated by `feature(rustc_attrs)`. See regression RUST-143834. For the underlying problem where even introducing new feature-gated unstable built-in attributes can break user code such as ```rs macro_rules! align { () => { /* .. */ }; } pub(crate) use align; // `use` here becomes ambiguous ``` refer to RUST-134963. Since the `#[align]` attribute is still feature-gated by `feature(fn_align)`, we can rename it as a mitigation. Note that `#[rustc_align]` will obviously mean that current unstable user code using `feature(fn_aling)` will need additionally `feature(rustc_attrs)`, but this is a short-term mitigation to buy time, and is expected to be changed to a better name with less collision potential. See <https://rust-lang.zulipchat.com/#narrow/channel/238009-t-compiler.2Fmeetings/topic/.5Bweekly.5D.202025-07-17/near/529290371> where mitigation options were considered. (cherry picked from commit 69b71e44107b4905ec7ad84ccb3edf4f14b3df69)
2025-06-22Port `#[no_mangle]` to new attribute parsing infrastructureJonathan Brouwer-0/+18
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-06-22Port `#[must_use]` to new attribute parsing infrastructureJonathan Brouwer-0/+41
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-06-21Port `#[rustc_pub_transparent]` to the new attribute systemPavel Grigorenko-0/+13
2025-06-21Rollup merge of #142539 - GrigorenkoPV:attributes/may_dangle, r=jdonszelmannJana Dönszelmann-0/+20
Port `#[may_dangle]` to the new attribute system Very similar to rust-lang/rust#142498. This is a part of rust-lang/rust#131229, so r? `@jdonszelmann`
2025-06-20Auto merge of #142794 - tgross35:rollup-iae7okj, r=tgross35bors-1/+39
Rollup of 9 pull requests Successful merges: - rust-lang/rust#142331 (Add `trim_prefix` and `trim_suffix` methods for both `slice` and `str` types.) - rust-lang/rust#142491 (Rework #[cold] attribute parser) - rust-lang/rust#142494 (Fix missing docs in `rustc_attr_parsing`) - rust-lang/rust#142495 (Better template for `#[repr]` attributes) - rust-lang/rust#142497 (Fix random failure when JS code is executed when the whole file was not read yet) - rust-lang/rust#142575 (Ensure copy* intrinsics also perform the static self-init checks) - rust-lang/rust#142650 (Refactor Translator) - rust-lang/rust#142713 (mbe: Refactor transcription) - rust-lang/rust#142755 (rustdoc: Remove `FormatRenderer::cache`) r? `@ghost` `@rustbot` modify labels: rollup
2025-06-20Port `#[may_dangle]` to the new attribute systemPavel Grigorenko-0/+20
2025-06-20Rollup merge of #142715 - folkertdev:fn-align-corrections, r=jdonszelmannJakub Beránek-1/+1
correct template for `#[align]` attribute Tracking issue: https://github.com/rust-lang/rust/issues/82232 related: https://github.com/rust-lang/rust/pull/142507 I didn't fully understand what `template!` did, clearly. An empty `#[align]` attribute was still rejected later, but without this change it does get suggested in certain cases. I've also updated some outdated references to `#[repr(align)]` on functions. r? ``@jdonszelmann``
2025-06-20Rollup merge of #142495 - jdonszelmann:better-repr-template, r=oli-obkTrevor Gross-1/+2
Better template for `#[repr]` attributes
2025-06-20Rollup merge of #142494 - jdonszelmann:missing-attr-parsing-docs, r=oli-obkTrevor Gross-0/+19
Fix missing docs in `rustc_attr_parsing`
2025-06-20expected word diagnostic testJana Dönszelmann-1/+1
2025-06-20coldJana Dönszelmann-0/+18
2025-06-20Rollup merge of #138291 - jdonszelmann:optimize-attr, r=oli-obkTrevor Gross-0/+41
rewrite `optimize` attribute to use new attribute parsing infrastructure r? ```@oli-obk``` I'm afraid we'll get quite a few of these PRs in the future. If we get a lot of trivial changes I'll start merging multiple into one PR. They should be easy to review :) Waiting on #138165 first
2025-06-19correct template for `#[align]`Folkert de Vries-1/+1
it should not suggest just `#[align]`
2025-06-18fixup missing docs in attr parsingJana Dönszelmann-0/+19
2025-06-18better template for repr attributesJana Dönszelmann-1/+2
2025-06-18convert the `optimize` attribute to a new parserJana Dönszelmann-0/+41
2025-06-18add `#[align]` attributeFolkert de Vries-2/+56
Right now it's used for functions with `fn_align`, in the future it will get more uses (statics, struct fields, etc.)
2025-06-17make error codes reflect reality betterJana Dönszelmann-60/+59
2025-06-17use consistent attr errors in all attribute parsersJana Dönszelmann-39/+42
2025-06-17fix bugs in inline/force_inline and diagnostics of all attr parsersJana Dönszelmann-63/+113
2025-06-17implement rustc_force_inline parserJana Dönszelmann-0/+1
2025-06-17implement inline parserJonathan Dönszelmann-1/+2
2025-06-16Port `#[rustc_as_ptr]` to the new attribute systemPavel Grigorenko-0/+22
2025-06-13Rollup merge of #142158 - xizheyin:141617, r=jdonszelmannMatthias Krüger-1/+4
Tracking the old name of renamed unstable library features This PR resolves the first problem of rust-lang/rust#141617 : tracking renamed unstable features. The first commit is to add a ui test, and the second one tracks the changes. I will comment on the code for clarification. r? `@jdonszelmann` There have been a lot of PR's reviewed by you lately, thanks for your time! cc `@jyn514`
2025-06-12Tracking the old name of renamed unstable library attributexizheyin-1/+4
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-06-12remove 'static in some placesJana Dönszelmann-11/+11
2025-06-12introduce new lint infraJana Dönszelmann-127/+245
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-12Start using new diagnostic logic on all existing `single` parsersJonathan Dönszelmann-43/+14
2025-06-12introduce duplicate attribute diagnostic logicJana Dönszelmann-17/+112
2025-06-11consistently rename (old) attribute groupsJana Dönszelmann-1/+1
2025-06-11document attribute parsers betterJana Dönszelmann-0/+9
2025-06-06Rollup merge of #142058 - xizheyin:rustc-attr-parsing, r=jdonszelmannMatthias Krüger-1/+1
Clean `rustc_attr_parsing/src/lib.rs` documentation Improves the documentation clarity in `rustc_attr_parsing` by restructuring content with clearer section headers, simplifying explanations of attribute types, making technical descriptions more precise. r? ``@oli-obk``
2025-06-05Clean `rustc_attr_parsing` documentationxizheyin-1/+1
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-06-04Rollup merge of #141271 - nnethercote:attr-streamline, r=jdonszelmannMatthias Krüger-9/+9
Streamline some attr parsing APIs r? ``@jdonszelmann``
2025-05-26Add custom trait for emitting lint within `cfg_matches`Urgau-6/+21
2025-05-26Rollup merge of #140539 - nnethercote:simplify-attribute_groups, r=jdonszelmannJacob Pratt-15/+15
Simplify `attribute_groups` It's more complicated than it needs to be. r? ``@jdonszelmann``
2025-05-24Make #[cfg(version)] respect RUSTC_OVERRIDE_VERSION_STRINGest31-2/+2
2025-05-21Rename `MetaItemParser::path_without_args` as `MetaItemParser::path`.Nicholas Nethercote-9/+9
And avoid the clone.
2025-05-21collect doc alias as tips during resolutionbohan-0/+30
2025-05-20Avoid `rustc_span::` qualifiers.Nicholas Nethercote-15/+15
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-07Avoid some unwraps.Nicholas Nethercote-18/+27
By using `@` patterns more. Also, use `Symbol` more in a couple of errors to avoid some unnecessary conversions to strings. This even removes a lifetime.
2025-05-07Eliminate `word_or_empty` methods.Nicholas Nethercote-48/+53
To get rid of the `Ident::empty` uses. This requires introducing `PathParser::word_sym`, as an alternative to `PathParser::word`.
2025-04-20Remove #[rustc_macro_edition_2021].Mara Bos-20/+0
It was only temporarily used by pin!(), which no longer needs it.
2025-04-18Rollup merge of #139615 - nnethercote:rm-name_or_empty, r=jdonszelmannMatthias Krüger-6/+6
Remove `name_or_empty` Another step towards #137978. r? ``@jdonszelmann``
2025-04-17Auto merge of #139949 - matthiaskrgr:rollup-pxc5tsx, r=matthiaskrgrbors-15/+0
Rollup of 8 pull requests Successful merges: - #138632 (Stabilize `cfg_boolean_literals`) - #139416 (unstable book; document `macro_metavar_expr_concat`) - #139782 (Consistent with treating Ctor Call as Struct in liveness analysis) - #139885 (document RUSTC_BOOTSTRAP, RUSTC_OVERRIDE_VERSION_STRING, and -Z allow-features in the unstable book) - #139904 (Explicitly annotate edition for `unpretty=expanded` and `unpretty=hir` tests) - #139932 (transmutability: Refactor tests for simplicity) - #139944 (Move eager translation to a method on Diag) - #139948 (git: ignore `60600a6fa403216bfd66e04f948b1822f6450af7` for blame purposes) r? `@ghost` `@rustbot` modify labels: rollup
2025-04-17Replace infallible `name_or_empty` methods with fallible `name` methods.Nicholas Nethercote-6/+6
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-03Stabilize `cfg_boolean_literals`clubby789-15/+0
2025-03-31hygiene: Rename semi-transparent to semi-opaqueVadim Petrochenkov-1/+1
The former is just too long, see the examples in `hygiene.rs`
2025-03-25Avoid `kw::Empty` when dealing with `rustc_allowed_through_unstable_modules`.Nicholas Nethercote-6/+2
The existing code produces `Some(kw::Empty)` for these invalid forms: - a non-name-value, e.g. `#[rustc_allowed_through_unstable_modules]` - a non-string arg, e.g. `#[rustc_allowed_through_unstable_modules = 3]` The new code avoids the `kw::Empty` and is a little shorter. It will produce `None` in those cases, which means E0789 won't be produced if the `stable` attribute is missing for these invalid forms. This doesn't matter, because these invalid forms will trigger an "malformed `rustc_allowed_through_unstable_modules` attribute" anyway.