about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorNiko Matsakis <niko@alum.mit.edu>2013-03-25 17:39:15 -0400
committerNiko Matsakis <niko@alum.mit.edu>2013-03-25 17:39:15 -0400
commit057c40d5bd3dc700af7d99a2dfeba0fe6c2ba119 (patch)
treeaf40d0e72775b851feea2b1ffb6acfe80b53997c /src
parent6d4499ce4d948bf7b7b385b40e5b3536507ad3e8 (diff)
downloadrust-057c40d5bd3dc700af7d99a2dfeba0fe6c2ba119.tar.gz
rust-057c40d5bd3dc700af7d99a2dfeba0fe6c2ba119.zip
make ty_region give a useful span when it fails
Diffstat (limited to 'src')
-rw-r--r--src/librustc/middle/borrowck/gather_loans.rs5
-rw-r--r--src/librustc/middle/ty.rs17
-rw-r--r--src/librustc/middle/typeck/check/regionck.rs7
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));
                 }
             }