-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Mitigate #[align]
name resolution ambiguity regression with a rename
#144080
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
…sion See RUST-143834.
From `#[align]` -> `#[xxxxx_temp_mitigation_rename_of_align_xxxxx]` to minimize probability of colliding with user defined macros or derive proc-macro attributes. 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. This is not 100% bullet-proof, because technically a user could've written some stable code which `s/align/xxxxx_temp_mitigation_rename_of_align_xxxxx/`, but that seems sufficiently unlikely. 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.
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 |
@@ -1,49 +1,52 @@ | |||
// ignore-tidy-linelength |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remark: intentional to minimize diff lines
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 |
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#[xxxxx_temp_mitigation_rename_of_align_xxxxx]
to mitigate the beta regression by:#[align]
.macro_rules!
macro or proc-macro attribute namedxxxxx_temp_mitigation_rename_of_align_xxxxx
, but I consider that practically sufficiently unlikely.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.rs
which demonstrates the current name resolution regression re.align
. This test fails against current master.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.