about summary refs log tree commit diff
path: root/compiler/rustc_attr_parsing/src/attributes/repr.rs
AgeCommit message (Collapse)AuthorLines
2025-09-09allow `#[rustc_align_static(N)]` on `static`sFolkert de Vries-0/+27
We need a different attribute than `rustc_align` because unstable attributes are tied to their feature (we can't have two unstable features use the same unstable attribute). Otherwise this uses all of the same infrastructure as `#[rustc_align]`.
2025-08-21Introduce a prelude for very common imports across dozens of filesJana Dönszelmann-12/+5
2025-08-21refactor target checking, move out of context.rs and rename MaybeWarn to PolicyJana Dönszelmann-2/+3
2025-08-14Specify the list of allowed targets per attributeJonathan Brouwer-2/+15
2025-08-11Add more docs to templates for attrs with incorrect argumentsEsteban Küber-1/+4
2025-08-11Allow attr entries to declare list of alternatives for `List` and ↵Esteban Küber-3/+2
`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-07-31remove rustc_attr_data_structuresJana Dönszelmann-1/+1
2025-07-19Mitigate `#[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.
2025-07-06Rewrite empty attribute lintJonathan Brouwer-3/+4
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-07-03Port `#[target_feature]` to the new attribute parsing infrastructureJonathan Brouwer-1/+1
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-06-20Auto merge of #142794 - tgross35:rollup-iae7okj, r=tgross35bors-1/+2
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-20Rollup merge of #142495 - jdonszelmann:better-repr-template, r=oli-obkTrevor Gross-1/+2
Better template for `#[repr]` attributes
2025-06-19correct template for `#[align]`Folkert de Vries-1/+1
it should not suggest just `#[align]`
2025-06-18better template for repr attributesJana Dönszelmann-1/+2
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-0/+1
2025-06-17fix bugs in inline/force_inline and diagnostics of all attr parsersJana Dönszelmann-0/+3
2025-06-12remove 'static in some placesJana Dönszelmann-1/+1
2025-06-12introduce new lint infraJana Dönszelmann-9/+12
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-04Rollup merge of #141271 - nnethercote:attr-streamline, r=jdonszelmannMatthias Krüger-1/+1
Streamline some attr parsing APIs r? ``@jdonszelmann``
2025-05-21Rename `MetaItemParser::path_without_args` as `MetaItemParser::path`.Nicholas Nethercote-1/+1
And avoid the clone.
2025-05-20Avoid `rustc_span::` qualifiers.Nicholas Nethercote-3/+3
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-20/+28
To get rid of the `Ident::empty` uses. This requires introducing `PathParser::word_sym`, as an alternative to `PathParser::word`.
2025-02-24Introduce new-style attribute parsers for several attributesJana Dönszelmann-176/+205
note: compiler compiles but librustdoc and clippy don't
2025-01-19Run `clippy --fix` for `unnecessary_map_or` lintYotam Ofek-1/+1
2024-12-18Re-export more `rustc_span::symbol` things from `rustc_span`.Nicholas Nethercote-1/+1
`rustc_span::symbol` defines some things that are re-exported from `rustc_span`, such as `Symbol` and `sym`. But it doesn't re-export some closely related things such as `Ident` and `kw`. So you can do `use rustc_span::{Symbol, sym}` but you have to do `use rustc_span::symbol::{Ident, kw}`, which is inconsistent for no good reason. This commit re-exports `Ident`, `kw`, and `MacroRulesNormalizedIdent`, and changes many `rustc_span::symbol::` qualifiers in `compiler/` to `rustc_span::`. This is a 200+ net line of code reduction, mostly because many files with two `use rustc_span` items can be reduced to one.
2024-12-16rename rustc_attr to rustc_attr_parsing and create rustc_attr_data_structuresJonathan Dönszelmann-0/+215