File tree 2 files changed +24
-3
lines changed
compiler/rustc_mir_transform/src/coroutine
tests/ui/async-await/async-closures
2 files changed +24
-3
lines changed Original file line number Diff line number Diff line change @@ -156,9 +156,6 @@ impl<'tcx> MirPass<'tcx> for ByMoveBody {
156
156
bug ! ( "expected capture to be an upvar" ) ;
157
157
} ;
158
158
159
- assert ! (
160
- child_capture. place. projections. len( ) >= parent_capture. place. projections. len( )
161
- ) ;
162
159
// A parent matches a child they share the same prefix of projections.
163
160
// The child may have more, if it is capturing sub-fields out of
164
161
// something that is captured by-move in the parent closure.
@@ -180,6 +177,14 @@ impl<'tcx> MirPass<'tcx> for ByMoveBody {
180
177
continue ;
181
178
}
182
179
180
+ // This analysis only makes sense if the parent capture is a
181
+ // prefix of the child capture.
182
+ assert ! (
183
+ child_capture. place. projections. len( ) >= parent_capture. place. projections. len( ) ,
184
+ "parent capture ({parent_capture:#?}) expected to be prefix of \
185
+ child capture ({child_capture:#?})"
186
+ ) ;
187
+
183
188
// Store this set of additional projections (fields and derefs).
184
189
// We need to re-apply them later.
185
190
let child_precise_captures =
Original file line number Diff line number Diff line change
1
+ //@ check-pass
2
+ //@ edition: 2021
3
+ // issue: rust-lang/rust#123697
4
+
5
+ #![ feature( async_closure) ]
6
+
7
+ struct S { t : i32 }
8
+
9
+ fn test ( s : & S , t : & i32 ) {
10
+ async || {
11
+ println ! ( "{}" , s. t) ;
12
+ println ! ( "{}" , t) ;
13
+ } ;
14
+ }
15
+
16
+ fn main ( ) { }
You can’t perform that action at this time.
0 commit comments