Skip to content

Rename align to default_align on Scalar and Primitive#158542

Open
scottmcm wants to merge 2 commits into
rust-lang:mainfrom
scottmcm:scalar-but-packed
Open

Rename align to default_align on Scalar and Primitive#158542
scottmcm wants to merge 2 commits into
rust-lang:mainfrom
scottmcm:scalar-but-packed

Conversation

@scottmcm

Copy link
Copy Markdown
Member

To emphasize that just because you see a Scalar(I32) that doesn't really tell you anything about the alignment it has -- one should be looking at the type (well, the place) for that.

(The size method doesn't really have that problem -- i32 is always 4 bytes, no matter the context -- so is left untouched.)

No actual layout or behaviour changes in this PR. Just the rename and some comments.

r? @workingjubilee

@rustbot

rustbot commented Jun 29, 2026

Copy link
Copy Markdown
Collaborator

Some changes occurred to the CTFE / Miri interpreter

cc @rust-lang/miri

rustc_codegen_gcc is developed in its own repository. If possible, consider making this change to rust-lang/rustc_codegen_gcc instead.

cc @antoyo, @GuillaumeGomez

Some changes occurred to MIR optimizations

cc @rust-lang/wg-mir-opt

Some changes occurred to the CTFE machinery

cc @RalfJung, @oli-obk, @lcnr

rustc_codegen_cranelift is developed in its own repository. If possible, consider making this change to rust-lang/rustc_codegen_cranelift instead.

cc @bjorn3

@rustbot rustbot added A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jun 29, 2026
@rustbot

rustbot commented Jun 29, 2026

Copy link
Copy Markdown
Collaborator

workingjubilee is currently at their maximum review capacity.
They may take a while to respond.

@rust-log-analyzer

This comment has been minimized.

@scottmcm scottmcm force-pushed the scalar-but-packed branch from 4edeed7 to 2aaf9e0 Compare June 29, 2026 06:59
@rustbot

rustbot commented Jun 29, 2026

Copy link
Copy Markdown
Collaborator

miri is developed in its own repository. If possible, consider making this change to rust-lang/miri instead.

cc @rust-lang/miri

Comment thread compiler/rustc_abi/src/lib.rs Outdated
///
/// This is the type alignment for the corresponding built-in.
/// In other contexts it might have different alignment.
pub fn platform_align<C: HasDataLayout>(self, cx: &C) -> AbiAlign {

@RalfJung RalfJung Jun 29, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Naming bikeshed: what about default_align?

View changes since the review

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good -- better conveys "might not the the default" elsewhere than "platform" does since of course we're always targeting just one platform.

Comment thread compiler/rustc_abi/src/lib.rs Outdated
Comment thread compiler/rustc_abi/src/lib.rs Outdated
To emphasize that just because you see a `Scalar(I32)` that doesn't really tell you anything about the alignment it has -- one should be looking at the type (well, the place) for that.

No actual layout or behaviour changes in *this* PR.
@scottmcm scottmcm force-pushed the scalar-but-packed branch from 2aaf9e0 to f98365f Compare June 29, 2026 16:48
@scottmcm scottmcm changed the title Rename align to platform_align on Scalar and Primitive Rename align to default_align on Scalar and Primitive Jun 29, 2026
Co-authored-by: Ralf Jung <post@ralfj.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants