Skip to content

Commit d01b56e

Browse files
committed
stabilize align(N) on function items
1 parent 8a65ee0 commit d01b56e

File tree

17 files changed

+42
-92
lines changed

17 files changed

+42
-92
lines changed

compiler/rustc_attr_parsing/src/attributes/repr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ pub(crate) struct AlignParser(Option<(Align, Span)>);
273273

274274
impl AlignParser {
275275
const PATH: &'static [Symbol] = &[sym::align];
276-
const TEMPLATE: AttributeTemplate = template!(Word, List: "<alignment in bytes>");
276+
const TEMPLATE: AttributeTemplate = template!(List: "<alignment in bytes>");
277277

278278
fn parse<'c, S: Stage>(
279279
&mut self,

compiler/rustc_feature/src/accepted.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,8 @@ declare_features! (
216216
(accepted, f16c_target_feature, "1.68.0", Some(44839)),
217217
/// Allows field shorthands (`x` meaning `x: x`) in struct literal expressions.
218218
(accepted, field_init_shorthand, "1.17.0", Some(37340)),
219+
/// Allows using `#[align(...)]` on function items
220+
(accepted, fn_align, "CURRENT_RUSTC_VERSION", Some(82232)),
219221
/// Allows `#[must_use]` on functions, and introduces must-use operators (RFC 1940).
220222
(accepted, fn_must_use, "1.27.0", Some(43302)),
221223
/// Allows capturing variables in scope using format_args!

compiler/rustc_feature/src/builtin_attrs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ pub static BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
495495
),
496496
ungated!(no_link, Normal, template!(Word), WarnFollowing, EncodeCrossCrate::No),
497497
ungated!(repr, Normal, template!(List: "C"), DuplicatesOk, EncodeCrossCrate::No),
498-
gated!(align, Normal, template!(List: "alignment"), DuplicatesOk, EncodeCrossCrate::No, fn_align, experimental!(align)),
498+
ungated!(align, Normal, template!(List: "alignment"), DuplicatesOk, EncodeCrossCrate::No),
499499
ungated!(unsafe(Edition2024) export_name, Normal, template!(NameValueStr: "name"), FutureWarnPreceding, EncodeCrossCrate::No),
500500
ungated!(unsafe(Edition2024) link_section, Normal, template!(NameValueStr: "name"), FutureWarnPreceding, EncodeCrossCrate::No),
501501
ungated!(unsafe(Edition2024) no_mangle, Normal, template!(Word), WarnFollowing, EncodeCrossCrate::No),

compiler/rustc_feature/src/unstable.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -510,8 +510,6 @@ declare_features! (
510510
(unstable, ffi_pure, "1.45.0", Some(58329)),
511511
/// Controlling the behavior of fmt::Debug
512512
(unstable, fmt_debug, "1.82.0", Some(129709)),
513-
/// Allows using `#[repr(align(...))]` on function items
514-
(unstable, fn_align, "1.53.0", Some(82232)),
515513
/// Support delegating implementation of functions to other already implemented functions.
516514
(incomplete, fn_delegation, "1.76.0", Some(118212)),
517515
/// Allows impls for the Freeze trait.

src/tools/miri/tests/pass/fn_align.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
//@compile-flags: -Zmin-function-alignment=8
2-
#![feature(fn_align)]
32

43
// When a function uses `align(N)`, the function address should be a multiple of `N`.
54

tests/assembly/naked-functions/aix.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
//@[aix] needs-llvm-components: powerpc
1010

1111
#![crate_type = "lib"]
12-
#![feature(no_core, asm_experimental_arch, f128, linkage, fn_align)]
12+
#![feature(no_core, asm_experimental_arch, f128, linkage)]
1313
#![no_core]
1414

1515
// tests that naked functions work for the `powerpc64-ibm-aix` target.

tests/assembly/naked-functions/wasm32.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
//@ [wasm32-wasip1] needs-llvm-components: webassembly
1010

1111
#![crate_type = "lib"]
12-
#![feature(no_core, asm_experimental_arch, f128, linkage, fn_align)]
12+
#![feature(no_core, asm_experimental_arch, f128, linkage)]
1313
#![no_core]
1414

1515
extern crate minicore;

tests/codegen/align-fn.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
//@ compile-flags: -C no-prepopulate-passes -Z mir-opt-level=0
22

33
#![crate_type = "lib"]
4-
#![feature(fn_align)]
54

65
// CHECK: align 16
76
#[no_mangle]

tests/codegen/min-function-alignment.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
//@ [align1024] compile-flags: -Zmin-function-alignment=1024
55

66
#![crate_type = "lib"]
7-
#![feature(fn_align)]
87

98
// functions without explicit alignment use the global minimum
109
//

tests/codegen/naked-fn/aligned.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
//@ ignore-arm no "ret" mnemonic
44

55
#![crate_type = "lib"]
6-
#![feature(fn_align)]
76
use std::arch::naked_asm;
87

98
// CHECK: .balign 16

tests/codegen/naked-fn/min-function-alignment.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
//@ needs-asm-support
33
//@ ignore-arm no "ret" mnemonic
44

5-
#![feature(fn_align)]
65
#![crate_type = "lib"]
76

87
// functions without explicit alignment use the global minimum

tests/ui/asm/naked-with-invalid-repr-attr.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
//@ needs-asm-support
2-
#![feature(fn_align)]
32
#![crate_type = "lib"]
43
use std::arch::naked_asm;
54

tests/ui/asm/naked-with-invalid-repr-attr.stderr

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0517]: attribute should be applied to a struct, enum, or union
2-
--> $DIR/naked-with-invalid-repr-attr.rs:6:8
2+
--> $DIR/naked-with-invalid-repr-attr.rs:5:8
33
|
44
LL | #[repr(C)]
55
| ^
@@ -11,7 +11,7 @@ LL | | }
1111
| |_- not a struct, enum, or union
1212

