about summary refs log tree commit diff
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2020-06-21 10:04:12 +0200
committerRalf Jung <post@ralfj.de>2020-06-22 09:19:08 +0200
commit978470f711b3be3350a46d386a424e1dfb1ea148 (patch)
tree680fcc53b08d6d2a1d857b16c45f174c7172963c
parent8200771aa2cbd393a5beca819ac2462cf35e8d15 (diff)
downloadrust-978470f711b3be3350a46d386a424e1dfb1ea148.tar.gz
rust-978470f711b3be3350a46d386a424e1dfb1ea148.zip
no need to normalize mutability any more
-rw-r--r--src/librustc_mir/transform/validate.rs20
1 files changed, 7 insertions, 13 deletions
diff --git a/src/librustc_mir/transform/validate.rs b/src/librustc_mir/transform/validate.rs
index b2fbb48eefe..81bdcc849e4 100644
--- a/src/librustc_mir/transform/validate.rs
+++ b/src/librustc_mir/transform/validate.rs
@@ -100,22 +100,16 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
             return true;
         }
 
-        // Type-changing assignments can happen for (at least) two reasons:
-        // 1. `&mut T` -> `&T` gets optimized from a reborrow to a mere assignment.
-        // 2. Subtyping is used. While all normal lifetimes are erased, higher-ranked types
-        //    with their late-bound lifetimes are still around and can lead to type differences.
-        // Normalize both of them away.
-        // Also see the related but slightly different post-monomorphization method in `interpret/eval_context.rs`.
+        // Type-changing assignments can happen when subtyping is used. While
+        // all normal lifetimes are erased, higher-ranked types with their
+        // late-bound lifetimes are still around and can lead to type
+        // differences. Normalize both of them away.
+        // Also see the related but slightly different post-monomorphization
+        // method in `interpret/eval_context.rs`.
         let normalize = |ty: Ty<'tcx>| {
             ty.fold_with(&mut BottomUpFolder {
                 tcx: self.tcx,
-                // Normalize all references to immutable.
-                ty_op: |ty| match ty.kind {
-                    ty::Ref(_, pointee, _) => {
-                        self.tcx.mk_imm_ref(self.tcx.lifetimes.re_erased, pointee)
-                    }
-                    _ => ty,
-                },
+                ty_op: |ty| ty,
                 // We just erase all late-bound lifetimes, but this is not fully correct (FIXME):
                 // lifetimes in invariant positions could matter (e.g. through associated types).
                 // But that just means we miss some potential incompatible types, it will not