Open repnop opened 3 years ago
Is it be possible to apply this to methods as well?
#![feature(fn_align)]
#[repr(align(1))]
fn main() {
Bar::foo();
}
struct Bar;
impl Bar {
#[repr(align(1))]
fn foo() {
println!("bar");
}
}
error[E0517]: attribute should be applied to a struct, enum, function, or union
--> src/main.rs:11:12
|
11 | #[repr(align(1))]
| ^^^^^^^^
12 | / fn foo() {
13 | | println!("bar");
14 | | }
| |_____- not a struct, enum, function, or union
For more information about this error, try `rustc --explain E0517`.
error: could not compile `asdf` due to previous error
I don't see why not? (I'm surprised it doesn't work already honestly lol) I'll see if I can find some time to investigate that and make another PR to allow that 👍
Thanks for opening this, I just bumped my head into this exact problem as well!
This should come with a command-line flag to address the request made in #128830 for global code alignment control.
This feature allows specifying an alignment for function items by adding the
#[repr(align(...))]
attribute to them. The feature gate for the issue is#![feature(fn_align)]
Example
Steps