1313
error[E0517]: attribute should be applied to a struct, enum, or union
14-
--> $DIR/naked-with-invalid-repr-attr.rs:14:8
14+
--> $DIR/naked-with-invalid-repr-attr.rs:13:8
1515
|
1616
LL | #[repr(transparent)]
1717
| ^^^^^^^^^^^
@@ -23,7 +23,7 @@ LL | | }
2323
| |_- not a struct, enum, or union
2424

2525
error[E0517]: attribute should be applied to a struct, enum, or union
26-
--> $DIR/naked-with-invalid-repr-attr.rs:22:8
26+
--> $DIR/naked-with-invalid-repr-attr.rs:21:8
2727
|
2828
LL | #[repr(C)]
2929
| ^
@@ -35,7 +35,7 @@ LL | | }
3535
| |_- not a struct, enum, or union
3636

3737
error[E0517]: attribute should be applied to a struct, enum, or union
38-
--> $DIR/naked-with-invalid-repr-attr.rs:32:8
38+
--> $DIR/naked-with-invalid-repr-attr.rs:31:8
3939
|
4040
LL | #[repr(C, packed)]
4141
| ^
@@ -48,7 +48,7 @@ LL | | }
4848
| |_- not a struct, enum, or union
4949

5050
error[E0517]: attribute should be applied to a struct or union
51-
--> $DIR/naked-with-invalid-repr-attr.rs:32:11
51+
--> $DIR/naked-with-invalid-repr-attr.rs:31:11
5252
|
5353
LL | #[repr(C, packed)]
5454
| ^^^^^^
@@ -61,7 +61,7 @@ LL | | }
6161
| |_- not a struct or union
6262

6363
error[E0517]: attribute should be applied to an enum
64-
--> $DIR/naked-with-invalid-repr-attr.rs:42:8
64+
--> $DIR/naked-with-invalid-repr-attr.rs:41:8
6565
|
6666
LL | #[repr(u8)]
6767
| ^^

tests/ui/attributes/malformed-fn-align.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
#![feature(fn_align)]
21
#![crate_type = "lib"]
32

