From 16a0f72f8ca85b1e2a1b69043dc16c6cf20cc83f Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Thu, 2 Aug 2012 17:12:17 -0700 Subject: [PATCH] rustc: Throw out some more regions when normalizing types --- src/rustc/middle/ty.rs | 59 ++++++++++++++++++++++++++---------------- 1 file changed, 37 insertions(+), 22 deletions(-) diff --git a/src/rustc/middle/ty.rs b/src/rustc/middle/ty.rs index afb18c605c4f..0dc1b6452482 100644 --- a/src/rustc/middle/ty.rs +++ b/src/rustc/middle/ty.rs @@ -3110,35 +3110,50 @@ fn ty_params_to_tys(tcx: ty::ctxt, tps: ~[ast::ty_param]) -> ~[t] { /// Returns an equivalent type with all the typedefs and self regions removed. fn normalize_ty(cx: ctxt, t: t) -> t { + fn normalize_mt(cx: ctxt, mt: mt) -> mt { + { ty: normalize_ty(cx, mt.ty), mutbl: mt.mutbl } + } + fn normalize_vstore(vstore: vstore) -> vstore { + match vstore { + vstore_fixed(*) | vstore_uniq | vstore_box => vstore, + vstore_slice(_) => vstore_slice(re_static) + } + } + alt cx.normalized_cache.find(t) { some(t) { return t; } none { } } - let t = alt get(t).struct { - ty_rptr(region, mt) { + let t = match get(t).struct { + ty_evec(mt, vstore) => + // This type has a vstore. Get rid of it + mk_evec(cx, normalize_mt(cx, mt), normalize_vstore(vstore)), + + ty_rptr(region, mt) => // This type has a region. Get rid of it - mk_rptr(cx, re_static, mt) - } - ty_enum(did, r) { - alt r.self_r { - some(_) { - // This enum has a self region. Get rid of it - mk_enum(cx, did, {self_r: none, self_ty: none, tps: r.tps}) - } - none { t } - } - } - ty_class(did, r) { - alt r.self_r { - some(_) { + mk_rptr(cx, re_static, normalize_mt(cx, mt)), + + ty_enum(did, r) => + match r.self_r { + some(_) => + // This enum has a self region. Get rid of it + mk_enum(cx, did, {self_r: none, self_ty: none, tps: r.tps}), + none => + t + }, + + ty_class(did, r) => + match r.self_r { + some(_) => // Ditto. - mk_class(cx, did, {self_r: none, self_ty: none, tps: r.tps}) - } - none { t } - } - } - _ { t } + mk_class(cx, did, {self_r: none, self_ty: none, tps: r.tps}), + none => + t + }, + + _ => + t }; // FIXME #2187: This also reduced int types to their compatible machine