remove hacks now that #3148 is fixed

r=brson
This commit is contained in:
Niko Matsakis 2013-01-25 10:29:25 -08:00
parent 2b67d88809
commit e6cadc4c03
2 changed files with 8 additions and 45 deletions

View File

@ -739,8 +739,9 @@ impl LookupContext {
let tcx = self.tcx();
return match ty::get(self_ty).sty {
ty::ty_rptr(self_r, self_mt) if self_mt.mutbl == m_mutbl => {
let region = fresh_region(self, self_r);
ty::ty_rptr(_, self_mt) if self_mt.mutbl == m_mutbl => {
let region = self.infcx().next_region_var(self.expr.span,
self.expr.id);
(ty::mk_rptr(tcx, region, self_mt),
ty::AutoAdjustment {
autoderefs: autoderefs+1,
@ -748,9 +749,10 @@ impl LookupContext {
region: region,
mutbl: self_mt.mutbl})})
}
ty::ty_evec(self_mt, vstore_slice(self_r))
ty::ty_evec(self_mt, vstore_slice(_))
if self_mt.mutbl == m_mutbl => {
let region = fresh_region(self, self_r);
let region = self.infcx().next_region_var(self.expr.span,
self.expr.id);
(ty::mk_evec(tcx, self_mt, vstore_slice(region)),
ty::AutoAdjustment {
autoderefs: autoderefs,
@ -763,26 +765,6 @@ impl LookupContext {
autoref: None})
}
};
fn fresh_region(self: &LookupContext,
self_r: ty::Region) -> ty::Region {
let region = self.infcx().next_region_var(self.expr.span,
self.expr.id);
// FIXME(#3148)---in principle this dependency should
// be done more generally as part of regionck
match infer::mk_subr(self.infcx(), true, self.expr.span,
region, self_r) {
Ok(_) => {}
Err(e) => {
self.tcx().sess.span_bug(
self.expr.span,
fmt!("Failed with error: %?", e));
}
}
return region;
}
}
fn search_for_autosliced_method(

View File

@ -196,15 +196,7 @@ impl Coerce {
let inner_ty = match *sty_a {
ty::ty_box(mt_a) => mt_a.ty,
ty::ty_uniq(mt_a) => mt_a.ty,
ty::ty_rptr(r_a, mt_a) => {
// Ensure that the pointer we are borrowing from lives
// at least as long as the borrowed result.
//
// FIXME(#3148)---in principle this dependency should
// be done more generally
if_ok!(sub.contraregions(r_a, r_borrow));
mt_a.ty
}
ty::ty_rptr(r_a, mt_a) => mt_a.ty,
_ => {
return self.subtype(a, b);
}
@ -267,18 +259,7 @@ impl Coerce {
let sub = Sub(**self);
let r_borrow = self.infcx.next_region_var_nb(self.span);
let ty_inner = match *sty_a {
ty::ty_evec(mt, vstore_box) => mt.ty,
ty::ty_evec(mt, vstore_uniq) => mt.ty,
ty::ty_evec(mt, vstore_fixed(_)) => mt.ty,
ty::ty_evec(mt, vstore_slice(r_a)) => {
// Ensure that the pointer we are borrowing from lives
// at least as long as the borrowed result.
//
// FIXME(#3148)---in principle this dependency should
// be done more generally
if_ok!(sub.contraregions(r_a, r_borrow));
mt.ty
}
ty::ty_evec(mt, _) => mt.ty,
_ => {
return self.subtype(a, b);
}