提交 b38092e9 编写于 作者: T Tim Chevalier

In ty::normalize_ty, don't replace self_regions with None

Instead, replace with re_static. This was causing ty::subst to
fail when called from trans::type_of::type_of.

Already discussed with nmatsakis and it's a small change, so
no review.

Closes #3447
上级 bbc46d52
......@@ -1473,7 +1473,10 @@ fn do_subst(cx: ctxt,
fold_regions_and_ty(
cx, typ,
|r| match r {
re_bound(br_self) => substs.self_r.get(),
re_bound(br_self) => substs.self_r.expect(
#fmt("ty::subst: \
Reference to self region when given substs with no \
self region, ty = %s", ty_to_str(cx, typ))),
_ => r
},
|t| do_subst(cx, substs, t),
......@@ -3910,9 +3913,11 @@ fn normalize_vstore(vstore: vstore) -> vstore {
ty_enum(did, r) =>
match r.self_r {
Some(_) =>
// This enum has a self region. Get rid of it
// Use re_static since trans doesn't care about regions
mk_enum(cx, did,
{self_r: None, self_ty: None, tps: r.tps}),
{self_r: Some(ty::re_static),
self_ty: None,
tps: r.tps}),
None =>
t
},
......@@ -3921,7 +3926,8 @@ fn normalize_vstore(vstore: vstore) -> vstore {
match r.self_r {
Some(_) =>
// Ditto.
mk_class(cx, did, {self_r: None, self_ty: None, tps: r.tps}),
mk_class(cx, did, {self_r: Some(ty::re_static), self_ty: None,
tps: r.tps}),
None =>
t
},
......
// xfail-test
struct list<T> {
element: &self/T,
mut next: Option<@list<T>>
......@@ -11,13 +10,13 @@ fn addEnd(&self, element: &self/T) {
next: option::None
};
self.next = Some(@newList);
self.next = Some(@(move newList));
}
}
fn main() {
let s = @"str";
let ls: list<@str> = list {
let ls = list {
element: &s,
next: option::None
};
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册