diff options
| author | bors <bors@rust-lang.org> | 2013-03-26 06:58:10 -0700 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2013-03-26 06:58:10 -0700 |
| commit | 74fb263f7a8d385635e0861593ce6d72d0e5ec10 (patch) | |
| tree | 3bb1f03ef6087dc2e45d35c9c2db52b0deeec1ad | |
| parent | 51eb7dc8a719f6ae05a563109b3bbccee319263e (diff) | |
| parent | 057c40d5bd3dc700af7d99a2dfeba0fe6c2ba119 (diff) | |
| download | rust-74fb263f7a8d385635e0861593ce6d72d0e5ec10.tar.gz rust-74fb263f7a8d385635e0861593ce6d72d0e5ec10.zip | |
auto merge of #5546 : nikomatsakis/rust/ty_region-useful-span, r=catamorphism
r? @catamorphism
| -rw-r--r-- | src/librustc/middle/borrowck/gather_loans.rs | 5 | ||||
| -rw-r--r-- | src/librustc/middle/ty.rs | 17 | ||||
| -rw-r--r-- | src/librustc/middle/typeck/check/regionck.rs | 7 |
3 files changed, 18 insertions, 11 deletions
diff --git a/src/librustc/middle/borrowck/gather_loans.rs b/src/librustc/middle/borrowck/gather_loans.rs index 83fe2db79ef..bab652a3d1e 100644 --- a/src/librustc/middle/borrowck/gather_loans.rs +++ b/src/librustc/middle/borrowck/gather_loans.rs @@ -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 @@ pub impl GatherLoanCtxt { // 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 diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index de626675fa3..44245e0b4e1 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -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)); + } } } diff --git a/src/librustc/middle/typeck/check/regionck.rs b/src/librustc/middle/typeck/check/regionck.rs index 6682082bd18..3a02c19dbaf 100644 --- a/src/librustc/middle/typeck/check/regionck.rs +++ b/src/librustc/middle/typeck/check/regionck.rs @@ -616,8 +616,9 @@ pub mod guarantor { // 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 @@ pub mod guarantor { 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)); } } |
