about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/assembly/naked-functions/wasm32.rs2
-rw-r--r--tests/codegen/align-fn.rs22
-rw-r--r--tests/codegen/min-function-alignment.rs6
-rw-r--r--tests/codegen/naked-fn/aligned.rs2
-rw-r--r--tests/codegen/naked-fn/min-function-alignment.rs4
-rw-r--r--tests/ui/asm/naked-with-invalid-repr-attr.rs3
-rw-r--r--tests/ui/asm/naked-with-invalid-repr-attr.stderr12
-rw-r--r--tests/ui/attributes/arg-error-issue-121425.stderr12
-rw-r--r--tests/ui/attributes/invalid-repr.rs2
-rw-r--r--tests/ui/attributes/invalid-repr.stderr4
-rw-r--r--tests/ui/attributes/malformed-fn-align.rs17
-rw-r--r--tests/ui/attributes/malformed-fn-align.stderr69
-rw-r--r--tests/ui/feature-gates/feature-gate-fn_align.rs7
-rw-r--r--tests/ui/feature-gates/feature-gate-fn_align.stderr37
-rw-r--r--tests/ui/repr/attr-usage-repr.rs2
-rw-r--r--tests/ui/repr/attr-usage-repr.stderr4
-rw-r--r--tests/ui/repr/malformed-repr-hints.stderr24
17 files changed, 161 insertions, 68 deletions
diff --git a/tests/assembly/naked-functions/wasm32.rs b/tests/assembly/naked-functions/wasm32.rs
index 984152f2b45..5f114246ad5 100644
--- a/tests/assembly/naked-functions/wasm32.rs
+++ b/tests/assembly/naked-functions/wasm32.rs
@@ -37,7 +37,7 @@ extern "C" fn nop() {
 #[unsafe(naked)]
 #[linkage = "weak"]
 // wasm functions cannot be aligned, so this has no effect
-#[repr(align(32))]
+#[align(32)]
 extern "C" fn weak_aligned_nop() {
     naked_asm!("nop")
 }
diff --git a/tests/codegen/align-fn.rs b/tests/codegen/align-fn.rs
index 660d8cd2bbf..267da060240 100644
--- a/tests/codegen/align-fn.rs
+++ b/tests/codegen/align-fn.rs
@@ -5,7 +5,7 @@
 
 // CHECK: align 16
 #[no_mangle]
-#[repr(align(16))]
+#[align(16)]
 pub fn fn_align() {}
 
 pub struct A;
@@ -13,12 +13,12 @@ pub struct A;
 impl A {
     // CHECK: align 16
     #[no_mangle]
-    #[repr(align(16))]
+    #[align(16)]
     pub fn method_align(self) {}
 
     // CHECK: align 16
     #[no_mangle]
-    #[repr(align(16))]
+    #[align(16)]
     pub fn associated_fn() {}
 }
 
@@ -26,19 +26,19 @@ trait T: Sized {
     fn trait_fn() {}
 
     // CHECK: align 32
-    #[repr(align(32))]
+    #[align(32)]
     fn trait_method(self) {}
 }
 
 impl T for A {
     // CHECK: align 16
     #[no_mangle]
-    #[repr(align(16))]
+    #[align(16)]
     fn trait_fn() {}
 
     // CHECK: align 16
     #[no_mangle]
-    #[repr(align(16))]
+    #[align(16)]
     fn trait_method(self) {}
 }
 
@@ -51,18 +51,20 @@ pub fn foo() {
 // CHECK-LABEL: align_specified_twice_1
 // CHECK-SAME: align 64
 #[no_mangle]
-#[repr(align(32), align(64))]
+#[align(32)]
+#[align(64)]
 pub fn align_specified_twice_1() {}
 
 // CHECK-LABEL: align_specified_twice_2
 // CHECK-SAME: align 128
 #[no_mangle]
-#[repr(align(128), align(32))]
+#[align(128)]
+#[align(32)]
 pub fn align_specified_twice_2() {}
 
 // CHECK-LABEL: align_specified_twice_3
 // CHECK-SAME: align 256
 #[no_mangle]
-#[repr(align(32))]
-#[repr(align(256))]
+#[align(32)]
+#[align(256)]
 pub fn align_specified_twice_3() {}
diff --git a/tests/codegen/min-function-alignment.rs b/tests/codegen/min-function-alignment.rs
index 7c0ad12402a..75f845572a4 100644
--- a/tests/codegen/min-function-alignment.rs
+++ b/tests/codegen/min-function-alignment.rs
@@ -18,16 +18,16 @@ pub fn no_explicit_align() {}
 // align16: align 16
 // align1024: align 1024
 #[no_mangle]
-#[repr(align(8))]
+#[align(8)]
 pub fn lower_align() {}
 
-// the higher value of min-function-alignment and repr(align) wins out
+// the higher value of min-function-alignment and the align attribute wins out
 //
 // CHECK-LABEL: @higher_align
 // align16: align 32
 // align1024: align 1024
 #[no_mangle]
-#[repr(align(32))]
+#[align(32)]
 pub fn higher_align() {}
 
 // cold functions follow the same rules as other functions
diff --git a/tests/codegen/naked-fn/aligned.rs b/tests/codegen/naked-fn/aligned.rs
index 47ef779f1b2..f9fce8e5a5d 100644
--- a/tests/codegen/naked-fn/aligned.rs
+++ b/tests/codegen/naked-fn/aligned.rs
@@ -8,7 +8,7 @@ use std::arch::naked_asm;
 
 // CHECK: .balign 16
 // CHECK-LABEL: naked_empty:
-#[repr(align(16))]
+#[align(16)]
 #[no_mangle]
 #[unsafe(naked)]
 pub extern "C" fn naked_empty() {
diff --git a/tests/codegen/naked-fn/min-function-alignment.rs b/tests/codegen/naked-fn/min-function-alignment.rs
index 1d778be8c90..59554c1cae5 100644
--- a/tests/codegen/naked-fn/min-function-alignment.rs
+++ b/tests/codegen/naked-fn/min-function-alignment.rs
@@ -16,7 +16,7 @@ pub extern "C" fn naked_no_explicit_align() {
 
 // CHECK: .balign 16
 #[no_mangle]
-#[repr(align(8))]
+#[align(8)]
 #[unsafe(naked)]
 pub extern "C" fn naked_lower_align() {
     core::arch::naked_asm!("ret")
@@ -24,7 +24,7 @@ pub extern "C" fn naked_lower_align() {
 
 // CHECK: .balign 32
 #[no_mangle]
-#[repr(align(32))]
+#[align(32)]
 #[unsafe(naked)]
 pub extern "C" fn naked_higher_align() {
     core::arch::naked_asm!("ret")
diff --git a/tests/ui/asm/naked-with-invalid-repr-attr.rs b/tests/ui/asm/naked-with-invalid-repr-attr.rs
index 96eed70dc55..bfbbf29a69e 100644
--- a/tests/ui/asm/naked-with-invalid-repr-attr.rs
+++ b/tests/ui/asm/naked-with-invalid-repr-attr.rs
@@ -19,8 +19,9 @@ extern "C" fn example2() {
     naked_asm!("")
 }
 
-#[repr(align(16), C)]
+#[repr(C)]
 //~^ ERROR attribute should be applied to a struct, enum, or union [E0517]
+#[align(16)]
 #[unsafe(naked)]
 extern "C" fn example3() {
     //~^ NOTE not a struct, enum, or union
diff --git a/tests/ui/asm/naked-with-invalid-repr-attr.stderr b/tests/ui/asm/naked-with-invalid-repr-attr.stderr
index f173a39e5bf..4eb4a4e5a04 100644
--- a/tests/ui/asm/naked-with-invalid-repr-attr.stderr
+++ b/tests/ui/asm/naked-with-invalid-repr-attr.stderr
@@ -23,10 +23,10 @@ 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:19
+  --> $DIR/naked-with-invalid-repr-attr.rs:22:8
    |
-LL |   #[repr(align(16), C)]
-   |                     ^
+LL |   #[repr(C)]
+   |          ^
 ...
 LL | / extern "C" fn example3() {
 LL | |
@@ -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:31:8
+  --> $DIR/naked-with-invalid-repr-attr.rs:32: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:31:11
+  --> $DIR/naked-with-invalid-repr-attr.rs:32: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:41:8
+  --> $DIR/naked-with-invalid-repr-attr.rs:42:8
    |
 LL |   #[repr(u8)]
    |          ^^
diff --git a/tests/ui/attributes/arg-error-issue-121425.stderr b/tests/ui/attributes/arg-error-issue-121425.stderr
index 6e71f15fdc8..1beb99b1703 100644
--- a/tests/ui/attributes/arg-error-issue-121425.stderr
+++ b/tests/ui/attributes/arg-error-issue-121425.stderr
@@ -1,9 +1,3 @@
-error[E0693]: incorrect `repr(align)` attribute format: `align` takes exactly one argument in parentheses
-  --> $DIR/arg-error-issue-121425.rs:16:8
-   |
-LL | #[repr(align())]
-   |        ^^^^^^^
-
 error[E0693]: incorrect `repr(align)` attribute format: `align` expects a literal integer as argument
   --> $DIR/arg-error-issue-121425.rs:4:14
    |
@@ -22,6 +16,12 @@ error[E0589]: invalid `repr(align)` attribute: not an unsuffixed integer
 LL | #[repr(align("str"))]
    |              ^^^^^
 
+error[E0693]: incorrect `repr(align)` attribute format: `align` takes exactly one argument in parentheses
+  --> $DIR/arg-error-issue-121425.rs:16:8
+   |
+LL | #[repr(align())]
+   |        ^^^^^^^
+
 error[E0552]: incorrect `repr(packed)` attribute format: `packed` expects a literal integer as argument
   --> $DIR/arg-error-issue-121425.rs:21:15
    |
diff --git a/tests/ui/attributes/invalid-repr.rs b/tests/ui/attributes/invalid-repr.rs
index 10a487c127e..d7933533405 100644
--- a/tests/ui/attributes/invalid-repr.rs
+++ b/tests/ui/attributes/invalid-repr.rs
@@ -1,5 +1,5 @@
 #[repr(align(16))]
-//~^ ERROR attribute should be applied to a struct, enum, function, associated function, or union
+//~^ ERROR attribute should be applied to a struct, enum, or union
 pub type Foo = i32;
 
 fn main() {}
diff --git a/tests/ui/attributes/invalid-repr.stderr b/tests/ui/attributes/invalid-repr.stderr
index 681460ad081..3f5a305c6b7 100644
--- a/tests/ui/attributes/invalid-repr.stderr
+++ b/tests/ui/attributes/invalid-repr.stderr
@@ -1,11 +1,11 @@
-error[E0517]: attribute should be applied to a struct, enum, function, associated function, or union
+error[E0517]: attribute should be applied to a struct, enum, or union
   --> $DIR/invalid-repr.rs:1:8
    |
 LL | #[repr(align(16))]
    |        ^^^^^^^^^
 LL |
 LL | pub type Foo = i32;
-   | ------------------- not a struct, enum, function, associated function, or union
+   | ------------------- not a struct, enum, or union
 
 error: aborting due to 1 previous error
 
diff --git a/tests/ui/attributes/malformed-fn-align.rs b/tests/ui/attributes/malformed-fn-align.rs
index 4aaad01b723..35ffd6d8acc 100644
--- a/tests/ui/attributes/malformed-fn-align.rs
+++ b/tests/ui/attributes/malformed-fn-align.rs
@@ -2,6 +2,21 @@
 #![crate_type = "lib"]
 
 trait MyTrait {
-    #[repr(align)] //~ ERROR invalid `repr(align)` attribute: `align` needs an argument
+    #[align] //~ ERROR malformed `align` attribute input
     fn myfun();
 }
+
+#[align = 16] //~ ERROR malformed `align` attribute input
+fn f1() {}
+
+#[align("hello")] //~ ERROR invalid alignment value: not an unsuffixed integer
+fn f2() {}
+
+#[align(0)] //~ ERROR invalid alignment value: not a power of two
+fn f3() {}
+
+#[repr(align(16))] //~ ERROR `#[repr(align(...))]` is not supported on function items
+fn f4() {}
+
+#[align(16)] //~ ERROR `#[align(...)]` is not supported on struct items
+struct S1;
diff --git a/tests/ui/attributes/malformed-fn-align.stderr b/tests/ui/attributes/malformed-fn-align.stderr
index 57913c48ef7..765255c2c3a 100644
--- a/tests/ui/attributes/malformed-fn-align.stderr
+++ b/tests/ui/attributes/malformed-fn-align.stderr
@@ -1,9 +1,66 @@
-error[E0589]: invalid `repr(align)` attribute: `align` needs an argument
-  --> $DIR/malformed-fn-align.rs:5:12
+error[E0539]: malformed `align` attribute input
+  --> $DIR/malformed-fn-align.rs:5:5
+   |
+LL |     #[align]
+   |     ^^^^^^^^ expected this to be a list
+   |
+help: try changing it to one of the following valid forms of the attribute
+   |
+LL |     #[align(<alignment in bytes>)]
+   |            ++++++++++++++++++++++
+
+error[E0539]: malformed `align` attribute input
+  --> $DIR/malformed-fn-align.rs:9:1
+   |
+LL | #[align = 16]
+   | ^^^^^^^^^^^^^ expected this to be a list
+   |
+help: try changing it to one of the following valid forms of the attribute
+   |
+LL - #[align = 16]
+LL + #[align(<alignment in bytes>)]
+   |
+LL - #[align = 16]
+LL + #[align]
+   |
+
+error[E0589]: invalid alignment value: not an unsuffixed integer
+  --> $DIR/malformed-fn-align.rs:12:9
+   |
+LL | #[align("hello")]
+   |         ^^^^^^^
+
+error[E0589]: invalid alignment value: not a power of two
+  --> $DIR/malformed-fn-align.rs:15:9
+   |
+LL | #[align(0)]
+   |         ^
+
+error: `#[repr(align(...))]` is not supported on function items
+  --> $DIR/malformed-fn-align.rs:18:8
+   |
+LL | #[repr(align(16))]
+   |        ^^^^^^^^^
+   |
+help: use `#[align(...)]` instead
+  --> $DIR/malformed-fn-align.rs:18:8
+   |
+LL | #[repr(align(16))]
+   |        ^^^^^^^^^
+
+error: `#[align(...)]` is not supported on struct items
+  --> $DIR/malformed-fn-align.rs:21:1
+   |
+LL | #[align(16)]
+   | ^^^^^^^^^^^^
+   |
+help: use `#[repr(align(...))]` instead
+   |
+LL - #[align(16)]
+LL + #[repr(align(16))]
    |
-LL |     #[repr(align)]
-   |            ^^^^^ help: supply an argument here: `align(...)`
 
-error: aborting due to 1 previous error
+error: aborting due to 6 previous errors
 
-For more information about this error, try `rustc --explain E0589`.
+Some errors have detailed explanations: E0539, E0589.
+For more information about an error, try `rustc --explain E0539`.
diff --git a/tests/ui/feature-gates/feature-gate-fn_align.rs b/tests/ui/feature-gates/feature-gate-fn_align.rs
index 744877704dd..b6c300e5cbe 100644
--- a/tests/ui/feature-gates/feature-gate-fn_align.rs
+++ b/tests/ui/feature-gates/feature-gate-fn_align.rs
@@ -1,9 +1,12 @@
 #![crate_type = "lib"]
 
-#[repr(align(16))] //~ ERROR `repr(align)` attributes on functions are unstable
+#[align(16)]
+//~^ ERROR the `#[align]` attribute is an experimental feature
 fn requires_alignment() {}
 
 trait MyTrait {
-    #[repr(align)] //~ ERROR invalid `repr(align)` attribute: `align` needs an argument
+    #[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
index ff17c29fe02..93ef136dc73 100644
--- a/tests/ui/feature-gates/feature-gate-fn_align.stderr
+++ b/tests/ui/feature-gates/feature-gate-fn_align.stderr
@@ -1,20 +1,35 @@
-error[E0589]: invalid `repr(align)` attribute: `align` needs an argument
-  --> $DIR/feature-gate-fn_align.rs:7:12
+error[E0658]: the `#[align]` attribute is an experimental feature
+  --> $DIR/feature-gate-fn_align.rs:3:1
    |
-LL |     #[repr(align)]
-   |            ^^^^^ help: supply an argument here: `align(...)`
+LL | #[align(16)]
+   | ^^^^^^^^^^^^
+   |
+   = note: see issue #82232 <https://github.com/rust-lang/rust/issues/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]: `repr(align)` attributes on functions are unstable
-  --> $DIR/feature-gate-fn_align.rs:3:8
+error[E0658]: the `#[align]` attribute is an experimental feature
+  --> $DIR/feature-gate-fn_align.rs:8:5
    |
-LL | #[repr(align(16))]
-   |        ^^^^^^^^^
+LL |     #[align]
+   |     ^^^^^^^^
    |
    = note: see issue #82232 <https://github.com/rust-lang/rust/issues/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: aborting due to 2 previous errors
+error[E0539]: malformed `align` attribute input
+  --> $DIR/feature-gate-fn_align.rs:8:5
+   |
+LL |     #[align]
+   |     ^^^^^^^^ expected this to be a list
+   |
+help: try changing it to one of the following valid forms of the attribute
+   |
+LL |     #[align(<alignment in bytes>)]
+   |            ++++++++++++++++++++++
+
+error: aborting due to 3 previous errors
 
-Some errors have detailed explanations: E0589, E0658.
-For more information about an error, try `rustc --explain E0589`.
+Some errors have detailed explanations: E0539, E0658.
+For more information about an error, try `rustc --explain E0539`.
diff --git a/tests/ui/repr/attr-usage-repr.rs b/tests/ui/repr/attr-usage-repr.rs
index cbf99f16e03..ca63ac564fc 100644
--- a/tests/ui/repr/attr-usage-repr.rs
+++ b/tests/ui/repr/attr-usage-repr.rs
@@ -45,7 +45,7 @@ enum EInt {
     B,
 }
 
-#[repr()] //~ ERROR attribute should be applied to a struct, enum, function, associated function, or union [E0517]
+#[repr()] //~ ERROR attribute should be applied to a struct, enum, or union [E0517]
 type SirThisIsAType = i32;
 
 #[repr()]
diff --git a/tests/ui/repr/attr-usage-repr.stderr b/tests/ui/repr/attr-usage-repr.stderr
index a25e68c483f..a62992c597a 100644
--- a/tests/ui/repr/attr-usage-repr.stderr
+++ b/tests/ui/repr/attr-usage-repr.stderr
@@ -36,13 +36,13 @@ LL | |     B,
 LL | | }
    | |_- not a struct
 
-error[E0517]: attribute should be applied to a struct, enum, function, associated function, or union
+error[E0517]: attribute should be applied to a struct, enum, or union
   --> $DIR/attr-usage-repr.rs:48:1
    |
 LL | #[repr()]
    | ^^^^^^^^^
 LL | type SirThisIsAType = i32;
-   | -------------------------- not a struct, enum, function, associated function, or union
+   | -------------------------- not a struct, enum, or union
 
 error: aborting due to 5 previous errors
 
diff --git a/tests/ui/repr/malformed-repr-hints.stderr b/tests/ui/repr/malformed-repr-hints.stderr
index 7a6e9ccc73e..6fb92755761 100644
--- a/tests/ui/repr/malformed-repr-hints.stderr
+++ b/tests/ui/repr/malformed-repr-hints.stderr
@@ -1,15 +1,3 @@
-error[E0693]: incorrect `repr(align)` attribute format: `align` takes exactly one argument in parentheses
-  --> $DIR/malformed-repr-hints.rs:14:8
-   |
-LL | #[repr(align(2, 4))]
-   |        ^^^^^^^^^^^
-
-error[E0693]: incorrect `repr(align)` attribute format: `align` takes exactly one argument in parentheses
-  --> $DIR/malformed-repr-hints.rs:18:8
-   |
-LL | #[repr(align())]
-   |        ^^^^^^^
-
 error[E0552]: incorrect `repr(packed)` attribute format: `packed` takes exactly one parenthesized argument, or no parentheses at all
   --> $DIR/malformed-repr-hints.rs:6:8
    |
@@ -22,6 +10,18 @@ error[E0589]: invalid `repr(align)` attribute: `align` needs an argument
 LL | #[repr(align)]
    |        ^^^^^ help: supply an argument here: `align(...)`
 
+error[E0693]: incorrect `repr(align)` attribute format: `align` takes exactly one argument in parentheses
+  --> $DIR/malformed-repr-hints.rs:14:8
+   |
+LL | #[repr(align(2, 4))]
+   |        ^^^^^^^^^^^
+
+error[E0693]: incorrect `repr(align)` attribute format: `align` takes exactly one argument in parentheses
+  --> $DIR/malformed-repr-hints.rs:18:8
+   |
+LL | #[repr(align())]
+   |        ^^^^^^^
+
 error[E0552]: invalid representation hint: `Rust` does not take a parenthesized argument list
   --> $DIR/malformed-repr-hints.rs:23:8
    |