File tree 2 files changed +24
-1
lines changed
compiler/rustc_mir_transform/src/coroutine
tests/ui/async-await/async-closures
2 files changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -154,6 +154,14 @@ impl<'tcx> MirPass<'tcx> for ByMoveBody {
154
154
} ) {
155
155
let ( child_field_idx, child_capture) = child_captures. next ( ) . unwrap ( ) ;
156
156
157
+ // This analysis only makes sense if the parent capture is a
158
+ // prefix of the child capture.
159
+ assert ! (
160
+ child_capture. place. projections. len( ) >= parent_capture. place. projections. len( ) ,
161
+ "parent capture ({parent_capture:#?}) expected to be prefix of \
162
+ child capture ({child_capture:#?})"
163
+ ) ;
164
+
157
165
// Store this set of additional projections (fields and derefs).
158
166
// We need to re-apply them later.
159
167
let child_precise_captures =
@@ -244,7 +252,6 @@ fn child_prefix_matches_parent_projections(
244
252
bug ! ( "expected capture to be an upvar" ) ;
245
253
} ;
246
254
247
- assert ! ( child_capture. place. projections. len( ) >= parent_capture. place. projections. len( ) ) ;
248
255
parent_base. var_path . hir_id == child_base. var_path . hir_id
249
256
&& std:: iter:: zip ( & child_capture. place . projections , & parent_capture. place . projections )
250
257
. all ( |( child, parent) | child. kind == parent. kind )
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