Skip to content

Commit 74fb263

Browse files
committed
auto merge of #5546 : nikomatsakis/rust/ty_region-useful-span, r=catamorphism
r? @catamorphism
2 parents 51eb7dc + 057c40d commit 74fb263

File tree

3 files changed

+18
-11
lines changed

3 files changed

+18
-11
lines changed

Diff for: src/librustc/middle/borrowck/gather_loans.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ fn req_loans_in_expr(ex: @ast::expr,
145145

146146
// make sure that the thing we are pointing out stays valid
147147
// for the lifetime `scope_r` of the resulting ptr:
148-
let scope_r = ty_region(tcx.ty(ex));
148+
let scope_r = ty_region(tcx, ex.span, tcx.ty(ex));
149149
self.guarantee_valid(base_cmt, mutbl, scope_r);
150150
visit::visit_expr(ex, self, vt);
151151
}
@@ -599,7 +599,8 @@ pub impl GatherLoanCtxt {
599599
// find the region of the resulting pointer (note that
600600
// the type of such a pattern will *always* be a
601601
// region pointer)
602-
let scope_r = ty_region(self.tcx().ty(pat));
602+
let scope_r = ty_region(self.tcx(), pat.span,
603+
self.tcx().ty(pat));
603604

604605
// if the scope of the region ptr turns out to be
605606
// specific to this arm, wrap the categorization with

Diff for: src/librustc/middle/ty.rs

+11-6
Original file line numberDiff line numberDiff line change
@@ -2794,13 +2794,18 @@ pub fn ty_vstore(ty: t) -> vstore {
27942794
}
27952795
}
27962796

2797-
pub fn ty_region(ty: t) -> Region {
2797+
pub fn ty_region(tcx: ctxt,
2798+
span: span,
2799+
ty: t) -> Region {
27982800
match get(ty).sty {
2799-
ty_rptr(r, _) => r,
2800-
ty_evec(_, vstore_slice(r)) => r,
2801-
ty_estr(vstore_slice(r)) => r,
2802-
ref s => fail!(fmt!("ty_region() invoked on in appropriate ty: %?",
2803-
(*s)))
2801+
ty_rptr(r, _) => r,
2802+
ty_evec(_, vstore_slice(r)) => r,
2803+
ty_estr(vstore_slice(r)) => r,
2804+
ref s => {
2805+
tcx.sess.span_bug(
2806+
span,
2807+
fmt!("ty_region() invoked on in appropriate ty: %?", s));
2808+
}
28042809
}
28052810
}
28062811

Diff for: src/librustc/middle/typeck/check/regionck.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -616,8 +616,9 @@ pub mod guarantor {
616616
// mk_subr should never fail.
617617
let rptr_ty = rcx.resolve_node_type(id);
618618
if !ty::type_is_error(rptr_ty) {
619-
debug!("rptr_ty=%s", ty_to_str(rcx.fcx.ccx.tcx, rptr_ty));
620-
let r = ty::ty_region(rptr_ty);
619+
let tcx = rcx.fcx.ccx.tcx;
620+
debug!("rptr_ty=%s", ty_to_str(tcx, rptr_ty));
621+
let r = ty::ty_region(tcx, span, rptr_ty);
621622
infallibly_mk_subr(rcx, true, span, r, bound);
622623
}
623624
}
@@ -890,7 +891,7 @@ pub mod guarantor {
890891
ast::pat_region(p) => {
891892
let rptr_ty = rcx.resolve_node_type(pat.id);
892893
if !ty::type_is_error(rptr_ty) {
893-
let r = ty::ty_region(rptr_ty);
894+
let r = ty::ty_region(rcx.fcx.tcx(), pat.span, rptr_ty);
894895
link_ref_bindings_in_pat(rcx, p, Some(r));
895896
}
896897
}

0 commit comments

Comments
 (0)