Skip to content

Commit 16a0f72

Browse files
committed
rustc: Throw out some more regions when normalizing types
1 parent 51b9674 commit 16a0f72

File tree

1 file changed

+37
-22
lines changed

1 file changed

+37
-22
lines changed

src/rustc/middle/ty.rs

Lines changed: 37 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3110,35 +3110,50 @@ fn ty_params_to_tys(tcx: ty::ctxt, tps: ~[ast::ty_param]) -> ~[t] {
31103110

31113111
/// Returns an equivalent type with all the typedefs and self regions removed.
31123112
fn normalize_ty(cx: ctxt, t: t) -> t {
3113+
fn normalize_mt(cx: ctxt, mt: mt) -> mt {
3114+
{ ty: normalize_ty(cx, mt.ty), mutbl: mt.mutbl }
3115+
}
3116+
fn normalize_vstore(vstore: vstore) -> vstore {
3117+
match vstore {
3118+
vstore_fixed(*) | vstore_uniq | vstore_box => vstore,
3119+
vstore_slice(_) => vstore_slice(re_static)
3120+
}
3121+
}
3122+
31133123
alt cx.normalized_cache.find(t) {
31143124
some(t) { return t; }
31153125
none { }
31163126
}
31173127

3118-
let t = alt get(t).struct {
3119-
ty_rptr(region, mt) {
3128+
let t = match get(t).struct {
3129+
ty_evec(mt, vstore) =>
3130+
// This type has a vstore. Get rid of it
3131+
mk_evec(cx, normalize_mt(cx, mt), normalize_vstore(vstore)),
3132+
3133+
ty_rptr(region, mt) =>
31203134
// This type has a region. Get rid of it
3121-
mk_rptr(cx, re_static, mt)
3122-
}
3123-
ty_enum(did, r) {
3124-
alt r.self_r {
3125-
some(_) {
3126-
// This enum has a self region. Get rid of it
3127-
mk_enum(cx, did, {self_r: none, self_ty: none, tps: r.tps})
3128-
}
3129-
none { t }
3130-
}
3131-
}
3132-
ty_class(did, r) {
3133-
alt r.self_r {
3134-
some(_) {
3135+
mk_rptr(cx, re_static, normalize_mt(cx, mt)),
3136+
3137+
ty_enum(did, r) =>
3138+
match r.self_r {
3139+
some(_) =>
3140+
// This enum has a self region. Get rid of it
3141+
mk_enum(cx, did, {self_r: none, self_ty: none, tps: r.tps}),
3142+
none =>
3143+
t
3144+
},
3145+
3146+
ty_class(did, r) =>
3147+
match r.self_r {
3148+
some(_) =>
31353149
// Ditto.
3136-
mk_class(cx, did, {self_r: none, self_ty: none, tps: r.tps})
3137-
}
3138-
none { t }
3139-
}
3140-
}
3141-
_ { t }
3150+
mk_class(cx, did, {self_r: none, self_ty: none, tps: r.tps}),
3151+
none =>
3152+
t
3153+
},
3154+
3155+
_ =>
3156+
t
31423157
};
31433158

31443159
// FIXME #2187: This also reduced int types to their compatible machine

0 commit comments

Comments
 (0)