@@ -808,21 +808,15 @@ impl<'body, 'a, 'tcx> VnState<'body, 'a, 'tcx> {
808808        let  projection_ty = place_ty. projection_ty ( self . tcx ,  proj) ; 
809809        let  proj = match  proj { 
810810            ProjectionElem :: Deref  => { 
811-                 if  let  Some ( Mutability :: Not )  = place_ty . ty . ref_mutability ( ) 
812-                     && projection_ty . ty . is_freeze ( self . tcx ,   self . typing_env ( ) ) 
811+                 if  let  Value :: Address   {  base ,  projection ,  ..  }  =  self . get ( value ) 
812+                     && let   Some ( value )  =  self . dereference_address ( base ,  projection ) 
813813                { 
814-                     if  let  Value :: Address  {  base,  projection,  .. }  = self . get ( value) 
815-                         && let  Some ( value)  = self . dereference_address ( base,  projection) 
816-                     { 
817-                         return  Some ( ( projection_ty,  value) ) ; 
818-                     } 
819- 
820-                     // An immutable borrow `_x` always points to the same value for the 
821-                     // lifetime of the borrow, so we can merge all instances of `*_x`. 
822-                     return  Some ( ( projection_ty,  self . insert_deref ( projection_ty. ty ,  value) ) ) ; 
823-                 }  else  { 
824-                     return  None ; 
814+                     return  Some ( ( projection_ty,  value) ) ; 
825815                } 
816+ 
817+                 // An borrow `_x` can point to the same value for the 
818+                 // lifetime of the borrow, so we can merge instances of `*_x`. 
819+                 return  Some ( ( projection_ty,  self . insert_deref ( projection_ty. ty ,  value) ) ) ; 
826820            } 
827821            ProjectionElem :: Downcast ( name,  index)  => ProjectionElem :: Downcast ( name,  index) , 
828822            ProjectionElem :: Field ( f,  _)  => match  self . get ( value)  { 
@@ -1927,6 +1921,7 @@ impl<'tcx> MutVisitor<'tcx> for VnState<'_, '_, 'tcx> {
19271921            TerminatorKind :: SwitchInt  {  .. } 
19281922                | TerminatorKind :: Goto  {  .. } 
19291923                | TerminatorKind :: Unreachable 
1924+                 | TerminatorKind :: Return 
19301925        ) ; 
19311926        if  !safe_to_preserve_derefs { 
19321927            self . invalidate_derefs ( ) ; 
0 commit comments