@@ -146,6 +146,37 @@ impl<'tcx> MirPass<'tcx> for ElaborateBoxDerefs {
146146 }
147147
148148 visitor. patch . apply ( body) ;
149+
150+ for debug_info in body. var_debug_info . iter_mut ( ) {
151+ if let VarDebugInfoContents :: Place ( place) = & mut debug_info. value {
152+ let mut new_projections: Option < Vec < _ > > = None ;
153+ let mut last_deref = 0 ;
154+
155+ for ( i, ( base, elem) ) in place. iter_projections ( ) . enumerate ( ) {
156+ let base_ty = base. ty ( & body. local_decls , tcx) . ty ;
157+
158+ if elem == PlaceElem :: Deref && base_ty. is_box ( ) {
159+ let new_projections = new_projections. get_or_insert_default ( ) ;
160+
161+ let ( unique_ty, nonnull_ty, ptr_ty) =
162+ build_ptr_tys ( tcx, base_ty. boxed_ty ( ) , unique_did, nonnull_did) ;
163+
164+ new_projections. extend_from_slice ( & base. projection [ last_deref..] ) ;
165+ new_projections. extend_from_slice ( & build_projection (
166+ unique_ty, nonnull_ty, ptr_ty,
167+ ) ) ;
168+ new_projections. push ( PlaceElem :: Deref ) ;
169+
170+ last_deref = i;
171+ }
172+ }
173+
174+ if let Some ( mut new_projections) = new_projections {
175+ new_projections. extend_from_slice ( & place. projection [ last_deref..] ) ;
176+ place. projection = tcx. intern_place_elems ( & new_projections) ;
177+ }
178+ }
179+ }
149180 } else {
150181 // box is not present, this pass doesn't need to do anything
151182 }
0 commit comments