11use std:: mem;
22
33use rustc_index:: IndexVec ;
4+ use rustc_middle:: bug;
45use rustc_middle:: mir:: * ;
56use rustc_middle:: ty:: { self , Ty , TyCtxt , TypeVisitableExt } ;
6- use rustc_middle:: { bug, span_bug} ;
77use smallvec:: { SmallVec , smallvec} ;
88use tracing:: debug;
99
@@ -344,13 +344,14 @@ impl<'a, 'tcx, F: Fn(Ty<'tcx>) -> bool> MoveDataBuilder<'a, 'tcx, F> {
344344 match & stmt. kind {
345345 StatementKind :: Assign ( box ( place, Rvalue :: CopyForDeref ( reffed) ) ) => {
346346 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 ;
348349
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+ }
354355 }
355356 StatementKind :: Assign ( box ( place, rval) ) => {
356357 self . create_move_path ( * place) ;
@@ -375,13 +376,9 @@ impl<'a, 'tcx, F: Fn(Ty<'tcx>) -> bool> MoveDataBuilder<'a, 'tcx, F> {
375376 self . gather_move ( Place :: from ( * local) ) ;
376377 }
377378 }
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 { .. }
385382 | StatementKind :: AscribeUserType ( ..)
386383 | StatementKind :: PlaceMention ( ..)
387384 | StatementKind :: Coverage ( ..)
0 commit comments