Skip to content

Document and correct assignment order for yield and inline-asm - #160777

Open
cjgillot wants to merge 3 commits into
rust-lang:mainfrom
cjgillot:init-kind
Open

Document and correct assignment order for yield and inline-asm#160777
cjgillot wants to merge 3 commits into
rust-lang:mainfrom
cjgillot:init-kind

Conversation

@cjgillot

@cjgillot cjgillot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

The first two commits cleanup and rename the variants of InitKind.

The third commit attempts to make several parts of MIR analyses a bit more consistent.

For calls, we correctly model assignments to happen on the return edge.

For yields, assignments also happen on the return edge according to dataflow analyses (see TerminatorEdges), but were considered unconditional. This should not change anything, as nobody uses droppable types as coroutine resume argument.

For inline_asm, same thing, dataflow analyses consider assignments to happen on targets and not on unwind. This is also corrected. I have no idea what's the impact of this. I suppose user wisely avoid to assign droppable types in inline asm that may unwind.

  • I did not use an LLM to create a change in this PR.
  • I used an LLM to create a change in this PR, and I have explained below how it was used.

@rustbot

rustbot commented Aug 8, 2026

Copy link
Copy Markdown
Collaborator

This PR changes MIR

cc @oli-obk, @RalfJung, @JakobDegen, @vakaras

@rustbot rustbot added 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 Aug 8, 2026
@rustbot

rustbot commented Aug 8, 2026

Copy link
Copy Markdown
Collaborator

r? @mu001999

rustbot has assigned @mu001999.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler
  • compiler expanded to 75 candidates
  • Random selection from 19 candidates

/// The operands for the inline assembly, as `Operand`s or `Place`s.
///
/// For the purposes of MIR analyzes, `out` and `inout` operands are only considered
/// written-to when execution continues with `targets`.

@RalfJung RalfJung Aug 9, 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.

I don't understand this comment, which confusion is it trying to avoid?

View changes since the review

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I want to convey that out and inout operands in inline asm work the same way. MIR analyses consider they are only written-to if the asm does not unwind.

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.

Suggested change
/// written-to when execution continues with `targets`.
/// written-to when execution continues with `targets`, but not when the asm unwinds.

Doesn't that mean "it is UB to write to these if the asm ends up unwinding rather than continuing with one of the targets"? That seems more clear to me than talking about this in terms of what analyses do.

@RalfJung

RalfJung commented Aug 9, 2026

Copy link
Copy Markdown
Member

Document and correct assignment order for yield and inline-asm

There are no docs changes for yields that I can find, so the docs were already correct there?

@mu001999

Copy link
Copy Markdown
Member

r? RalfJung

@rustbot rustbot assigned RalfJung and unassigned mu001999 Aug 10, 2026
@rustbot

rustbot commented Aug 10, 2026

Copy link
Copy Markdown
Collaborator

RalfJung is not on the review rotation at the moment.
They may take a while to respond.

@RalfJung

RalfJung commented Aug 10, 2026 via email

Copy link
Copy Markdown
Member

@rustbot rustbot assigned wesleywiser and unassigned RalfJung Aug 10, 2026
This variant is never constructed.
For `yield` this is not a problem, as nobody uses droppable types a
coroutine resume argument.

For `inline_asm`, it is delicate to gauge the effect.
@cjgillot

Copy link
Copy Markdown
Contributor Author

Document and correct assignment order for yield and inline-asm

There are no docs changes for yields that I can find, so the docs were already correct there?

Yes. I changed them in #156875

@rustbot

rustbot commented Aug 16, 2026

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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