auto merge of #5546 : nikomatsakis/rust/ty_region-useful-span, r=catamorphism

r? @catamorphism
This commit is contained in:
bors 2013-03-26 06:58:10 -07:00
commit 74fb263f7a
3 changed files with 18 additions and 11 deletions

View File

@ -145,7 +145,7 @@ fn req_loans_in_expr(ex: @ast::expr,
// make sure that the thing we are pointing out stays valid
// for the lifetime `scope_r` of the resulting ptr:
let scope_r = ty_region(tcx.ty(ex));
let scope_r = ty_region(tcx, ex.span, tcx.ty(ex));
self.guarantee_valid(base_cmt, mutbl, scope_r);
visit::visit_expr(ex, self, vt);
}
@ -599,7 +599,8 @@ fn gather_pat(@mut self,
// find the region of the resulting pointer (note that
// the type of such a pattern will *always* be a
// region pointer)
let scope_r = ty_region(self.tcx().ty(pat));
let scope_r = ty_region(self.tcx(), pat.span,
self.tcx().ty(pat));
// if the scope of the region ptr turns out to be
// specific to this arm, wrap the categorization with

View File

@ -2794,13 +2794,18 @@ pub fn ty_vstore(ty: t) -> vstore {
}
}
pub fn ty_region(ty: t) -> Region {
pub fn ty_region(tcx: ctxt,
span: span,
ty: t) -> Region {
match get(ty).sty {
ty_rptr(r, _) => r,
ty_evec(_, vstore_slice(r)) => r,
ty_estr(vstore_slice(r)) => r,
ref s => fail!(fmt!("ty_region() invoked on in appropriate ty: %?",
(*s)))
ty_rptr(r, _) => r,
ty_evec(_, vstore_slice(r)) => r,
ty_estr(vstore_slice(r)) => r,
ref s => {
tcx.sess.span_bug(
span,
fmt!("ty_region() invoked on in appropriate ty: %?", s));
}
}
}

View File

@ -616,8 +616,9 @@ fn link(
// mk_subr should never fail.
let rptr_ty = rcx.resolve_node_type(id);
if !ty::type_is_error(rptr_ty) {
debug!("rptr_ty=%s", ty_to_str(rcx.fcx.ccx.tcx, rptr_ty));
let r = ty::ty_region(rptr_ty);
let tcx = rcx.fcx.ccx.tcx;
debug!("rptr_ty=%s", ty_to_str(tcx, rptr_ty));
let r = ty::ty_region(tcx, span, rptr_ty);
infallibly_mk_subr(rcx, true, span, r, bound);
}
}
@ -890,7 +891,7 @@ fn link_ref_bindings_in_pat(
ast::pat_region(p) => {
let rptr_ty = rcx.resolve_node_type(pat.id);
if !ty::type_is_error(rptr_ty) {
let r = ty::ty_region(rptr_ty);
let r = ty::ty_region(rcx.fcx.tcx(), pat.span, rptr_ty);
link_ref_bindings_in_pat(rcx, p, Some(r));
}
}