rust-lang / rust-lang/rust

cleanup quasi-layout alignment computations

Open
#147,107 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

C-cleanup T-compiler
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

Originally posted by @scottmcm in https://github.com/rust-lang/rust/issues/145419#issuecomment-3303649594:

I do think that, from an implementation perspective, it's a bit icky for this particular check to do this dance of "fail to get layout, then do extra layout calculations". It feels like there ought to be a general query for "layout but I only care about alignment (or an under- or over-estimate thereof)" that everywhere that doesn't care about things like niches and field offsets, just the alignment, could use so that checks like this would always be consistent. (Like const prop of the Align UnOp in a MIR optimization arguably wants this as well.)

This is a common pattern in cases in the compiler where we want to compute an alignment relative to T. Normally this involves computing the layout of T, but sometimes we don't know exactly what T's layout would be because of some other variable Q which is indeterminate but only affects size, not alignment. So instead we compute the alignment of U, where the question about T's alignment would logically depend on U.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the compiler checks that compute alignment relative to a type, including the cited MIR optimization for the Align UnOp. Compare cases where layout fails because size depends on an indeterminate type with cases that only need alignment. Done should be a decided general alignment query and consistent use of it, but the issue does not identify files or tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.