diff --git a/compiler/rustc_feature/src/accepted.rs b/compiler/rustc_feature/src/accepted.rs index cfe0f4e5d6cb6..0efd6bae409aa 100644 --- a/compiler/rustc_feature/src/accepted.rs +++ b/compiler/rustc_feature/src/accepted.rs @@ -216,6 +216,8 @@ declare_features! ( (accepted, f16c_target_feature, "1.68.0", Some(44839)), /// Allows field shorthands (`x` meaning `x: x`) in struct literal expressions. (accepted, field_init_shorthand, "1.17.0", Some(37340)), + /// Allows using `#[align(...)]` on function items + (accepted, fn_align, "CURRENT_RUSTC_VERSION", Some(82232)), /// Allows `#[must_use]` on functions, and introduces must-use operators (RFC 1940). (accepted, fn_must_use, "1.27.0", Some(43302)), /// Allows capturing variables in scope using format_args! diff --git a/compiler/rustc_feature/src/builtin_attrs.rs b/compiler/rustc_feature/src/builtin_attrs.rs index 5b1f1684d54c1..f69780234ea11 100644 --- a/compiler/rustc_feature/src/builtin_attrs.rs +++ b/compiler/rustc_feature/src/builtin_attrs.rs @@ -495,7 +495,7 @@ pub static BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[ ), ungated!(no_link, Normal, template!(Word), WarnFollowing, EncodeCrossCrate::No), ungated!(repr, Normal, template!(List: "C"), DuplicatesOk, EncodeCrossCrate::No), - gated!(align, Normal, template!(List: "alignment"), DuplicatesOk, EncodeCrossCrate::No, fn_align, experimental!(align)), + ungated!(align, Normal, template!(List: "alignment"), DuplicatesOk, EncodeCrossCrate::No), ungated!(unsafe(Edition2024) export_name, Normal, template!(NameValueStr: "name"), FutureWarnPreceding, EncodeCrossCrate::No), ungated!(unsafe(Edition2024) link_section, Normal, template!(NameValueStr: "name"), FutureWarnPreceding, EncodeCrossCrate::No), ungated!(unsafe(Edition2024) no_mangle, Normal, template!(Word), WarnFollowing, EncodeCrossCrate::No), diff --git a/compiler/rustc_feature/src/unstable.rs b/compiler/rustc_feature/src/unstable.rs index 91715851226bb..4c5c3d0bc89a7 100644 --- a/compiler/rustc_feature/src/unstable.rs +++ b/compiler/rustc_feature/src/unstable.rs @@ -510,8 +510,6 @@ declare_features! ( (unstable, ffi_pure, "1.45.0", Some(58329)), /// Controlling the behavior of fmt::Debug (unstable, fmt_debug, "1.82.0", Some(129709)), - /// Allows using `#[align(...)]` on function items - (unstable, fn_align, "1.53.0", Some(82232)), /// Support delegating implementation of functions to other already implemented functions. (incomplete, fn_delegation, "1.76.0", Some(118212)), /// Allows impls for the Freeze trait. diff --git a/src/tools/miri/tests/pass/fn_align.rs b/src/tools/miri/tests/pass/fn_align.rs index 28f9299588003..c26a11f202c5e 100644 --- a/src/tools/miri/tests/pass/fn_align.rs +++ b/src/tools/miri/tests/pass/fn_align.rs @@ -1,5 +1,4 @@ //@compile-flags: -Zmin-function-alignment=8 -#![feature(fn_align)] // When a function uses `align(N)`, the function address should be a multiple of `N`. diff --git a/tests/assembly/naked-functions/aix.rs b/tests/assembly/naked-functions/aix.rs index 57ff0e183bed5..68d568986062c 100644 --- a/tests/assembly/naked-functions/aix.rs +++ b/tests/assembly/naked-functions/aix.rs @@ -9,7 +9,7 @@ //@[aix] needs-llvm-components: powerpc #![crate_type = "lib"] -#![feature(no_core, asm_experimental_arch, f128, linkage, fn_align)] +#![feature(no_core, asm_experimental_arch, f128, linkage)] #![no_core] // tests that naked functions work for the `powerpc64-ibm-aix` target. diff --git a/tests/assembly/naked-functions/wasm32.rs b/tests/assembly/naked-functions/wasm32.rs index 5f114246ad557..8311188ed96b4 100644 --- a/tests/assembly/naked-functions/wasm32.rs +++ b/tests/assembly/naked-functions/wasm32.rs @@ -9,7 +9,7 @@ //@ [wasm32-wasip1] needs-llvm-components: webassembly #![crate_type = "lib"] -#![feature(no_core, asm_experimental_arch, f128, linkage, fn_align)] +#![feature(no_core, asm_experimental_arch, f128, linkage)] #![no_core] extern crate minicore; diff --git a/tests/codegen/align-fn.rs b/tests/codegen/align-fn.rs index 267da0602406e..b5095bcd2b71d 100644 --- a/tests/codegen/align-fn.rs +++ b/tests/codegen/align-fn.rs @@ -1,7 +1,6 @@ //@ compile-flags: -C no-prepopulate-passes -Z mir-opt-level=0 #![crate_type = "lib"] -#![feature(fn_align)] // CHECK: align 16 #[no_mangle] diff --git a/tests/codegen/min-function-alignment.rs b/tests/codegen/min-function-alignment.rs index 75f845572a4af..e2ebb38983b10 100644 --- a/tests/codegen/min-function-alignment.rs +++ b/tests/codegen/min-function-alignment.rs @@ -4,7 +4,6 @@ //@ [align1024] compile-flags: -Zmin-function-alignment=1024 #![crate_type = "lib"] -#![feature(fn_align)] // functions without explicit alignment use the global minimum // diff --git a/tests/codegen/naked-fn/aligned.rs b/tests/codegen/naked-fn/aligned.rs index f9fce8e5a5d59..24bd886b271a2 100644 --- a/tests/codegen/naked-fn/aligned.rs +++ b/tests/codegen/naked-fn/aligned.rs @@ -3,7 +3,6 @@ //@ ignore-arm no "ret" mnemonic #![crate_type = "lib"] -#![feature(fn_align)] use std::arch::naked_asm; // CHECK: .balign 16 diff --git a/tests/codegen/naked-fn/min-function-alignment.rs b/tests/codegen/naked-fn/min-function-alignment.rs index 59554c1cae554..ca4f2a1c9f61b 100644 --- a/tests/codegen/naked-fn/min-function-alignment.rs +++ b/tests/codegen/naked-fn/min-function-alignment.rs @@ -2,7 +2,6 @@ //@ needs-asm-support //@ ignore-arm no "ret" mnemonic -#![feature(fn_align)] #![crate_type = "lib"] // functions without explicit alignment use the global minimum diff --git a/tests/ui/asm/naked-with-invalid-repr-attr.rs b/tests/ui/asm/naked-with-invalid-repr-attr.rs index bfbbf29a69ee7..4d22bb5d55fdc 100644 --- a/tests/ui/asm/naked-with-invalid-repr-attr.rs +++ b/tests/ui/asm/naked-with-invalid-repr-attr.rs @@ -1,5 +1,4 @@ //@ needs-asm-support -#![feature(fn_align)] #![crate_type = "lib"] use std::arch::naked_asm; diff --git a/tests/ui/asm/naked-with-invalid-repr-attr.stderr b/tests/ui/asm/naked-with-invalid-repr-attr.stderr index 4eb4a4e5a0482..d8c4f94ad0db2 100644 --- a/tests/ui/asm/naked-with-invalid-repr-attr.stderr +++ b/tests/ui/asm/naked-with-invalid-repr-attr.stderr @@ -1,5 +1,5 @@ error[E0517]: attribute should be applied to a struct, enum, or union - --> $DIR/naked-with-invalid-repr-attr.rs:6:8 + --> $DIR/naked-with-invalid-repr-attr.rs:5:8 | LL | #[repr(C)] | ^ @@ -11,7 +11,7 @@ LL | | } | |_- not a struct, enum, or union error[E0517]: attribute should be applied to a struct, enum, or union - --> $DIR/naked-with-invalid-repr-attr.rs:14:8 + --> $DIR/naked-with-invalid-repr-attr.rs:13:8 | LL | #[repr(transparent)] | ^^^^^^^^^^^ @@ -23,7 +23,7 @@ LL | | } | |_- not a struct, enum, or union error[E0517]: attribute should be applied to a struct, enum, or union - --> $DIR/naked-with-invalid-repr-attr.rs:22:8 + --> $DIR/naked-with-invalid-repr-attr.rs:21:8 | LL | #[repr(C)] | ^ @@ -35,7 +35,7 @@ LL | | } | |_- not a struct, enum, or union error[E0517]: attribute should be applied to a struct, enum, or union - --> $DIR/naked-with-invalid-repr-attr.rs:32:8 + --> $DIR/naked-with-invalid-repr-attr.rs:31:8 | LL | #[repr(C, packed)] | ^ @@ -48,7 +48,7 @@ LL | | } | |_- not a struct, enum, or union error[E0517]: attribute should be applied to a struct or union - --> $DIR/naked-with-invalid-repr-attr.rs:32:11 + --> $DIR/naked-with-invalid-repr-attr.rs:31:11 | LL | #[repr(C, packed)] | ^^^^^^ @@ -61,7 +61,7 @@ LL | | } | |_- not a struct or union error[E0517]: attribute should be applied to an enum - --> $DIR/naked-with-invalid-repr-attr.rs:42:8 + --> $DIR/naked-with-invalid-repr-attr.rs:41:8 | LL | #[repr(u8)] | ^^ diff --git a/tests/ui/attributes/malformed-fn-align.rs b/tests/ui/attributes/malformed-fn-align.rs index f5ab9555e561f..03faac97ce2a3 100644 --- a/tests/ui/attributes/malformed-fn-align.rs +++ b/tests/ui/attributes/malformed-fn-align.rs @@ -1,4 +1,3 @@ -#![feature(fn_align)] #![crate_type = "lib"] trait MyTrait { diff --git a/tests/ui/attributes/malformed-fn-align.stderr b/tests/ui/attributes/malformed-fn-align.stderr index b769d0b457ddd..106acfadc724f 100644 --- a/tests/ui/attributes/malformed-fn-align.stderr +++ b/tests/ui/attributes/malformed-fn-align.stderr @@ -1,5 +1,5 @@ error[E0539]: malformed `align` attribute input - --> $DIR/malformed-fn-align.rs:5:5 + --> $DIR/malformed-fn-align.rs:4:5 | LL | #[align] | ^^^^^^^^ @@ -8,7 +8,7 @@ LL | #[align] | help: must be of the form: `#[align()]` error[E0805]: malformed `align` attribute input - --> $DIR/malformed-fn-align.rs:8:5 + --> $DIR/malformed-fn-align.rs:7:5 | LL | #[align(1, 2)] | ^^^^^^^------^ @@ -17,7 +17,7 @@ LL | #[align(1, 2)] | help: must be of the form: `#[align()]` error[E0539]: malformed `align` attribute input - --> $DIR/malformed-fn-align.rs:12:1 + --> $DIR/malformed-fn-align.rs:11:1 | LL | #[align = 16] | ^^^^^^^^^^^^^ @@ -26,31 +26,31 @@ LL | #[align = 16] | help: must be of the form: `#[align()]` error[E0589]: invalid alignment value: not an unsuffixed integer - --> $DIR/malformed-fn-align.rs:15:9 + --> $DIR/malformed-fn-align.rs:14:9 | LL | #[align("hello")] | ^^^^^^^ error[E0589]: invalid alignment value: not a power of two - --> $DIR/malformed-fn-align.rs:18:9 + --> $DIR/malformed-fn-align.rs:17:9 | LL | #[align(0)] | ^ error: `#[repr(align(...))]` is not supported on function items - --> $DIR/malformed-fn-align.rs:21:8 + --> $DIR/malformed-fn-align.rs:20:8 | LL | #[repr(align(16))] | ^^^^^^^^^ | help: use `#[align(...)]` instead - --> $DIR/malformed-fn-align.rs:21:8 + --> $DIR/malformed-fn-align.rs:20:8 | LL | #[repr(align(16))] | ^^^^^^^^^ error: `#[align(...)]` is not supported on struct items - --> $DIR/malformed-fn-align.rs:24:1 + --> $DIR/malformed-fn-align.rs:23:1 | LL | #[align(16)] | ^^^^^^^^^^^^ diff --git a/tests/ui/feature-gates/feature-gate-fn_align.rs b/tests/ui/feature-gates/feature-gate-fn_align.rs deleted file mode 100644 index b6c300e5cbe61..0000000000000 --- a/tests/ui/feature-gates/feature-gate-fn_align.rs +++ /dev/null @@ -1,12 +0,0 @@ -#![crate_type = "lib"] - -#[align(16)] -//~^ ERROR the `#[align]` attribute is an experimental feature -fn requires_alignment() {} - -trait MyTrait { - #[align] - //~^ ERROR the `#[align]` attribute is an experimental feature - //~| ERROR malformed `align` attribute input - fn myfun(); -} diff --git a/tests/ui/feature-gates/feature-gate-fn_align.stderr b/tests/ui/feature-gates/feature-gate-fn_align.stderr deleted file mode 100644 index 921cf08435c28..0000000000000 --- a/tests/ui/feature-gates/feature-gate-fn_align.stderr +++ /dev/null @@ -1,33 +0,0 @@ -error[E0658]: the `#[align]` attribute is an experimental feature - --> $DIR/feature-gate-fn_align.rs:3:1 - | -LL | #[align(16)] - | ^^^^^^^^^^^^ - | - = note: see issue #82232 for more information - = help: add `#![feature(fn_align)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - -error[E0658]: the `#[align]` attribute is an experimental feature - --> $DIR/feature-gate-fn_align.rs:8:5 - | -LL | #[align] - | ^^^^^^^^ - | - = note: see issue #82232 for more information - = help: add `#![feature(fn_align)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - -error[E0539]: malformed `align` attribute input - --> $DIR/feature-gate-fn_align.rs:8:5 - | -LL | #[align] - | ^^^^^^^^ - | | - | expected this to be a list - | help: must be of the form: `#[align()]` - -error: aborting due to 3 previous errors - -Some errors have detailed explanations: E0539, E0658. -For more information about an error, try `rustc --explain E0539`.