]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc/middle/borrowck/gather_loans/lifetime.rs
rustc: remove DefArg and DefBinding in favor of DefLocal.
[rust.git] / src / librustc / middle / borrowck / gather_loans / lifetime.rs
index 3337a56edf008d8f52f7e29d1f6d03bb3a034c43..c07123325253b37bd4bbb7d6b1da67698a3afd90 100644 (file)
@@ -14,8 +14,8 @@
  */
 
 use middle::borrowck::*;
-use euv = middle::expr_use_visitor;
-use mc = middle::mem_categorization;
+use middle::expr_use_visitor as euv;
+use middle::mem_categorization as mc;
 use middle::ty;
 use util::ppaux::Repr;
 use syntax::ast;
@@ -29,7 +29,7 @@ pub fn guarantee_lifetime(bccx: &BorrowckCtxt,
                           cause: euv::LoanCause,
                           cmt: mc::cmt,
                           loan_region: ty::Region,
-                          loan_kind: ty::BorrowKind)
+                          _: ty::BorrowKind)
                           -> Result<(),()> {
     debug!("guarantee_lifetime(cmt={}, loan_region={})",
            cmt.repr(bccx.tcx), loan_region.repr(bccx.tcx));
@@ -38,7 +38,6 @@ pub fn guarantee_lifetime(bccx: &BorrowckCtxt,
                                          span: span,
                                          cause: cause,
                                          loan_region: loan_region,
-                                         loan_kind: loan_kind,
                                          cmt_original: cmt.clone()};
     ctxt.check(&cmt, None)
 }
@@ -46,8 +45,8 @@ pub fn guarantee_lifetime(bccx: &BorrowckCtxt,
 ///////////////////////////////////////////////////////////////////////////
 // Private
 
-struct GuaranteeLifetimeContext<'a> {
-    bccx: &'a BorrowckCtxt<'a>,
+struct GuaranteeLifetimeContext<'a, 'tcx: 'a> {
+    bccx: &'a BorrowckCtxt<'a, 'tcx>,
 
     // the node id of the function body for the enclosing item
     item_scope_id: ast::NodeId,
@@ -55,11 +54,10 @@ struct GuaranteeLifetimeContext<'a> {
     span: Span,
     cause: euv::LoanCause,
     loan_region: ty::Region,
-    loan_kind: ty::BorrowKind,
     cmt_original: mc::cmt
 }
 
-impl<'a> GuaranteeLifetimeContext<'a> {
+impl<'a, 'tcx> GuaranteeLifetimeContext<'a, 'tcx> {
 
     fn check(&self, cmt: &mc::cmt, discr_scope: Option<ast::NodeId>) -> R {
         //! Main routine. Walks down `cmt` until we find the "guarantor".
@@ -71,9 +69,9 @@ fn check(&self, cmt: &mc::cmt, discr_scope: Option<ast::NodeId>) -> R {
             mc::cat_rvalue(..) |
             mc::cat_copied_upvar(..) |                  // L-Local
             mc::cat_local(..) |                         // L-Local
-            mc::cat_arg(..) |                           // L-Local
             mc::cat_upvar(..) |
             mc::cat_deref(_, _, mc::BorrowedPtr(..)) |  // L-Deref-Borrowed
+            mc::cat_deref(_, _, mc::Implicit(..)) |
             mc::cat_deref(_, _, mc::UnsafePtr(..)) => {
                 self.check_scope(self.scope(cmt))
             }
@@ -175,14 +173,14 @@ fn scope(&self, cmt: &mc::cmt) -> ty::Region {
             mc::cat_static_item => {
                 ty::ReStatic
             }
-            mc::cat_local(local_id) |
-            mc::cat_arg(local_id) => {
+            mc::cat_local(local_id) => {
                 ty::ReScope(self.bccx.tcx.region_maps.var_scope(local_id))
             }
             mc::cat_deref(_, _, mc::UnsafePtr(..)) => {
                 ty::ReStatic
             }
-            mc::cat_deref(_, _, mc::BorrowedPtr(_, r)) => {
+            mc::cat_deref(_, _, mc::BorrowedPtr(_, r)) |
+            mc::cat_deref(_, _, mc::Implicit(_, r)) => {
                 r
             }
             mc::cat_downcast(ref cmt) |