File tree Expand file tree Collapse file tree 2 files changed +18
-3
lines changed
compiler/rustc_ty_utils/src
tests/ui/async-await/async-closures Expand file tree Collapse file tree 2 files changed +18
-3
lines changed Original file line number Diff line number Diff line change @@ -321,7 +321,10 @@ fn opaque_types_defined_by<'tcx>(
321321 collector. collect_taits_declared_in_body ( ) ;
322322 }
323323 // Closures and coroutines are type checked with their parent
324- DefKind :: Closure | DefKind :: InlineConst => {
324+ // Note that we also support `SyntheticCoroutineBody` since we create
325+ // a MIR body for the def kind, and some MIR passes (like promotion)
326+ // may require doing analysis using its typing env.
327+ DefKind :: Closure | DefKind :: InlineConst | DefKind :: SyntheticCoroutineBody => {
325328 collector. opaques . extend ( tcx. opaque_types_defined_by ( tcx. local_parent ( item) ) ) ;
326329 }
327330 DefKind :: AssocTy | DefKind :: TyAlias | DefKind :: GlobalAsm => { }
@@ -343,8 +346,7 @@ fn opaque_types_defined_by<'tcx>(
343346 | DefKind :: ForeignMod
344347 | DefKind :: Field
345348 | DefKind :: LifetimeParam
346- | DefKind :: Impl { .. }
347- | DefKind :: SyntheticCoroutineBody => {
349+ | DefKind :: Impl { .. } => {
348350 span_bug ! (
349351 tcx. def_span( item) ,
350352 "`opaque_types_defined_by` not defined for {} `{item:?}`" ,
Original file line number Diff line number Diff line change 1+ //@ build-pass
2+ //@ compile-flags: --crate-type=lib
3+ //@ edition: 2024
4+
5+ union U {
6+ f : i32 ,
7+ }
8+
9+ fn foo ( ) {
10+ async || {
11+ & U { f : 1 }
12+ } ;
13+ }
You can’t perform that action at this time.
0 commit comments