File tree Expand file tree Collapse file tree 2 files changed +24
-3
lines changed
compiler/rustc_mir_transform/src/coroutine
tests/ui/async-await/async-closures Expand file tree Collapse file tree 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 {
156156 bug ! ( "expected capture to be an upvar" ) ;
157157 } ;
158158
159- assert ! (
160- child_capture. place. projections. len( ) >= parent_capture. place. projections. len( )
161- ) ;
162159 // A parent matches a child they share the same prefix of projections.
163160 // The child may have more, if it is capturing sub-fields out of
164161 // something that is captured by-move in the parent closure.
@@ -180,6 +177,14 @@ impl<'tcx> MirPass<'tcx> for ByMoveBody {
180177 continue ;
181178 }
182179
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+
183188 // Store this set of additional projections (fields and derefs).
184189 // We need to re-apply them later.
185190 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