Allow specifying alignment for functions
This commit is contained in:
parent
138fd56cf9
commit
448d07683a
18 changed files with 137 additions and 83 deletions
9
src/test/codegen/align-fn.rs
Normal file
9
src/test/codegen/align-fn.rs
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
// compile-flags: -C no-prepopulate-passes -Z mir-opt-level=0
|
||||
|
||||
#![crate_type = "lib"]
|
||||
#![feature(fn_align)]
|
||||
|
||||
// CHECK: align 16
|
||||
#[no_mangle]
|
||||
#[repr(align(16))]
|
||||
pub fn fn_align() {}
|
||||
|
|
@ -3,7 +3,6 @@
|
|||
macro_rules! pass_nonterminal {
|
||||
($n:expr) => {
|
||||
#[repr(align($n))] //~ ERROR expected unsuffixed literal or identifier, found `n!()`
|
||||
//~| ERROR unrecognized representation hint
|
||||
struct S;
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,17 +9,5 @@ LL | pass_nonterminal!(n!());
|
|||
|
|
||||
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error[E0552]: unrecognized representation hint
|
||||
--> $DIR/nonterminal-expansion.rs:5:16
|
||||
|
|
||||
LL | #[repr(align($n))]
|
||||
| ^^^^^^^^^
|
||||
...
|
||||
LL | pass_nonterminal!(n!());
|
||||
| ------------------------ in this macro invocation
|
||||
|
|
||||
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
error: aborting due to previous error
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0552`.
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
// repr currently doesn't support literals
|
||||
#[repr("C")] //~ ERROR E0565
|
||||
//~| ERROR E0565
|
||||
struct A { }
|
||||
struct A {}
|
||||
|
||||
fn main() { }
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -4,12 +4,6 @@ error[E0565]: meta item in `repr` must be an identifier
|
|||
LL | #[repr("C")]
|
||||
| ^^^
|
||||
|
||||
error[E0565]: meta item in `repr` must be an identifier
|
||||
--> $DIR/E0565.rs:2:8
|
||||
|
|
||||
LL | #[repr("C")]
|
||||
| ^^^
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0565`.
|
||||
|
|
|
|||
4
src/test/ui/feature-gates/feature-gate-fn_align.rs
Normal file
4
src/test/ui/feature-gates/feature-gate-fn_align.rs
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
#![crate_type = "lib"]
|
||||
|
||||
#[repr(align(16))] //~ ERROR `repr(align)` attributes on functions are unstable
|
||||
fn requires_alignment() {}
|
||||
12
src/test/ui/feature-gates/feature-gate-fn_align.stderr
Normal file
12
src/test/ui/feature-gates/feature-gate-fn_align.stderr
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
error[E0658]: `repr(align)` attributes on functions are unstable
|
||||
--> $DIR/feature-gate-fn_align.rs:3:8
|
||||
|
|
||||
LL | #[repr(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
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0658`.
|
||||
|
|
@ -13,13 +13,13 @@ fn main() {
|
|||
|
||||
#[repr(nothing)]
|
||||
let _x = 0;
|
||||
//~^^ ERROR attribute should be applied to a struct, enum, or union
|
||||
//~^^ ERROR E0552
|
||||
|
||||
#[repr(something_not_real)]
|
||||
loop {
|
||||
()
|
||||
};
|
||||
//~^^^^ ERROR attribute should be applied to a struct, enum, or union
|
||||
//~^^^^ ERROR E0552
|
||||
|
||||
#[repr]
|
||||
let _y = "123";
|
||||
|
|
|
|||
|
|
@ -26,23 +26,17 @@ LL | #[inline(XYZ)]
|
|||
LL | let _b = 4;
|
||||
| ----------- not a function or closure
|
||||
|
||||
error[E0517]: attribute should be applied to a struct, enum, or union
|
||||
error[E0552]: unrecognized representation hint
|
||||
--> $DIR/issue-43988.rs:14:12
|
||||
|
|
||||
LL | #[repr(nothing)]
|
||||
| ^^^^^^^
|
||||
LL | let _x = 0;
|
||||
| ----------- not a struct, enum, or union
|
||||
|
||||
error[E0517]: attribute should be applied to a struct, enum, or union
|
||||
error[E0552]: unrecognized representation hint
|
||||
--> $DIR/issue-43988.rs:18:12
|
||||
|
|
||||
LL | #[repr(something_not_real)]
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
LL | / loop {
|
||||
LL | | ()
|
||||
LL | | };
|
||||
| |_____- not a struct, enum, or union
|
||||
LL | #[repr(something_not_real)]
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0518]: attribute should be applied to function or closure
|
||||
--> $DIR/issue-43988.rs:30:5
|
||||
|
|
@ -54,5 +48,5 @@ LL | foo();
|
|||
|
||||
error: aborting due to 7 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0517, E0518.
|
||||
For more information about an error, try `rustc --explain E0517`.
|
||||
Some errors have detailed explanations: E0518, E0552.
|
||||
For more information about an error, try `rustc --explain E0518`.
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ struct Test;
|
|||
|
||||
enum Foo {
|
||||
#[repr(u8)]
|
||||
//~^ ERROR attribute should be applied to a struct, enum, or union
|
||||
//~^ ERROR attribute should be applied to an enum
|
||||
Variant,
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
error[E0517]: attribute should be applied to a struct, enum, or union
|
||||
error[E0517]: attribute should be applied to an enum
|
||||
--> $DIR/repr-disallow-on-variant.rs:4:12
|
||||
|
|
||||
LL | #[repr(u8)]
|
||||
| ^^
|
||||
LL |
|
||||
LL | Variant,
|
||||
| ------- not a struct, enum, or union
|
||||
| ------- not an enum
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue