Skip to content

cleanup quasi-layout alignment computations #147107

@workingjubilee

Description

@workingjubilee

Originally posted by @scottmcm in #145419 (comment):

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-cleanupCategory: PRs that clean code up or issues documenting cleanup.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions