]> git.lizzy.rs Git - rust.git/commitdiff
Revert borrowck changes
authorJohn Kåre Alsaker <john.kare.alsaker@gmail.com>
Fri, 14 Jul 2017 23:22:13 +0000 (01:22 +0200)
committerJohn Kåre Alsaker <john.kare.alsaker@gmail.com>
Fri, 28 Jul 2017 13:46:25 +0000 (15:46 +0200)
src/librustc_borrowck/borrowck/gather_loans/mod.rs
src/librustc_borrowck/diagnostics.rs

index bcfc9db56fcc789c76fcdef01ab930fcd0947774..426eef5957075b4eb21e2c69cb247287708406df 100644 (file)
@@ -21,7 +21,6 @@
 use rustc::middle::expr_use_visitor as euv;
 use rustc::middle::mem_categorization as mc;
 use rustc::middle::mem_categorization::Categorization;
-use rustc::middle::region::extent_has_yield;
 use rustc::middle::region;
 use rustc::ty::{self, TyCtxt};
 
 mod move_error;
 
 pub fn gather_loans_in_fn<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>,
-                                    body_id: hir::BodyId)
+                                    body: hir::BodyId)
                                     -> (Vec<Loan<'tcx>>, move_data::MoveData<'tcx>) {
-    let def_id = bccx.tcx.hir.body_owner_def_id(body_id);
+    let def_id = bccx.tcx.hir.body_owner_def_id(body);
     let param_env = bccx.tcx.param_env(def_id);
-    let body = bccx.tcx.hir.body(body_id);
     let mut glcx = GatherLoanCtxt {
         bccx: bccx,
         all_loans: Vec::new(),
-        item_ub: region::CodeExtent::Misc(body_id.node_id),
+        item_ub: region::CodeExtent::Misc(body.node_id),
         move_data: MoveData::new(),
         move_error_collector: move_error::MoveErrorCollector::new(),
-        generator: body.is_generator(),
     };
 
+    let body = glcx.bccx.tcx.hir.body(body);
     euv::ExprUseVisitor::new(&mut glcx, bccx.tcx, param_env, &bccx.region_maps, bccx.tables)
         .consume_body(body);
 
@@ -67,7 +65,6 @@ struct GatherLoanCtxt<'a, 'tcx: 'a> {
     /// `item_ub` is used as an upper-bound on the lifetime whenever we
     /// ask for the scope of an expression categorized as an upvar.
     item_ub: region::CodeExtent,
-    generator: bool,
 }
 
 impl<'a, 'tcx> euv::Delegate<'tcx> for GatherLoanCtxt<'a, 'tcx> {
@@ -219,19 +216,6 @@ fn check_aliasability<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>,
     }
 }
 
-fn check_yields<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>,
-                          borrow_span: Span,
-                          loan_region: ty::Region<'tcx>) {
-    if let &ty::RegionKind::ReScope(extent) = loan_region {
-        if extent_has_yield(bccx.tcx, extent) {
-             span_err!(bccx.tcx.sess,
-                borrow_span,
-                E0624,
-                "cannot borrow this value across the suspend point of a generator");
-        }
-    }
-}
-
 /// Implements the M-* rules in README.md.
 fn check_mutability<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>,
                               borrow_span: Span,
@@ -343,11 +327,6 @@ fn guarantee_valid(&mut self,
             return;
         }
 
-        // Check that the region has no yields if this is in a generator
-        if self.generator {
-            check_yields(self.bccx, borrow_span, loan_region);
-        }
-
         // Check that the lifetime of the borrow does not exceed
         // the lifetime of the data being borrowed.
         if lifetime::guarantee_lifetime(self.bccx, self.item_ub,
index 2ae9498d63cfd9e913709036f92c7874826652cf..cc9bdf8c8a553098296aafcf7ab4715819d5aaa9 100644 (file)
@@ -1192,5 +1192,4 @@ struct Foo<'a> {
     E0595, // closure cannot assign to {}
     E0598, // lifetime of {} is too short to guarantee its contents can be...
     E0623, // borrow of the implicit argument of a generator
-    E0624, // borrow across a suspend point
 }