43
trait MyTrait {
54
#[align] //~ ERROR malformed `align` attribute input
6-
fn myfun();
5+
fn myfun1();
6+
7+
#[align(1, 2)] //~ ERROR malformed `align` attribute input
8+
fn myfun2();
79
}
810

911
#[align = 16] //~ ERROR malformed `align` attribute input
Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,56 @@
11
error[E0539]: malformed `align` attribute input
2-
--> $DIR/malformed-fn-align.rs:5:5
2+
--> $DIR/malformed-fn-align.rs:4:5
33
|
44
LL | #[align]
5-
| ^^^^^^^^ expected this to be a list
6-
|
7-
help: try changing it to one of the following valid forms of the attribute
8-
|
9-
LL | #[align(<alignment in bytes>)]
10-
| ++++++++++++++++++++++
5+
| ^^^^^^^^
6+
| |
7+
| expected this to be a list
8+
| help: must be of the form: `#[align(<alignment in bytes>)]`
9+
10+
error[E0805]: malformed `align` attribute input
11+
--> $DIR/malformed-fn-align.rs:7:5
12+
|
13+
LL | #[align(1, 2)]
14+
| ^^^^^^^------^
15+
| | |
16+
| | expected a single argument here
17+
| help: must be of the form: `#[align(<alignment in bytes>)]`
1118

1219
error[E0539]: malformed `align` attribute input
13-
--> $DIR/malformed-fn-align.rs:9:1
20+
--> $DIR/malformed-fn-align.rs:11:1
1421
|
1522
LL | #[align = 16]
16-
| ^^^^^^^^^^^^^ expected this to be a list
17-
|
18-
help: try changing it to one of the following valid forms of the attribute
19-
|
20-
LL - #[align = 16]
21-
LL + #[align(<alignment in bytes>)]
22-
|
23-
LL - #[align = 16]
24-
LL + #[align]
25-
|
23+
| ^^^^^^^^^^^^^
24+
| |
25+
| expected this to be a list
26+
| help: must be of the form: `#[align(<alignment in bytes>)]`
2627

2728
error[E0589]: invalid alignment value: not an unsuffixed integer
28-
--> $DIR/malformed-fn-align.rs:12:9
29+
--> $DIR/malformed-fn-align.rs:14:9
2930
|
3031
LL | #[align("hello")]
3132
| ^^^^^^^
3233

3334
error[E0589]: invalid alignment value: not a power of two
34-
--> $DIR/malformed-fn-align.rs:15:9
35+
--> $DIR/malformed-fn-align.rs:17:9
3536
|
3637
LL | #[align(0)]
3738
| ^
3839

3940
error: `#[repr(align(...))]` is not supported on function items
40-
--> $DIR/malformed-fn-align.rs:18:8
41+
--> $DIR/malformed-fn-align.rs:20:8
4142
|
4243
LL | #[repr(align(16))]
4344
| ^^^^^^^^^
4445
|
4546
help: use `#[align(...)]` instead
46-
--> $DIR/malformed-fn-align.rs:18:8
47+
--> $DIR/malformed-fn-align.rs:20:8
4748
|
4849
LL | #[repr(align(16))]
4950
| ^^^^^^^^^
5051

5152
error: `#[align(...)]` is not supported on struct items
52-
--> $DIR/malformed-fn-align.rs:21:1
53+
--> $DIR/malformed-fn-align.rs:23:1
5354
|
5455
LL | #[align(16)]
5556
| ^^^^^^^^^^^^
@@ -60,7 +61,7 @@ LL - #[align(16)]
6061
LL + #[repr(align(16))]
6162
|
6263

63-
error: aborting due to 6 previous errors
64+
error: aborting due to 7 previous errors
6465

65-
Some errors have detailed explanations: E0539, E0589.
66+
Some errors have detailed explanations: E0539, E0589, E0805.
6667
For more information about an error, try `rustc --explain E0539`.

tests/ui/feature-gates/feature-gate-fn_align.rs

Lines changed: 0 additions & 12 deletions
This file was deleted.

tests/ui/feature-gates/feature-gate-fn_align.stderr

Lines changed: 0 additions & 35 deletions
This file was deleted.

0 commit comments

Comments
 (0)