about summary refs log tree commit diff
path: root/compiler/rustc_attr_parsing/src
AgeCommit message (Collapse)AuthorLines
2025-08-21split up context.rsJana Dönszelmann-329/+359
2025-08-21Introduce a prelude for very common imports across dozens of filesJana Dönszelmann-216/+70
2025-08-21refactor target checking, move out of context.rs and rename MaybeWarn to PolicyJana Dönszelmann-324/+402
2025-08-19Auto merge of #145601 - jieyouxu:rollup-t5mbqhc, r=jieyouxubors-0/+1
Rollup of 10 pull requests Successful merges: - rust-lang/rust#145538 (bufreader::Buffer::backshift: don't move the uninit bytes) - rust-lang/rust#145542 (triagebot: Don't warn no-mentions on subtree updates) - rust-lang/rust#145549 (Update rust maintainers in openharmony.md) - rust-lang/rust#145550 (Avoid using `()` in `derive(From)` output.) - rust-lang/rust#145556 (Allow stability attributes on extern crates) - rust-lang/rust#145560 (Remove unused `PartialOrd`/`Ord` from bootstrap) - rust-lang/rust#145568 (ignore frontmatters in `TokenStream::new`) - rust-lang/rust#145571 (remove myself from some adhoc-groups and pings) - rust-lang/rust#145576 (Add change tracker entry for `--timings`) - rust-lang/rust#145578 (Add VEXos "linked files" support to `armv7a-vex-v5`) r? `@ghost` `@rustbot` modify labels: rollup
2025-08-19Rollup merge of #145556 - JonathanBrouwer:extern-crate-stable, r=jdonszelmann许杰友 Jieyou Xu (Joe)-0/+1
Allow stability attributes on extern crates Fixes https://github.com/rust-lang/rust/issues/145497 r? ``@jdonszelmann``
2025-08-19Rollup merge of #145500 - JonathanBrouwer:must_use_target, r=jdonszelmann许杰友 Jieyou Xu (Joe)-2/+22
Port must_use to the new target checking This PR ports `must_use` to the new target checking logic This also adds a tool-only suggestion to remove attributes on invalid targets, as to not immediately undo the work of https://github.com/rust-lang/rust/pull/145274 r? `@jdonszelmann`
2025-08-19Port `must_use` to the new target checkingJonathan Brouwer-2/+18
2025-08-19Make tool-only suggestion to remove attributes on invalid targetsJonathan Brouwer-0/+4
2025-08-19Rollup merge of #145243 - jdonszelmann:inner-attr-errors, r=petrochenkovStuart Cook-11/+29
take attr style into account in diagnostics when the original attribute was specified as an inner attribute, the suggestion will now match that attribute style
2025-08-18Allow stability attributes on extern cratesJonathan Brouwer-0/+1
2025-08-18Rollup merge of #145485 - JonathanBrouwer:fix-deprecation-targets, ↵Stuart Cook-0/+5
r=jdonszelmann Fix deprecation attributes on foreign statics r? ````````@jdonszelmann```````` Fixes https://github.com/rust-lang/rust/issues/145437
2025-08-16take attr style into account in attr diagnosticsJana Dönszelmann-11/+29
2025-08-16Fix deprecation attribute on foreign statics & typesJonathan Brouwer-0/+2
2025-08-16Don't show foreign types as an allowed target if the feature is not enabledJonathan Brouwer-0/+3
2025-08-15Port `#[custom_mir(..)]` to the new attribute systemSasha Pourcelot-0/+143
2025-08-14Specify the list of allowed targets per attributeJonathan Brouwer-44/+361
2025-08-14Allow attribute parsers to specify a list of allowed targetsJonathan Brouwer-11/+293
Every acceptor gets an `ALLOWED_TARGETS` specification which can specify per target whether it is allowed, warned, or errored.
2025-08-14Pass the target type down to `parse_attribute_list`Jonathan Brouwer-1/+5
2025-08-13Port the `#[linkage]` attribute to the new attribute systemSasha Pourcelot-2/+77
2025-08-12Rollup merge of #145238 - estebank:attr-overhaul, r=jdonszelmannStuart Cook-55/+101
Tweak invalid builtin attribute output - Add link to reference/docs when possible - More accurate suggestions by supporting multiple alternative suggestions ``` error: malformed `crate_type` attribute input --> $DIR/crate-type-macro-call.rs:1:1 | LL | #![crate_type = foo!()] | ^^^^^^^^^^^^^^^^^^^^^^^ | = note: for more information, visit <https://doc.rust-lang.org/reference/linkage.html> help: the following are the possible correct uses | LL - #![crate_type = foo!()] LL + #![crate_type = "bin"] | LL - #![crate_type = foo!()] LL + #![crate_type = "cdylib"] | LL - #![crate_type = foo!()] LL + #![crate_type = "dylib"] | LL - #![crate_type = foo!()] LL + #![crate_type = "lib"] | = and 4 other candidates ```
2025-08-11Rework `NameValueStr`Esteban Küber-1/+1
2025-08-11Add more docs to templates for attrs with incorrect argumentsEsteban Küber-14/+52
2025-08-11Add link to invalid `repr` errorEsteban Küber-0/+1
2025-08-11Allow attr entries to declare list of alternatives for `List` and ↵Esteban Küber-47/+54
`NamedValueStr` Modify `AttributeTemplate` to support list of alternatives for list and name value attribute styles. Suggestions now provide more correct suggested code: ``` error[E0805]: malformed `used` attribute input --> $DIR/used_with_multi_args.rs:3:1 | LL | #[used(compiler, linker)] | ^^^^^^------------------^ | | | expected a single argument here | help: try changing it to one of the following valid forms of the attribute | LL - #[used(compiler, linker)] LL + #[used(compiler)] | LL - #[used(compiler, linker)] LL + #[used(linker)] | LL - #[used(compiler, linker)] LL + #[used] | ``` instead of the prior "masking" of the lack of this feature by suggesting pipe-separated lists: ``` error[E0805]: malformed `used` attribute input --> $DIR/used_with_multi_args.rs:3:1 | LL | #[used(compiler, linker)] | ^^^^^^------------------^ | | | expected a single argument here | help: try changing it to one of the following valid forms of the attribute | LL - #[used(compiler, linker)] LL + #[used(compiler|linker)] | LL - #[used(compiler, linker)] LL + #[used] | ```
2025-08-11Port `#[allow_internal_unsafe]` to the new attribute system (attempt 2)Sasha Pourcelot-1/+12
2025-08-08Revert "Port `#[allow_internal_unsafe]` to the new attribute system"Jana Dönszelmann-12/+1
This reverts commit 4f7a6ace9e2f2192af7b5d32f4b1664189e0e143.
2025-08-07Rollup merge of #144857 - scrabsha:push-pwtyrnmqkrtr, r=jdonszelmannTrevor Gross-1/+12
Port `#[allow_internal_unsafe]` to the new attribute system Related to https://github.com/rust-lang/rust/issues/131229#issue-2565886367. r? ````@jdonszelmann````
2025-08-07Port `#[allow_internal_unsafe]` to the new attribute systemSasha Pourcelot-1/+12
2025-08-07Rollup merge of #143808 - JonathanBrouwer:should_panic_parser, r=jdonszelmannStuart Cook-1/+54
Port `#[should_panic]` to the new attribute parsing infrastructure Ports `#[should_panic]` to the new attribute parsing infrastructure for https://github.com/rust-lang/rust/issues/131229#issuecomment-2971351163 r? ```@jdonszelmann```
2025-08-06Port `#[should_panic]` to the new attribute parsing infrastructureJonathan Brouwer-1/+54
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-08-06Rollup merge of #144794 - scrabsha:push-noqrrttovmwy, r=jdonszelmannGuillaume Gomez-0/+18
Port `#[coroutine]` to the new attribute system Related to https://github.com/rust-lang/rust/issues/131229#issue-2565886367. r? `````@jdonszelmann`````
2025-08-05Rollup merge of #144866 - JonathanBrouwer:should_emit_fix, r=jdonszelmannSamuel Tardieu-4/+11
Remove `SHOULD_EMIT_LINTS` in favor of `should_emit` r? ``@jdonszelmann``
2025-08-04Port `#[coroutine]` to the new attribute systemSasha Pourcelot-0/+18
Related to https://github.com/rust-lang/rust/issues/131229#issue-2565886367.
2025-08-03Rollup merge of #144738 - bjorn3:remove_omit_gdb_pretty_printer_section, ↵Samuel Tardieu-12/+2
r=jieyouxu Remove the omit_gdb_pretty_printer_section attribute Disabling loading of pretty printers in the debugger itself is more reliable. Before this commit the .gdb_debug_scripts section couldn't be included in dylibs or rlibs as otherwise there is no way to disable the section anymore without recompiling the entire standard library.
2025-08-03Remove `SHOULD_EMIT_LINTS` in favor of `should_emit`Jonathan Brouwer-4/+11
2025-08-01Remove the omit_gdb_pretty_printer_section attributebjorn3-12/+2
Disabling loading of pretty printers in the debugger itself is more reliable. Before this commit the .gdb_debug_scripts section couldn't be included in dylibs or rlibs as otherwise there is no way to disable the section anymore without recompiling the entire standard library.
2025-08-01Cleanup the definition of `group_type`Jonathan Brouwer-25/+36
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-07-31remove rustc_attr_data_structuresJana Dönszelmann-40/+42
2025-07-29coverage: Rename `CoverageStatus` to `CoverageAttrKind`Zalathar-5/+5
This patch also prepares the affected code in `coverage_attr_on` for some subsequent changes.
2025-07-26Use the new attributes throughout the codebaseJonathan Brouwer-4/+4
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-07-26Parsers for the attributesJonathan Brouwer-0/+147
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-07-24Rollup merge of #144358 - JonathanBrouwer:fix-stability-malformed, r=oli-obkLeón Orell Valerian Liehr-4/+22
Stop using the old `validate_attr` logic for stability attributes I think this was accidentally missed when implementing the stability attributes? r? `````@oli-obk````` cc `````@jdonszelmann`````
2025-07-23Stop using the old `validate_attr` logic for stability attributesJonathan Brouwer-4/+22
2025-07-23Ports `#[macro_use]` and `#[macro_escape]` to the new attribute parsing ↵Jonathan Brouwer-4/+138
infrastructure
2025-07-22Rollup merge of #144080 - jieyouxu:realign, r=BoxyUwU许杰友 Jieyou Xu (Joe)-2/+3
Mitigate `#[align]` name resolution ambiguity regression with a rename Mitigates beta regression rust-lang/rust#143834 after a beta backport. ### Background on the beta regression The name resolution regression arises due to rust-lang/rust#142507 adding a new feature-gated built-in attribute named `#[align]`. However, unfortunately even [introducing new feature-gated unstable built-in attributes can break user code](https://www.github.com/rust-lang/rust/issues/134963) such as ```rs macro_rules! align { () => { /* .. */ }; } pub(crate) use align; // `use` here becomes ambiguous ``` ### Mitigation approach This PR renames `#[align]` to `#[rustc_align]` to mitigate the beta regression by: 1. Undoing the introduction of a new built-in attribute with a common name, i.e. `#[align]`. 2. Renaming `#[align]` to `#[rustc_align]`. The renamed attribute being `rustc_align` will not introduce new stable breakages, as attributes beginning with `rustc` are reserved and perma-unstable. This does mean existing nightly code using `fn_align` feature will additionally need to specify `#![feature(rustc_attrs)]`. This PR is very much a short-term mitigation to alleviate time pressure from having to fully fix the current limitation of inevitable name resolution regressions that would arise from adding any built-in attributes. Long-term solutions are discussed in [#t-lang > namespacing macro attrs to reduce conflicts with new adds](https://rust-lang.zulipchat.com/#narrow/channel/213817-t-lang/topic/namespacing.20macro.20attrs.20to.20reduce.20conflicts.20with.20new.20adds/with/529249622). ### Alternative mitigation options [Various mitigation options were considered during the compiler triage meeting](https://github.com/rust-lang/rust/issues/143834#issuecomment-3084415277), and those consideration are partly reproduced here: - Reverting the PR doesn't seem very minimal/trivial, and carries risks of its own. - Rename to a less-common but aim-to-stabilization name is itself not safe nor convenient, because (1) that risks introducing new regressions (i.e. ambiguity against the new name), and (2) lang would have to FCP the new name hastily for the mitigation to land timely and have a chance to be backported. This also makes the path towards stabilization annoying. - Rename the attribute to a rustc attribute, which will be perma-unstable and does not cause new ambiguities in stable code. - This alleviates the time pressure to address *this* regression, or for lang to have to rush an FCP for some new name that can still break user code. - This avoids backing out a whole implementation. ### Review advice This PR is best reviewed commit-by-commit. - Commit 1 adds a test `tests/ui/attributes/fn-align-nameres-ambiguity-143834.rs` which demonstrates the current name resolution regression re. `align`. This test fails against current master. - Commit 2 carries out the renames and test reblesses. Notably, commit 2 will cause `tests/ui/attributes/fn-align-nameres-ambiguity-143834.rs` to change from fail (nameres regression) to pass. This PR, if the approach still seems acceptable, will need a beta-backport to address the beta regression.
2025-07-19Mitigate `#[align]` name resolution ambiguity regression with a renameJieyou Xu-2/+3
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.
2025-07-18Auto merge of #143845 - cjgillot:stability-query, r=jieyouxubors-4/+4
Split-up stability_index query This PR aims to move deprecation and stability processing away from the monolithic `stability_index` query, and directly implement `lookup_{deprecation,stability,body_stability,const_stability}` queries. The basic idea is to: - move per-attribute sanity checks into `check_attr.rs`; - move attribute compatibility checks into the `MissingStabilityAnnotations` visitor; - progressively dismantle the `Annotator` visitor and the `stability_index` query. The first commit contains functional change, and now warns when `#[automatically_derived]` is applied on a non-trait impl block. The other commits should not change visible behaviour. Perf in https://github.com/rust-lang/rust/pull/143845#issuecomment-3066308630 shows small but consistent improvement, except for unused-warnings case. That case being a stress test, I'm leaning towards accepting the regression. This PR changes `check_attr`, so has a high conflict rate on that file. This should not cause issues for review.
2025-07-18Rollup merge of #143891 - scrabsha:push-xxtttopqoprr, r=jdonszelmannMatthias Krüger-6/+110
Port `#[coverage]` to the new attribute system r? ``````@jdonszelmann``````
2025-07-17Include ErrorGuaranteed in StableSince::Err.Camille GILLOT-4/+4
2025-07-17Auto merge of #143879 - fee1-dead-contrib:push-lrlpoouyqqry, r=fmeasebors-0/+1
parse `const trait Trait` r? oli-obk or anyone from project-const-traits cc `@rust-lang/project-const-traits`