Skip to content

Support opaque_types_defined_by for SyntheticCoroutineBody #141584

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 27, 2025

Conversation

compiler-errors
Copy link
Member

@compiler-errors compiler-errors commented May 26, 2025

We create a synthetic MIR body for the AsyncFnOnce impl for async closures. That body goes through all passes that a regular body does, including promotion.

Promotion sometimes requires computing that the type of an rvalue is Freeze, which requires computing the typing env of a body. This requires calling opaque_types_defined_by on the body's def id, which leads to an ICE today since we don't expect that query to be called for synthetic bodies.

While we could fix this by, for example, computing the typeck root of the body before calling a TypingEnv constructor, I think it's appropriate to do a more general fix here since I think it's reasonable that other passes might do analysis too.

Fixes #141466

r? @lcnr or @oli-obk

@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 May 26, 2025
@lcnr
Copy link
Contributor

lcnr commented May 26, 2025

@bors r+ rollup

@bors
Copy link
Collaborator

bors commented May 26, 2025

📌 Commit 5e31cd3 has been approved by lcnr

It is now in the queue for this repository.

@bors bors 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-review Status: Awaiting review from the assignee but also interested parties. labels May 26, 2025
jieyouxu added a commit to jieyouxu/rust that referenced this pull request May 26, 2025
…ic-body, r=lcnr

Support `opaque_types_defined_by` for `SyntheticCoroutineBody`

We create a synthetic MIR body for the `AsyncFnOnce` impl for async closures. That body goes through all passes that a regular body does, including promotion.

Promotion sometimes requires computing that the type of an rvalue is `Freeze`, which requires computing the typing env of a body. This requires calling `opaque_types_defined_by` on the body's def id, which leads to an ICE today since we don't expect that query to be called for synthetic bodies.

While we could fix this by, for example, computing the typeck root of the body before calling a `TypingEnv` constructor, I think it's appropriate to do a more general fix here since I think it's reasonable that other passes might do analysis too.

Fixes rust-lang#141466

r? `@lcnr` or `@oli-obk`
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request May 27, 2025
…ic-body, r=lcnr

Support `opaque_types_defined_by` for `SyntheticCoroutineBody`

We create a synthetic MIR body for the `AsyncFnOnce` impl for async closures. That body goes through all passes that a regular body does, including promotion.

Promotion sometimes requires computing that the type of an rvalue is `Freeze`, which requires computing the typing env of a body. This requires calling `opaque_types_defined_by` on the body's def id, which leads to an ICE today since we don't expect that query to be called for synthetic bodies.

While we could fix this by, for example, computing the typeck root of the body before calling a `TypingEnv` constructor, I think it's appropriate to do a more general fix here since I think it's reasonable that other passes might do analysis too.

Fixes rust-lang#141466

r? ``@lcnr`` or ``@oli-obk``
bors added a commit that referenced this pull request May 27, 2025
…rors

Rollup of 17 pull requests

Successful merges:

 - #140591 (Fix malformed suggestion for E0061 when method is a macro token in macro context)
 - #141536 (Improve `ambiguous_wide_pointer_comparisons` lint compare diagnostics)
 - #141552 (Pull out dedicated `cfg_version` syntax test from feature gate test)
 - #141556 (bootstrap: translate Windows paths in a way that works for both Cygwin and MSYS2)
 - #141563 (Remove out-of-date `noop_*` names.)
 - #141568 (dist: make sure llvm-project submodule is present)
 - #141580 (Use more detailed spans in dyn compat errors within bodies)
 - #141582 (intrinsics, ScalarInt: minor cleanup)
 - #141584 (Support `opaque_types_defined_by` for `SyntheticCoroutineBody`)
 - #141587 (Add missing edition directives for async-await tests)
 - #141594 (Add `generic_arg_infer` test)
 - #141596 (rustc book: fix erratic sentence by making it more simple)
 - #141599 (Remove an unnecessary use of `Box::into_inner`.)
 - #141611 (Update mdbook to 0.4.51)
 - #141616 (Remove spastorino from vacations)
 - #141623 (use custom types to clarify arguments to `emit_ptr_va_arg`)
 - #141635 (further dedup `WalkItemKind` for `mut_visit` and `visit`)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 9d46af1 into rust-lang:master May 27, 2025
7 checks passed
@rustbot rustbot added this to the 1.89.0 milestone May 27, 2025
bors added a commit that referenced this pull request May 27, 2025
Rollup of 8 pull requests

Successful merges:

 - #141584 (Support `opaque_types_defined_by` for `SyntheticCoroutineBody`)
 - #141587 (Add missing edition directives for async-await tests)
 - #141594 (Add `generic_arg_infer` test)
 - #141596 (rustc book: fix erratic sentence by making it more simple)
 - #141599 (Remove an unnecessary use of `Box::into_inner`.)
 - #141611 (Update mdbook to 0.4.51)
 - #141616 (Remove spastorino from vacations)
 - #141623 (use custom types to clarify arguments to `emit_ptr_va_arg`)

r? `@ghost`
`@rustbot` modify labels: rollup
rust-timer added a commit that referenced this pull request May 27, 2025
Rollup merge of #141584 - compiler-errors:typing-env-synthetic-body, r=lcnr

Support `opaque_types_defined_by` for `SyntheticCoroutineBody`

We create a synthetic MIR body for the `AsyncFnOnce` impl for async closures. That body goes through all passes that a regular body does, including promotion.

Promotion sometimes requires computing that the type of an rvalue is `Freeze`, which requires computing the typing env of a body. This requires calling `opaque_types_defined_by` on the body's def id, which leads to an ICE today since we don't expect that query to be called for synthetic bodies.

While we could fix this by, for example, computing the typeck root of the body before calling a `TypingEnv` constructor, I think it's appropriate to do a more general fix here since I think it's reasonable that other passes might do analysis too.

Fixes #141466

r? ```@lcnr``` or ```@oli-obk```
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.

ICE: opaque_types_defined_by not defined for synthetic mir body
4 participants