File tree 2 files changed +18
-3
lines changed
compiler/rustc_ty_utils/src
tests/ui/async-await/async-closures 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>(
321
321
collector. collect_taits_declared_in_body ( ) ;
322
322
}
323
323
// 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 => {
325
328
collector. opaques . extend ( tcx. opaque_types_defined_by ( tcx. local_parent ( item) ) ) ;
326
329
}
327
330
DefKind :: AssocTy | DefKind :: TyAlias | DefKind :: GlobalAsm => { }
@@ -343,8 +346,7 @@ fn opaque_types_defined_by<'tcx>(
343
346
| DefKind :: ForeignMod
344
347
| DefKind :: Field
345
348
| DefKind :: LifetimeParam
346
- | DefKind :: Impl { .. }
347
- | DefKind :: SyntheticCoroutineBody => {
349
+ | DefKind :: Impl { .. } => {
348
350
span_bug ! (
349
351
tcx. def_span( item) ,
350
352
"`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