Revert borrowck changes
This commit is contained in:
parent
2ad0f89e86
commit
10def9a6e0
@ -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};
|
||||
|
||||
@ -37,20 +36,19 @@
|
||||
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,
|
||||
|
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user