1
1
use std:: mem;
2
2
3
3
use rustc_index:: IndexVec ;
4
+ use rustc_middle:: bug;
4
5
use rustc_middle:: mir:: * ;
5
6
use rustc_middle:: ty:: { self , Ty , TyCtxt , TypeVisitableExt } ;
6
- use rustc_middle:: { bug, span_bug} ;
7
7
use smallvec:: { SmallVec , smallvec} ;
8
8
use tracing:: debug;
9
9
@@ -344,13 +344,14 @@ impl<'a, 'tcx, F: Fn(Ty<'tcx>) -> bool> MoveDataBuilder<'a, 'tcx, F> {
344
344
match & stmt. kind {
345
345
StatementKind :: Assign ( box ( place, Rvalue :: CopyForDeref ( reffed) ) ) => {
346
346
let local = place. as_local ( ) . unwrap ( ) ;
347
- assert ! ( self . body. local_decls[ local] . is_deref_temp( ) ) ;
347
+ if self . body . local_decls [ local] . is_deref_temp ( ) {
348
+ let rev_lookup = & mut self . data . rev_lookup ;
348
349
349
- let rev_lookup = & mut self . data . rev_lookup ;
350
-
351
- rev_lookup. un_derefer . insert ( local, reffed . as_ref ( ) ) ;
352
- let base_local = rev_lookup. un_derefer . deref_chain ( local) . first ( ) . unwrap ( ) . local ;
353
- rev_lookup . locals [ local ] = rev_lookup . locals [ base_local ] ;
350
+ rev_lookup . un_derefer . insert ( local , reffed . as_ref ( ) ) ;
351
+ let base_local =
352
+ rev_lookup. un_derefer . deref_chain ( local) . first ( ) . unwrap ( ) . local ;
353
+ rev_lookup. locals [ local] = rev_lookup . locals [ base_local ] ;
354
+ }
354
355
}
355
356
StatementKind :: Assign ( box ( place, rval) ) => {
356
357
self . create_move_path ( * place) ;
@@ -375,13 +376,9 @@ impl<'a, 'tcx, F: Fn(Ty<'tcx>) -> bool> MoveDataBuilder<'a, 'tcx, F> {
375
376
self . gather_move ( Place :: from ( * local) ) ;
376
377
}
377
378
}
378
- StatementKind :: SetDiscriminant { .. } | StatementKind :: Deinit ( ..) => {
379
- span_bug ! (
380
- stmt. source_info. span,
381
- "SetDiscriminant/Deinit should not exist during borrowck"
382
- ) ;
383
- }
384
- StatementKind :: Retag { .. }
379
+ StatementKind :: SetDiscriminant { .. }
380
+ | StatementKind :: Deinit ( ..)
381
+ | StatementKind :: Retag { .. }
385
382
| StatementKind :: AscribeUserType ( ..)
386
383
| StatementKind :: PlaceMention ( ..)
387
384
| StatementKind :: Coverage ( ..)
0 commit comments