diff options
| author | Michael Goulet <michael@errs.io> | 2025-05-26 12:19:34 +0000 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2025-05-26 12:19:34 +0000 |
| commit | 5e31cd30aae245aaa1374e12521667b8c728402d (patch) | |
| tree | d4e12cb04a7217bd8b5a8dc9bef81ce353d2dfbd /compiler/rustc_ty_utils/src | |
| parent | 95a2212587f1b8500af1ac630322b0cb2e030c61 (diff) | |
Support opaque_types_defined_by for SyntheticCoroutineBody
Diffstat (limited to 'compiler/rustc_ty_utils/src')
| -rw-r--r-- | compiler/rustc_ty_utils/src/opaque_types.rs | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/compiler/rustc_ty_utils/src/opaque_types.rs b/compiler/rustc_ty_utils/src/opaque_types.rs index 841f602d985..3b4482146d4 100644 --- a/compiler/rustc_ty_utils/src/opaque_types.rs +++ b/compiler/rustc_ty_utils/src/opaque_types.rs @@ -321,7 +321,10 @@ fn opaque_types_defined_by<'tcx>( collector.collect_taits_declared_in_body(); } // Closures and coroutines are type checked with their parent - DefKind::Closure | DefKind::InlineConst => { + // Note that we also support `SyntheticCoroutineBody` since we create + // a MIR body for the def kind, and some MIR passes (like promotion) + // may require doing analysis using its typing env. + DefKind::Closure | DefKind::InlineConst | DefKind::SyntheticCoroutineBody => { collector.opaques.extend(tcx.opaque_types_defined_by(tcx.local_parent(item))); } DefKind::AssocTy | DefKind::TyAlias | DefKind::GlobalAsm => {} @@ -343,8 +346,7 @@ fn opaque_types_defined_by<'tcx>( | DefKind::ForeignMod | DefKind::Field | DefKind::LifetimeParam - | DefKind::Impl { .. } - | DefKind::SyntheticCoroutineBody => { + | DefKind::Impl { .. } => { span_bug!( tcx.def_span(item), "`opaque_types_defined_by` not defined for {} `{item:?}`", |
