Repository navigation
Tracking Issue for #[align(...)] on function items (fn_align) #82232
Description
Activity
- addedC-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCCategory: An issue tracking the progress of sth. like the implementation of an RFC
on Feb 17, 2021 - changed the title
[-]Tracking Issue for `#[repr(align = ...)]` on function items (fn_align)[/-][+]Tracking Issue for `#[repr(align(...))]` on function items (fn_align)[/+]on Feb 17, 2021 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 errorReacted by Esteban Blanc, Bennet Bleßmann, Diana and yvtI 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 👍
Reacted by Alex Martens, Ofek Shochat and Evan RichterThanks 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.
- addedA-rust-for-linuxRelevant for the Rust-for-Linux projectRelevant for the Rust-for-Linux project
on Aug 8, 2024 - added a commit that references this issue
on Aug 28, 2024 - addedA-alignArea: alignment control (`repr(align(N))` and so on)Area: alignment control (`repr(align(N))` and so on)F-fn_align`#![feature(fn_align)]``#![feature(fn_align)]`and removedF-fn_align`#![feature(fn_align)]``#![feature(fn_align)]`
on Nov 1, 2024 39 remaining items
- added a commit that references this issue
on Jun 23, 2025 - added a commit that references this issue
on Jun 24, 2025 - added a commit that references this issue
on Jun 26, 2025 The PR description here is outdated, right? Could someone familiar with the feature update it?
- changed the title
[-]Tracking Issue for `#[repr(align(...))]` on function items (fn_align)[/-][+]Tracking Issue for `#[align(...)]` on function items (fn_align)[/+]on Jul 3, 2025 - addedS-tracking-needs-summaryStatus: It's hard to tell what's been done and what hasn't! Someone should do some investigation.Status: It's hard to tell what's been done and what hasn't! Someone should do some investigation.
on Jul 21, 2025 For the record, there is a new LLVM RFC related to function alignment that may interact with this feature: https://discourse.llvm.org/t/rfc-enhancing-function-alignment-attributes/88019
Reacted by Mateusz Mikuła, Jules Bertholet and JubileeFor the record, there is a new LLVM RFC related to function alignment that may interact with this feature: https://discourse.llvm.org/t/rfc-enhancing-function-alignment-attributes/88019
With that RFC, the Rust
alignattribute would correspond with LLVMminalign, I believe.LLVM apparently backed out the
align->minalignchange and the author is proposing adding a newprefalignattribute for that.Reacted by Alex, Jules Bertholet and Francisco BoniFor those who try to use it, the current syntax is
#[rustc_align(N)], not#[align(N)].#[align(N)]simply errors, while#[repr(align(N))]suggests#[rustc_align(N)].Please update the first comment.
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
fn_align:#[align(N)]on functions #140261Blocking issues