Skip to content

Commit 978470f

Browse files
committed
no need to normalize mutability any more
1 parent 8200771 commit 978470f

File tree

1 file changed

+7
-13
lines changed

1 file changed

+7
-13
lines changed

src/librustc_mir/transform/validate.rs

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -100,22 +100,16 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
100100
return true;
101101
}
102102

103-
// Type-changing assignments can happen for (at least) two reasons:
104-
// 1. `&mut T` -> `&T` gets optimized from a reborrow to a mere assignment.
105-
// 2. Subtyping is used. While all normal lifetimes are erased, higher-ranked types
106-
// with their late-bound lifetimes are still around and can lead to type differences.
107-
// Normalize both of them away.
108-
// Also see the related but slightly different post-monomorphization method in `interpret/eval_context.rs`.
103+
// Type-changing assignments can happen when subtyping is used. While
104+
// all normal lifetimes are erased, higher-ranked types with their
105+
// late-bound lifetimes are still around and can lead to type
106+
// differences. Normalize both of them away.
107+
// Also see the related but slightly different post-monomorphization
108+
// method in `interpret/eval_context.rs`.
109109
let normalize = |ty: Ty<'tcx>| {
110110
ty.fold_with(&mut BottomUpFolder {
111111
tcx: self.tcx,
112-
// Normalize all references to immutable.
113-
ty_op: |ty| match ty.kind {
114-
ty::Ref(_, pointee, _) => {
115-
self.tcx.mk_imm_ref(self.tcx.lifetimes.re_erased, pointee)
116-
}
117-
_ => ty,
118-
},
112+
ty_op: |ty| ty,
119113
// We just erase all late-bound lifetimes, but this is not fully correct (FIXME):
120114
// lifetimes in invariant positions could matter (e.g. through associated types).
121115
// But that just means we miss some potential incompatible types, it will not

0 commit comments

Comments
 (0)