Skip to content

Stabilize fn_align: #[align(N)] on functions #140261

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions compiler/rustc_feature/src/accepted.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_feature/src/builtin_attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
2 changes: 0 additions & 2 deletions compiler/rustc_feature/src/unstable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 0 additions & 1 deletion src/tools/miri/tests/pass/fn_align.rs
Original file line number Diff line number Diff line change
@@ -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`.

Expand Down
2 changes: 1 addition & 1 deletion tests/assembly/naked-functions/aix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion tests/assembly/naked-functions/wasm32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion tests/codegen/align-fn.rs
Original file line number Diff line number Diff line change
@@ -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]
Expand Down
1 change: 0 additions & 1 deletion tests/codegen/min-function-alignment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
//
Expand Down
1 change: 0 additions & 1 deletion tests/codegen/naked-fn/aligned.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
//@ ignore-arm no "ret" mnemonic

#![crate_type = "lib"]
#![feature(fn_align)]
use std::arch::naked_asm;

// CHECK: .balign 16
Expand Down
1 change: 0 additions & 1 deletion tests/codegen/naked-fn/min-function-alignment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion tests/ui/asm/naked-with-invalid-repr-attr.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//@ needs-asm-support
#![feature(fn_align)]
#![crate_type = "lib"]
use std::arch::naked_asm;

Expand Down
12 changes: 6 additions & 6 deletions tests/ui/asm/naked-with-invalid-repr-attr.stderr
Original file line number Diff line number Diff line change
@@ -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)]
| ^
Expand All @@ -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)]
| ^^^^^^^^^^^
Expand All @@ -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)]
| ^
Expand All @@ -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)]
| ^
Expand All @@ -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)]
| ^^^^^^
Expand All @@ -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)]
| ^^
Expand Down
1 change: 0 additions & 1 deletion tests/ui/attributes/malformed-fn-align.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#![feature(fn_align)]
#![crate_type = "lib"]

trait MyTrait {
Expand Down
16 changes: 8 additions & 8 deletions tests/ui/attributes/malformed-fn-align.stderr
Original file line number Diff line number Diff line change
@@ -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]
| ^^^^^^^^
Expand All @@ -8,7 +8,7 @@ LL | #[align]
| help: must be of the form: `#[align(<alignment in bytes>)]`

error[E0805]: malformed `align` attribute input
--> $DIR/malformed-fn-align.rs:8:5
--> $DIR/malformed-fn-align.rs:7:5
|
LL | #[align(1, 2)]
| ^^^^^^^------^
Expand All @@ -17,7 +17,7 @@ LL | #[align(1, 2)]
| help: must be of the form: `#[align(<alignment in bytes>)]`

error[E0539]: malformed `align` attribute input
--> $DIR/malformed-fn-align.rs:12:1
--> $DIR/malformed-fn-align.rs:11:1
|
LL | #[align = 16]
| ^^^^^^^^^^^^^
Expand All @@ -26,31 +26,31 @@ LL | #[align = 16]
| help: must be of the form: `#[align(<alignment in bytes>)]`

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)]
| ^^^^^^^^^^^^
Expand Down
12 changes: 0 additions & 12 deletions tests/ui/feature-gates/feature-gate-fn_align.rs

This file was deleted.

33 changes: 0 additions & 33 deletions tests/ui/feature-gates/feature-gate-fn_align.stderr

This file was deleted.

Loading