Skip to content

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

Merged
rust-bors[bot] merged 3 commits into
rust-lang:mainfrom
cjgillot:init-kind
Nov 8, 2026
Merged

rust-bors[bot] merged 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
@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

This comment has been minimized.

@rust-bors

This comment has been minimized.

@Amanieu

Amanieu commented Oct 20, 2026

Copy link
Copy Markdown
Member

r=me once conflicts are resolved

@Amanieu Amanieu assigned Amanieu and unassigned wesleywiser Oct 20, 2026
@Amanieu Amanieu added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 23, 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.
@rustbot

rustbot commented Nov 8, 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.

@cjgillot

cjgillot commented Nov 8, 2026

Copy link
Copy Markdown
Contributor Author

@bors r=Amanieu

@rust-bors

rust-bors Bot commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 834e5b6 has been approved by Amanieu

It is now in the queue for this repository.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Nov 8, 2026
rust-bors Bot pushed a commit that referenced this pull request Nov 8, 2026
Document and correct assignment order for yield and inline-asm

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.
@rust-bors

rust-bors Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

⌛ Testing commit 834e5b6 with merge 965c405...

Workflow: https://github.com/rust-lang/rust/actions/runs/42514271926

@JonathanBrouwer

Copy link
Copy Markdown
Member

@bors yield
Yielding to enclosing rollup

@rust-bors

rust-bors Bot commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

Auto build was cancelled. Cancelled workflows:

The next pull request likely to be tested is #165659.

rust-bors Bot pushed a commit that referenced this pull request Nov 8, 2026
…uwer

Rollup of 7 pull requests

Successful merges:

 - #160777 (Document and correct assignment order for yield and inline-asm)
 - #165224 (Ensure all output is printed from lldb debugger tester)
 - #165629 (std: fix build on RTEMS after libc 0.2.191)
 - #163624 (String::retain: convert only the untouched UTF-8 tail)
 - #164519 (Add Documentation for the `crate_type` attribute)
 - #165249 (Fix unused attribute duplication for lint attributes)
 - #165643 (oneshot_multi_task_recv_then_send test: wait for test thread to finish)
@rust-bors
rust-bors Bot merged commit ae168ee into rust-lang:main Nov 8, 2026
14 of 15 checks passed
rust-bors Bot pushed a commit that referenced this pull request Nov 8, 2026
Rollup merge of #160777 - cjgillot:init-kind, r=Amanieu

Document and correct assignment order for yield and inline-asm

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.
@rustbot rustbot added this to the 1.102.0 milestone Nov 8, 2026
@cjgillot
cjgillot deleted the init-kind branch November 9, 2026 23:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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.

7 participants