-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
CG Backends should validate Call types more strictly #105487
Copy link
Copy link
Open
Labels
A-codegenArea: Code generationArea: Code generationA-testsuiteArea: The testsuite used to check the correctness of rustcArea: The testsuite used to check the correctness of rustcC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.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.
Metadata
Metadata
Assignees
Labels
A-codegenArea: Code generationArea: Code generationA-testsuiteArea: The testsuite used to check the correctness of rustcArea: The testsuite used to check the correctness of rustcC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.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.
Type
Fields
Give feedbackNo fields configured for issues without a type.
In #104321, I bent the compilers rules a bit, both intentionally and not, in particular:
Up until #105250, the function generated for
Future::pollwas usingResumeTyinstead of&mut Context<'_>for its argument. This was fine asResumeTywas just a newtype wrapper around*const Context, so both are just pointers. Though @bjorn3 pointed out, this could have started randomly failing when using-Zrandomize-layout. Driveby question: Would#[repr(transparent)]have provided stronger guarantees here?The second case, fixed by #105082, was a mismatched return type. The change in #104321 correctly changed the generated MIR to output (and write to)
Poll. Though theFnAbiwas unchanged and still referring to aGeneratorState.This was seemingly fine as both happened to have the same size and alignment.
Callers were assuming a
Poll, MIR was outputting aPoll. But theFnAbiwas advertising aGeneratorStateerronously.As discovered by @bjorn3 in #104321 (comment),
cg_clifdoes a more stricter validation of the call arguments and return values in the codegen backend, which the other backends evidently did not do.They probably should.
CC @compiler-errors @oli-obk