-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-alignArea: alignment control (`repr(align(N))` and so on)Area: alignment control (`repr(align(N))` and so on)A-reprArea: the `#[repr(stuff)]` attributeArea: the `#[repr(stuff)]` attributeC-bugCategory: This is a bug.Category: This is a bug.F-fn_align`#![feature(fn_align)]``#![feature(fn_align)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
This code specifies two alignments, but applies none. A single align(256)
does work
#![feature(fn_align)]
#[repr(align(256), align(256))]
pub fn main() {
let ptr = main as *const u8;
println!("{ptr:?}");
assert_eq!(ptr.align_offset(256), 0);
}
CC: #82232
The culprit is this line here matching on slices of length 1:
rust/compiler/rustc_codegen_ssa/src/codegen_attrs.rs
Lines 418 to 420 in 145f9cf
codegen_fn_attrs.alignment = if let Some(items) = attr.meta_item_list() | |
&& let [item] = items.as_slice() | |
&& let Some((sym::align, literal)) = item.singleton_lit_list() |
It's a one line fix, but honestly this is trivially resolved with rust-lang/compiler-team#796 which I'm working on. I'll make it a separate PR at some point, but I'll assign myself since it makes sure changes conflict a little less :)
@rustbot claim
m-ou-se
Metadata
Metadata
Assignees
Labels
A-alignArea: alignment control (`repr(align(N))` and so on)Area: alignment control (`repr(align(N))` and so on)A-reprArea: the `#[repr(stuff)]` attributeArea: the `#[repr(stuff)]` attributeC-bugCategory: This is a bug.Category: This is a bug.F-fn_align`#![feature(fn_align)]``#![feature(fn_align)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.