Mitigate #[align] name resolution ambiguity regression with a rename - #144080
Conversation
|
r? @SparrowLii rustbot has assigned @SparrowLii. Use |
|
Some changes occurred in compiler/rustc_attr_data_structures Some changes occurred in compiler/rustc_attr_parsing Some changes occurred in compiler/rustc_passes/src/check_attr.rs The Miri subtree was changed cc @rust-lang/miri |
|
We reserve |
That would require I could give that a try when I wake up. |
For the tests that utilize the feature, yes, but presumably nobody should be using this feature anyways with this placeholder name. There's no special resolver behavior for |
|
Yeah good point. I'll make that change. |
|
btw this feature is actually used in the wild, and has worked reliably for years. We're allowed to break nightly features of course, but yeah, the |
This comment was marked as resolved.
This comment was marked as resolved.
…sion See RUST-143834.
|
Changes since last review:
|
This comment was marked as resolved.
This comment was marked as resolved.
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.
|
@rustbot ready |
Rollup of 14 pull requests Successful merges: - rust-lang/rust#142097 (gpu offload host code generation) - rust-lang/rust#143430 (Lower extra lifetimes before normal generic params.) - rust-lang/rust#143768 (Constify Try, From, TryFrom and relevant traits) - rust-lang/rust#143816 (Implement `check` for compiletest and RA using tool macro) - rust-lang/rust#143985 (rustc_public: de-StableMIR-ize) - rust-lang/rust#144027 (clippy: make tests work in stage 1) - rust-lang/rust#144080 (Mitigate `#[align]` name resolution ambiguity regression with a rename) - rust-lang/rust#144176 (Add approval blocking labels for new bors) - rust-lang/rust#144187 (fix handling of base address for TypeId allocations) - rust-lang/rust#144212 (Remove the ptr_unique lang item) - rust-lang/rust#144243 (Subtree update of `rust-analyzer`) - rust-lang/rust#144246 (Don't use another main test file as auxiliary) - rust-lang/rust#144251 (rustc-dev-guide subtree update) - rust-lang/rust#144254 (opt-dist: make `artifact-dir` an absolute path for `opt-dist local`) r? `@ghost` `@rustbot` modify labels: rollup
Rollup of 14 pull requests Successful merges: - rust-lang/rust#142097 (gpu offload host code generation) - rust-lang/rust#143430 (Lower extra lifetimes before normal generic params.) - rust-lang/rust#143768 (Constify Try, From, TryFrom and relevant traits) - rust-lang/rust#143816 (Implement `check` for compiletest and RA using tool macro) - rust-lang/rust#143985 (rustc_public: de-StableMIR-ize) - rust-lang/rust#144027 (clippy: make tests work in stage 1) - rust-lang/rust#144080 (Mitigate `#[align]` name resolution ambiguity regression with a rename) - rust-lang/rust#144176 (Add approval blocking labels for new bors) - rust-lang/rust#144187 (fix handling of base address for TypeId allocations) - rust-lang/rust#144212 (Remove the ptr_unique lang item) - rust-lang/rust#144243 (Subtree update of `rust-analyzer`) - rust-lang/rust#144246 (Don't use another main test file as auxiliary) - rust-lang/rust#144251 (rustc-dev-guide subtree update) - rust-lang/rust#144254 (opt-dist: make `artifact-dir` an absolute path for `opt-dist local`) r? `@ghost` `@rustbot` modify labels: rollup
Rollup of 14 pull requests Successful merges: - rust-lang/rust#142097 (gpu offload host code generation) - rust-lang/rust#143430 (Lower extra lifetimes before normal generic params.) - rust-lang/rust#143768 (Constify Try, From, TryFrom and relevant traits) - rust-lang/rust#143816 (Implement `check` for compiletest and RA using tool macro) - rust-lang/rust#143985 (rustc_public: de-StableMIR-ize) - rust-lang/rust#144027 (clippy: make tests work in stage 1) - rust-lang/rust#144080 (Mitigate `#[align]` name resolution ambiguity regression with a rename) - rust-lang/rust#144176 (Add approval blocking labels for new bors) - rust-lang/rust#144187 (fix handling of base address for TypeId allocations) - rust-lang/rust#144212 (Remove the ptr_unique lang item) - rust-lang/rust#144243 (Subtree update of `rust-analyzer`) - rust-lang/rust#144246 (Don't use another main test file as auxiliary) - rust-lang/rust#144251 (rustc-dev-guide subtree update) - rust-lang/rust#144254 (opt-dist: make `artifact-dir` an absolute path for `opt-dist local`) r? `@ghost` `@rustbot` modify labels: rollup
Rollup of 14 pull requests Successful merges: - rust-lang/rust#142097 (gpu offload host code generation) - rust-lang/rust#143430 (Lower extra lifetimes before normal generic params.) - rust-lang/rust#143768 (Constify Try, From, TryFrom and relevant traits) - rust-lang/rust#143816 (Implement `check` for compiletest and RA using tool macro) - rust-lang/rust#143985 (rustc_public: de-StableMIR-ize) - rust-lang/rust#144027 (clippy: make tests work in stage 1) - rust-lang/rust#144080 (Mitigate `#[align]` name resolution ambiguity regression with a rename) - rust-lang/rust#144176 (Add approval blocking labels for new bors) - rust-lang/rust#144187 (fix handling of base address for TypeId allocations) - rust-lang/rust#144212 (Remove the ptr_unique lang item) - rust-lang/rust#144243 (Subtree update of `rust-analyzer`) - rust-lang/rust#144246 (Don't use another main test file as auxiliary) - rust-lang/rust#144251 (rustc-dev-guide subtree update) - rust-lang/rust#144254 (opt-dist: make `artifact-dir` an absolute path for `opt-dist local`) r? `@ghost` `@rustbot` modify labels: rollup
Mitigate `#[align]` name resolution ambiguity regression with a rename Mitigates beta regression rust-lang#143834 after a beta backport. ### Background on the beta regression The name resolution regression arises due to rust-lang#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](rust-lang#143834 (comment)), 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.
Rollup of 14 pull requests Successful merges: - rust-lang#142097 (gpu offload host code generation) - rust-lang#143430 (Lower extra lifetimes before normal generic params.) - rust-lang#143768 (Constify Try, From, TryFrom and relevant traits) - rust-lang#143816 (Implement `check` for compiletest and RA using tool macro) - rust-lang#143985 (rustc_public: de-StableMIR-ize) - rust-lang#144027 (clippy: make tests work in stage 1) - rust-lang#144080 (Mitigate `#[align]` name resolution ambiguity regression with a rename) - rust-lang#144176 (Add approval blocking labels for new bors) - rust-lang#144187 (fix handling of base address for TypeId allocations) - rust-lang#144212 (Remove the ptr_unique lang item) - rust-lang#144243 (Subtree update of `rust-analyzer`) - rust-lang#144246 (Don't use another main test file as auxiliary) - rust-lang#144251 (rustc-dev-guide subtree update) - rust-lang#144254 (opt-dist: make `artifact-dir` an absolute path for `opt-dist local`) r? `@ghost` `@rustbot` modify labels: rollup
Mitigate `#[align]` name resolution ambiguity regression with a rename Mitigates beta regression rust-lang#143834 after a beta backport. ### Background on the beta regression The name resolution regression arises due to rust-lang#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](rust-lang#143834 (comment)), 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.
Rollup of 14 pull requests Successful merges: - rust-lang#142097 (gpu offload host code generation) - rust-lang#143430 (Lower extra lifetimes before normal generic params.) - rust-lang#143768 (Constify Try, From, TryFrom and relevant traits) - rust-lang#143816 (Implement `check` for compiletest and RA using tool macro) - rust-lang#143985 (rustc_public: de-StableMIR-ize) - rust-lang#144027 (clippy: make tests work in stage 1) - rust-lang#144080 (Mitigate `#[align]` name resolution ambiguity regression with a rename) - rust-lang#144176 (Add approval blocking labels for new bors) - rust-lang#144187 (fix handling of base address for TypeId allocations) - rust-lang#144212 (Remove the ptr_unique lang item) - rust-lang#144243 (Subtree update of `rust-analyzer`) - rust-lang#144246 (Don't use another main test file as auxiliary) - rust-lang#144251 (rustc-dev-guide subtree update) - rust-lang#144254 (opt-dist: make `artifact-dir` an absolute path for `opt-dist local`) r? `@ghost` `@rustbot` modify labels: rollup
Rollup of 14 pull requests Successful merges: - rust-lang/rust#142097 (gpu offload host code generation) - rust-lang/rust#143430 (Lower extra lifetimes before normal generic params.) - rust-lang/rust#143768 (Constify Try, From, TryFrom and relevant traits) - rust-lang/rust#143816 (Implement `check` for compiletest and RA using tool macro) - rust-lang/rust#143985 (rustc_public: de-StableMIR-ize) - rust-lang/rust#144027 (clippy: make tests work in stage 1) - rust-lang/rust#144080 (Mitigate `#[align]` name resolution ambiguity regression with a rename) - rust-lang/rust#144176 (Add approval blocking labels for new bors) - rust-lang/rust#144187 (fix handling of base address for TypeId allocations) - rust-lang/rust#144212 (Remove the ptr_unique lang item) - rust-lang/rust#144243 (Subtree update of `rust-analyzer`) - rust-lang/rust#144246 (Don't use another main test file as auxiliary) - rust-lang/rust#144251 (rustc-dev-guide subtree update) - rust-lang/rust#144254 (opt-dist: make `artifact-dir` an absolute path for `opt-dist local`) r? `@ghost` `@rustbot` modify labels: rollup
Rollup of 14 pull requests Successful merges: - rust-lang/rust#142097 (gpu offload host code generation) - rust-lang/rust#143430 (Lower extra lifetimes before normal generic params.) - rust-lang/rust#143768 (Constify Try, From, TryFrom and relevant traits) - rust-lang/rust#143816 (Implement `check` for compiletest and RA using tool macro) - rust-lang/rust#143985 (rustc_public: de-StableMIR-ize) - rust-lang/rust#144027 (clippy: make tests work in stage 1) - rust-lang/rust#144080 (Mitigate `#[align]` name resolution ambiguity regression with a rename) - rust-lang/rust#144176 (Add approval blocking labels for new bors) - rust-lang/rust#144187 (fix handling of base address for TypeId allocations) - rust-lang/rust#144212 (Remove the ptr_unique lang item) - rust-lang/rust#144243 (Subtree update of `rust-analyzer`) - rust-lang/rust#144246 (Don't use another main test file as auxiliary) - rust-lang/rust#144251 (rustc-dev-guide subtree update) - rust-lang/rust#144254 (opt-dist: make `artifact-dir` an absolute path for `opt-dist local`) r? `@ghost` `@rustbot` modify labels: rollup
Rename `#[unroll]` => `#[rustc_unroll]` to mitigate nameres ambiguity ## Summary Mitigate rust-lang#159429 by renaming `#[unroll]` => `#[rustc_unroll]`. Did not bother with a regression test, because a regression test would be hedging against an unknown attribute if `#[unroll]` later proceeds to get a different name. Tracking issue for `#![feature(loop_hints)]`: rust-lang#156874. ## Rationale Even while the crater-observed fallout seems to be relatively small, we'd like such nameres ambiguity breakages to be *deliberate* (read: T-lang FCP'd) rather than accidental (discovered through beta crater runs). See discussions around [last week's compiler triage meeting](https://rust-lang.zulipchat.com/#narrow/channel/238009-t-compiler.2Fmeetings/topic/.5Bweekly.5D.202026-07-23/near/612371735). ## Background context The recurring problem is that built-in attributes are treated differently compared to ordinary prelude attributes, built-in attributes, even while unstable, can name-collide with stable macro re-exports of the same name (and proc-macro helper attributes of the same name), which can break stable code. See rust-lang#134964. See also: - rust-lang#133708 - rust-lang#53913 (comment) - https://rust-lang.zulipchat.com/#narrow/channel/213817-t-lang/topic/Name.20Res.3A.20questions.20on.20intended.20behavior/near/562001319 - rust-lang#143834 (comment) ## Prior Art - For `#[align]`, breakage was more wide-spread, so we posted this same mitigation here: rust-lang#144080. - For `#[sanitize]`, T-lang explicitly FCP'd the breakage stemming from renaming `#[no_sanitize]` (old name) to `#[sanitize]` (new name) that regressed a couple of crates: rust-lang#142681 (comment). ## Alternatives to this PR Generally: - We let it slide. - T-lang FCP on `#[unroll]` breakage (in which case this PR should be closed). - FCP another name (and associated breakages). - (Hard) Fix the built-in attribute name resolution behavior. I have no particular preference on the approaches myself, any of this PR and the alternatives seem fine so as long as the breakage is *deliberate* not accidental.
Rename `#[unroll]` => `#[rustc_unroll]` to mitigate nameres ambiguity ## Summary Mitigate rust-lang#159429 by renaming `#[unroll]` => `#[rustc_unroll]`. Did not bother with a regression test, because a regression test would be hedging against an unknown attribute if `#[unroll]` later proceeds to get a different name. Tracking issue for `#![feature(loop_hints)]`: rust-lang#156874. ## Rationale Even while the crater-observed fallout seems to be relatively small, we'd like such nameres ambiguity breakages to be *deliberate* (read: T-lang FCP'd) rather than accidental (discovered through beta crater runs). See discussions around [last week's compiler triage meeting](https://rust-lang.zulipchat.com/#narrow/channel/238009-t-compiler.2Fmeetings/topic/.5Bweekly.5D.202026-07-23/near/612371735). ## Background context The recurring problem is that built-in attributes are treated differently compared to ordinary prelude attributes, built-in attributes, even while unstable, can name-collide with stable macro re-exports of the same name (and proc-macro helper attributes of the same name), which can break stable code. See rust-lang#134964. See also: - rust-lang#133708 - rust-lang#53913 (comment) - https://rust-lang.zulipchat.com/#narrow/channel/213817-t-lang/topic/Name.20Res.3A.20questions.20on.20intended.20behavior/near/562001319 - rust-lang#143834 (comment) ## Prior Art - For `#[align]`, breakage was more wide-spread, so we posted this same mitigation here: rust-lang#144080. - For `#[sanitize]`, T-lang explicitly FCP'd the breakage stemming from renaming `#[no_sanitize]` (old name) to `#[sanitize]` (new name) that regressed a couple of crates: rust-lang#142681 (comment). ## Alternatives to this PR Generally: - We let it slide. - T-lang FCP on `#[unroll]` breakage (in which case this PR should be closed). - FCP another name (and associated breakages). - (Hard) Fix the built-in attribute name resolution behavior. I have no particular preference on the approaches myself, any of this PR and the alternatives seem fine so as long as the breakage is *deliberate* not accidental.
Rename `#[unroll]` => `#[rustc_unroll]` to mitigate nameres ambiguity ## Summary Mitigate rust-lang#159429 by renaming `#[unroll]` => `#[rustc_unroll]`. Did not bother with a regression test, because a regression test would be hedging against an unknown attribute if `#[unroll]` later proceeds to get a different name. Tracking issue for `#![feature(loop_hints)]`: rust-lang#156874. ## Rationale Even while the crater-observed fallout seems to be relatively small, we'd like such nameres ambiguity breakages to be *deliberate* (read: T-lang FCP'd) rather than accidental (discovered through beta crater runs). See discussions around [last week's compiler triage meeting](https://rust-lang.zulipchat.com/#narrow/channel/238009-t-compiler.2Fmeetings/topic/.5Bweekly.5D.202026-07-23/near/612371735). ## Background context The recurring problem is that built-in attributes are treated differently compared to ordinary prelude attributes, built-in attributes, even while unstable, can name-collide with stable macro re-exports of the same name (and proc-macro helper attributes of the same name), which can break stable code. See rust-lang#134964. See also: - rust-lang#133708 - rust-lang#53913 (comment) - https://rust-lang.zulipchat.com/#narrow/channel/213817-t-lang/topic/Name.20Res.3A.20questions.20on.20intended.20behavior/near/562001319 - rust-lang#143834 (comment) ## Prior Art - For `#[align]`, breakage was more wide-spread, so we posted this same mitigation here: rust-lang#144080. - For `#[sanitize]`, T-lang explicitly FCP'd the breakage stemming from renaming `#[no_sanitize]` (old name) to `#[sanitize]` (new name) that regressed a couple of crates: rust-lang#142681 (comment). ## Alternatives to this PR Generally: - We let it slide. - T-lang FCP on `#[unroll]` breakage (in which case this PR should be closed). - FCP another name (and associated breakages). - (Hard) Fix the built-in attribute name resolution behavior. I have no particular preference on the approaches myself, any of this PR and the alternatives seem fine so as long as the breakage is *deliberate* not accidental.
Rename `#[unroll]` => `#[rustc_unroll]` to mitigate nameres ambiguity ## Summary Mitigate rust-lang#159429 by renaming `#[unroll]` => `#[rustc_unroll]`. Did not bother with a regression test, because a regression test would be hedging against an unknown attribute if `#[unroll]` later proceeds to get a different name. Tracking issue for `#![feature(loop_hints)]`: rust-lang#156874. ## Rationale Even while the crater-observed fallout seems to be relatively small, we'd like such nameres ambiguity breakages to be *deliberate* (read: T-lang FCP'd) rather than accidental (discovered through beta crater runs). See discussions around [last week's compiler triage meeting](https://rust-lang.zulipchat.com/#narrow/channel/238009-t-compiler.2Fmeetings/topic/.5Bweekly.5D.202026-07-23/near/612371735). ## Background context The recurring problem is that built-in attributes are treated differently compared to ordinary prelude attributes, built-in attributes, even while unstable, can name-collide with stable macro re-exports of the same name (and proc-macro helper attributes of the same name), which can break stable code. See rust-lang#134964. See also: - rust-lang#133708 - rust-lang#53913 (comment) - https://rust-lang.zulipchat.com/#narrow/channel/213817-t-lang/topic/Name.20Res.3A.20questions.20on.20intended.20behavior/near/562001319 - rust-lang#143834 (comment) ## Prior Art - For `#[align]`, breakage was more wide-spread, so we posted this same mitigation here: rust-lang#144080. - For `#[sanitize]`, T-lang explicitly FCP'd the breakage stemming from renaming `#[no_sanitize]` (old name) to `#[sanitize]` (new name) that regressed a couple of crates: rust-lang#142681 (comment). ## Alternatives to this PR Generally: - We let it slide. - T-lang FCP on `#[unroll]` breakage (in which case this PR should be closed). - FCP another name (and associated breakages). - (Hard) Fix the built-in attribute name resolution behavior. I have no particular preference on the approaches myself, any of this PR and the alternatives seem fine so as long as the breakage is *deliberate* not accidental.
Rename `#[unroll]` => `#[rustc_unroll]` to mitigate nameres ambiguity ## Summary Mitigate rust-lang#159429 by renaming `#[unroll]` => `#[rustc_unroll]`. Did not bother with a regression test, because a regression test would be hedging against an unknown attribute if `#[unroll]` later proceeds to get a different name. Tracking issue for `#![feature(loop_hints)]`: rust-lang#156874. ## Rationale Even while the crater-observed fallout seems to be relatively small, we'd like such nameres ambiguity breakages to be *deliberate* (read: T-lang FCP'd) rather than accidental (discovered through beta crater runs). See discussions around [last week's compiler triage meeting](https://rust-lang.zulipchat.com/#narrow/channel/238009-t-compiler.2Fmeetings/topic/.5Bweekly.5D.202026-07-23/near/612371735). ## Background context The recurring problem is that built-in attributes are treated differently compared to ordinary prelude attributes, built-in attributes, even while unstable, can name-collide with stable macro re-exports of the same name (and proc-macro helper attributes of the same name), which can break stable code. See rust-lang#134964. See also: - rust-lang#133708 - rust-lang#53913 (comment) - https://rust-lang.zulipchat.com/#narrow/channel/213817-t-lang/topic/Name.20Res.3A.20questions.20on.20intended.20behavior/near/562001319 - rust-lang#143834 (comment) ## Prior Art - For `#[align]`, breakage was more wide-spread, so we posted this same mitigation here: rust-lang#144080. - For `#[sanitize]`, T-lang explicitly FCP'd the breakage stemming from renaming `#[no_sanitize]` (old name) to `#[sanitize]` (new name) that regressed a couple of crates: rust-lang#142681 (comment). ## Alternatives to this PR Generally: - We let it slide. - T-lang FCP on `#[unroll]` breakage (in which case this PR should be closed). - FCP another name (and associated breakages). - (Hard) Fix the built-in attribute name resolution behavior. I have no particular preference on the approaches myself, any of this PR and the alternatives seem fine so as long as the breakage is *deliberate* not accidental.
Rename `#[unroll]` => `#[rustc_unroll]` to mitigate nameres ambiguity ## Summary Mitigate rust-lang#159429 by renaming `#[unroll]` => `#[rustc_unroll]`. Did not bother with a regression test, because a regression test would be hedging against an unknown attribute if `#[unroll]` later proceeds to get a different name. Tracking issue for `#![feature(loop_hints)]`: rust-lang#156874. ## Rationale Even while the crater-observed fallout seems to be relatively small, we'd like such nameres ambiguity breakages to be *deliberate* (read: T-lang FCP'd) rather than accidental (discovered through beta crater runs). See discussions around [last week's compiler triage meeting](https://rust-lang.zulipchat.com/#narrow/channel/238009-t-compiler.2Fmeetings/topic/.5Bweekly.5D.202026-07-23/near/612371735). ## Background context The recurring problem is that built-in attributes are treated differently compared to ordinary prelude attributes, built-in attributes, even while unstable, can name-collide with stable macro re-exports of the same name (and proc-macro helper attributes of the same name), which can break stable code. See rust-lang#134964. See also: - rust-lang#133708 - rust-lang#53913 (comment) - https://rust-lang.zulipchat.com/#narrow/channel/213817-t-lang/topic/Name.20Res.3A.20questions.20on.20intended.20behavior/near/562001319 - rust-lang#143834 (comment) ## Prior Art - For `#[align]`, breakage was more wide-spread, so we posted this same mitigation here: rust-lang#144080. - For `#[sanitize]`, T-lang explicitly FCP'd the breakage stemming from renaming `#[no_sanitize]` (old name) to `#[sanitize]` (new name) that regressed a couple of crates: rust-lang#142681 (comment). ## Alternatives to this PR Generally: - We let it slide. - T-lang FCP on `#[unroll]` breakage (in which case this PR should be closed). - FCP another name (and associated breakages). - (Hard) Fix the built-in attribute name resolution behavior. I have no particular preference on the approaches myself, any of this PR and the alternatives seem fine so as long as the breakage is *deliberate* not accidental.
Rollup merge of #160211 - jieyouxu:froot-loops, r=mati865 Rename `#[unroll]` => `#[rustc_unroll]` to mitigate nameres ambiguity ## Summary Mitigate #159429 by renaming `#[unroll]` => `#[rustc_unroll]`. Did not bother with a regression test, because a regression test would be hedging against an unknown attribute if `#[unroll]` later proceeds to get a different name. Tracking issue for `#![feature(loop_hints)]`: #156874. ## Rationale Even while the crater-observed fallout seems to be relatively small, we'd like such nameres ambiguity breakages to be *deliberate* (read: T-lang FCP'd) rather than accidental (discovered through beta crater runs). See discussions around [last week's compiler triage meeting](https://rust-lang.zulipchat.com/#narrow/channel/238009-t-compiler.2Fmeetings/topic/.5Bweekly.5D.202026-07-23/near/612371735). ## Background context The recurring problem is that built-in attributes are treated differently compared to ordinary prelude attributes, built-in attributes, even while unstable, can name-collide with stable macro re-exports of the same name (and proc-macro helper attributes of the same name), which can break stable code. See #134964. See also: - #133708 - #53913 (comment) - https://rust-lang.zulipchat.com/#narrow/channel/213817-t-lang/topic/Name.20Res.3A.20questions.20on.20intended.20behavior/near/562001319 - #143834 (comment) ## Prior Art - For `#[align]`, breakage was more wide-spread, so we posted this same mitigation here: #144080. - For `#[sanitize]`, T-lang explicitly FCP'd the breakage stemming from renaming `#[no_sanitize]` (old name) to `#[sanitize]` (new name) that regressed a couple of crates: #142681 (comment). ## Alternatives to this PR Generally: - We let it slide. - T-lang FCP on `#[unroll]` breakage (in which case this PR should be closed). - FCP another name (and associated breakages). - (Hard) Fix the built-in attribute name resolution behavior. I have no particular preference on the approaches myself, any of this PR and the alternatives seem fine so as long as the breakage is *deliberate* not accidental.
Mitigates beta regression #143834 after a beta backport.
Background on the beta regression
The name resolution regression arises due to #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 such asMitigation approach
This PR renames
#[align]to#[rustc_align]to mitigate the beta regression by:#[align].#[align]to#[rustc_align]. The renamed attribute beingrustc_alignwill not introduce new stable breakages, as attributes beginning withrustcare reserved and perma-unstable. This does mean existing nightly code usingfn_alignfeature 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.
Alternative mitigation options
Various mitigation options were considered during the compiler triage meeting, and those consideration are partly reproduced here:
Review advice
This PR is best reviewed commit-by-commit.
tests/ui/attributes/fn-align-nameres-ambiguity-143834.rswhich demonstrates the current name resolution regression re.align. This test fails against current master.tests/ui/attributes/fn-align-nameres-ambiguity-143834.rsto 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.