3
3
//! be a coroutine body that takes all of its upvars by-move, and which we stash
4
4
//! into the `CoroutineInfo` for all coroutines returned by coroutine-closures.
5
5
6
- use rustc_data_structures:: fx :: FxIndexSet ;
6
+ use rustc_data_structures:: unord :: UnordSet ;
7
7
use rustc_hir as hir;
8
8
use rustc_middle:: mir:: visit:: MutVisitor ;
9
9
use rustc_middle:: mir:: { self , dump_mir, MirPass } ;
@@ -33,7 +33,7 @@ impl<'tcx> MirPass<'tcx> for ByMoveBody {
33
33
return ;
34
34
}
35
35
36
- let mut by_ref_fields = FxIndexSet :: default ( ) ;
36
+ let mut by_ref_fields = UnordSet :: default ( ) ;
37
37
let by_move_upvars = Ty :: new_tup_from_iter (
38
38
tcx,
39
39
tcx. closure_captures ( coroutine_def_id) . iter ( ) . enumerate ( ) . map ( |( idx, capture) | {
@@ -73,7 +73,7 @@ impl<'tcx> MirPass<'tcx> for ByMoveBody {
73
73
74
74
struct MakeByMoveBody < ' tcx > {
75
75
tcx : TyCtxt < ' tcx > ,
76
- by_ref_fields : FxIndexSet < FieldIdx > ,
76
+ by_ref_fields : UnordSet < FieldIdx > ,
77
77
by_move_coroutine_ty : Ty < ' tcx > ,
78
78
}
79
79
@@ -89,11 +89,11 @@ impl<'tcx> MutVisitor<'tcx> for MakeByMoveBody<'tcx> {
89
89
location : mir:: Location ,
90
90
) {
91
91
if place. local == ty:: CAPTURE_STRUCT_LOCAL
92
- && !place . projection . is_empty ( )
93
- && let mir :: ProjectionElem :: Field ( idx , ty ) = place. projection [ 0 ]
92
+ && let Some ( ( & mir :: ProjectionElem :: Field ( idx , ty ) , projection ) ) =
93
+ place. projection . split_first ( )
94
94
&& self . by_ref_fields . contains ( & idx)
95
95
{
96
- let ( begin, end) = place . projection [ 1 .. ] . split_first ( ) . unwrap ( ) ;
96
+ let ( begin, end) = projection. split_first ( ) . unwrap ( ) ;
97
97
// FIXME(async_closures): I'm actually a bit surprised to see that we always
98
98
// initially deref the by-ref upvars. If this is not actually true, then we
99
99
// will at least get an ICE that explains why this isn't true :^)
0 commit comments