rust/compiler
许杰友 Jieyou Xu (Joe) ef4a7fb1b7
Rollup merge of #144080 - jieyouxu:realign, r=BoxyUwU
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-22 00:54:28 +08:00
..
rustc rename stable_mir to rustc_public, and rustc_smir to rustc_public_bridge 2025-07-14 09:25:54 +00:00
rustc_abi Simplify codegen for niche-encoded variant tests 2025-07-12 04:53:24 -07:00
rustc_arena Introduce Arena::try_alloc_from_iter. 2025-04-19 01:13:18 +00:00
rustc_ast Auto merge of #143879 - fee1-dead-contrib:push-lrlpoouyqqry, r=fmease 2025-07-17 15:54:33 +00:00
rustc_ast_ir Use -Wunused_crate_dependencies for compiler crates. 2025-03-20 08:59:43 +11:00
rustc_ast_lowering Rollup merge of #143430 - cjgillot:extra-lifetime-swap, r=oli-obk 2025-07-22 00:54:25 +08:00
rustc_ast_passes AST lowering: More robustly deal with relaxed bounds 2025-07-18 03:13:21 +02:00
rustc_ast_pretty parse const trait Trait 2025-07-17 18:06:26 +08:00
rustc_attr_data_structures Rollup merge of #144080 - jieyouxu:realign, r=BoxyUwU 2025-07-22 00:54:28 +08:00
rustc_attr_parsing Rollup merge of #144080 - jieyouxu:realign, r=BoxyUwU 2025-07-22 00:54:28 +08:00
rustc_baked_icu_data
rustc_borrowck Add alias for ArgOutlivesPredicate 2025-07-15 16:02:26 +00:00
rustc_builtin_macros Rollup merge of #143925 - oli-obk:slice-const-partialeq, r=fee1-dead 2025-07-18 14:49:19 +02:00
rustc_codegen_cranelift Update cranelift tests 2025-07-20 10:15:14 -07:00
rustc_codegen_gcc Remove forgotten git annotations 2025-07-18 22:35:58 +02:00
rustc_codegen_llvm Rollup merge of #142097 - ZuseZ4:offload-host1, r=oli-obk 2025-07-22 00:54:24 +08:00
rustc_codegen_ssa Rollup merge of #142097 - ZuseZ4:offload-host1, r=oli-obk 2025-07-22 00:54:24 +08:00
rustc_const_eval interpret: fix TypeId pointers being considered data pointers 2025-07-19 10:29:13 +02:00
rustc_data_structures Fix wrong cache event query key 2025-07-07 15:16:42 +02:00
rustc_driver Remove recursion_limit increases. 2025-04-02 16:25:27 +11:00
rustc_driver_impl Rollup merge of #143719 - xizheyin:142812-1, r=jieyouxu 2025-07-18 04:27:51 +02:00
rustc_error_codes Don't reject *multiple* relaxed bounds, reject *duplicate* ones. 2025-07-18 12:24:56 +02:00
rustc_error_messages Remove unused feature gates 2025-06-28 23:36:46 +00:00
rustc_errors rename emit_unless to emit_unless_delay 2025-07-19 01:49:19 +08:00
rustc_expand Rollup merge of #143925 - oli-obk:slice-const-partialeq, r=fee1-dead 2025-07-18 14:49:19 +02:00
rustc_feature Mitigate #[align] name resolution ambiguity regression with a rename 2025-07-19 01:42:30 +08:00
rustc_fluent_macro Remove all unused feature gates from the compiler 2025-06-08 14:50:42 +00:00
rustc_fs_util Retry if creating temp fails with access denied 2025-04-25 11:28:36 +00:00
rustc_graphviz
rustc_hashes
rustc_hir Warn useless deprecation in check_attr. 2025-07-17 22:28:49 +00:00
rustc_hir_analysis Rollup merge of #144142 - compiler-errors:itib, r=fmease 2025-07-20 08:56:09 +02:00
rustc_hir_pretty parse const trait Trait 2025-07-17 18:06:26 +08:00
rustc_hir_typeck rename emit_unless to emit_unless_delay 2025-07-19 01:49:19 +08:00
rustc_incremental Auto merge of #139758 - Zoxc:thread-local-graph, r=oli-obk 2025-05-07 12:39:54 +00:00
rustc_index use div_ceil instead of manual logic 2025-07-05 10:55:42 +02:00
rustc_index_macros In rustc_mir_tranform, iterate over index newtypes instead of ints 2025-04-12 11:53:07 +00:00
rustc_infer Add alias for ArgOutlivesPredicate 2025-07-15 16:02:26 +00:00
rustc_interface Rollup merge of #142097 - ZuseZ4:offload-host1, r=oli-obk 2025-07-22 00:54:24 +08:00
rustc_lexer test(lexer): Add frontmatter unit test 2025-07-10 10:25:29 -05:00
rustc_lint Rollup merge of #141260 - LuigiPiucco:volatile-null, r=RalfJung 2025-07-20 08:56:05 +02:00
rustc_lint_defs Implement resolver warnings about reexporting private dependencies 2025-07-15 15:44:25 +02:00
rustc_llvm Rollup merge of #142097 - ZuseZ4:offload-host1, r=oli-obk 2025-07-22 00:54:24 +08:00
rustc_log Add documentation for init_logger_with_additional_layer 2025-06-12 12:11:15 +02:00
rustc_macros Fix line break after ":" in unpretty attribute print 2025-07-06 09:51:47 +02:00
rustc_metadata Rollup merge of #144059 - LorrensP-2158466:remove-crate-loader, r=petrochenkov 2025-07-18 19:14:46 +02:00
rustc_middle Rollup merge of #144080 - jieyouxu:realign, r=BoxyUwU 2025-07-22 00:54:28 +08:00
rustc_mir_build Auto merge of #143779 - JonathanBrouwer:automatically_derived_parser, r=oli-obk 2025-07-14 04:29:53 +00:00
rustc_mir_dataflow Remove support for SwitchInt edge effects in backward dataflow analyses 2025-07-11 10:56:50 +02:00
rustc_mir_transform Auto merge of #144238 - jhpratt:rollup-xb8aida, r=jhpratt 2025-07-21 08:42:52 +00:00
rustc_monomorphize Add opaque TypeId handles for CTFE 2025-07-09 16:37:11 +00:00
rustc_next_trait_solver update comment 2025-07-18 09:36:38 +02:00
rustc_parse Rollup merge of #144080 - jieyouxu:realign, r=BoxyUwU 2025-07-22 00:54:28 +08:00
rustc_parse_format update to literal-escaper-0.0.5 2025-07-08 10:16:44 +00:00
rustc_passes Rollup merge of #144080 - jieyouxu:realign, r=BoxyUwU 2025-07-22 00:54:28 +08:00
rustc_pattern_analysis Don't consider unstable fields always-inhabited 2025-07-20 18:23:18 +02:00
rustc_privacy Do not check privacy for RPITIT. 2025-07-17 23:59:41 +00:00
rustc_proc_macro update to literal-escaper-0.0.5 2025-07-08 10:16:44 +00:00
rustc_public use RustcPublic instead of StableMir 2025-07-18 18:49:32 +00:00
rustc_public_bridge Update docs in rustc_public_bridge 2025-07-18 18:49:12 +00:00
rustc_query_impl Remove unused allow attrs 2025-07-07 12:58:16 +00:00
rustc_query_system use is_multiple_of instead of manual modulo 2025-07-05 10:55:35 +02:00
rustc_resolve Auto merge of #144172 - lqd:revert-144013, r=petrochenkov 2025-07-19 18:20:39 +00:00
rustc_sanitizers Remove support for dyn* 2025-07-01 19:00:21 +00:00
rustc_serialize use div_ceil instead of manual logic 2025-07-05 10:55:42 +02:00
rustc_session add -Zoffload=Enable flag behind -Zunstable-options, to enable gpu (host) code generation 2025-07-18 16:24:00 -07:00
rustc_span Mitigate #[align] name resolution ambiguity regression with a rename 2025-07-19 01:42:30 +08:00
rustc_symbol_mangling use codegen_instance_attrs where an instance is (easily) available 2025-07-16 23:24:32 +02:00
rustc_target Update AMDGPU data layout 2025-07-18 09:35:11 +02:00
rustc_thread_pool Correct comments. 2025-06-28 17:58:21 +08:00
rustc_trait_selection Consider param-env for fast path 2025-07-20 17:45:01 +00:00
rustc_traits Consider param-env for fast path 2025-07-20 17:45:01 +00:00
rustc_transmute compiler: Parse p- specs in datalayout string, allow definition of custom default data address space 2025-07-07 09:04:53 +02:00
rustc_ty_utils Rollup merge of #143793 - fmease:lta-opaq-inf-recur, r=oli-obk 2025-07-17 10:41:45 +02:00
rustc_type_ir Auto merge of #143545 - compiler-errors:coroutine-obl, r=oli-obk 2025-07-18 02:23:50 +00:00
rustc_type_ir_macros Split TypeFolder and FallibleTypeFolder 2025-04-15 18:30:35 +00:00