Stop using dynamic borrowing in MoveErrorCollector
This commit is contained in:
parent
4f5edf9e38
commit
d842a54b25
@ -44,7 +44,7 @@ pub fn gather_decl<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>,
|
||||
|
||||
pub fn gather_move_from_expr<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>,
|
||||
move_data: &MoveData<'tcx>,
|
||||
move_error_collector: &MoveErrorCollector<'tcx>,
|
||||
move_error_collector: &mut MoveErrorCollector<'tcx>,
|
||||
move_expr_id: ast::NodeId,
|
||||
cmt: mc::cmt<'tcx>,
|
||||
move_reason: euv::MoveReason) {
|
||||
@ -63,7 +63,7 @@ pub fn gather_move_from_expr<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>,
|
||||
|
||||
pub fn gather_match_variant<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>,
|
||||
move_data: &MoveData<'tcx>,
|
||||
_move_error_collector: &MoveErrorCollector<'tcx>,
|
||||
_move_error_collector: &mut MoveErrorCollector<'tcx>,
|
||||
move_pat: &hir::Pat,
|
||||
cmt: mc::cmt<'tcx>,
|
||||
mode: euv::MatchMode) {
|
||||
@ -94,7 +94,7 @@ pub fn gather_match_variant<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>,
|
||||
|
||||
pub fn gather_move_from_pat<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>,
|
||||
move_data: &MoveData<'tcx>,
|
||||
move_error_collector: &MoveErrorCollector<'tcx>,
|
||||
move_error_collector: &mut MoveErrorCollector<'tcx>,
|
||||
move_pat: &hir::Pat,
|
||||
cmt: mc::cmt<'tcx>) {
|
||||
let pat_span_path_opt = match move_pat.node {
|
||||
@ -115,7 +115,7 @@ pub fn gather_move_from_pat<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>,
|
||||
|
||||
fn gather_move<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>,
|
||||
move_data: &MoveData<'tcx>,
|
||||
move_error_collector: &MoveErrorCollector<'tcx>,
|
||||
move_error_collector: &mut MoveErrorCollector<'tcx>,
|
||||
move_info: GatherMoveInfo<'tcx>) {
|
||||
debug!("gather_move(move_id={}, cmt={:?})",
|
||||
move_info.id, move_info.cmt);
|
||||
|
@ -86,7 +86,7 @@ impl<'a, 'tcx> euv::Delegate<'tcx> for GatherLoanCtxt<'a, 'tcx> {
|
||||
match mode {
|
||||
euv::Move(move_reason) => {
|
||||
gather_moves::gather_move_from_expr(
|
||||
self.bccx, &self.move_data, &self.move_error_collector,
|
||||
self.bccx, &self.move_data, &mut self.move_error_collector,
|
||||
consume_id, cmt, move_reason);
|
||||
}
|
||||
euv::Copy => { }
|
||||
@ -104,7 +104,7 @@ impl<'a, 'tcx> euv::Delegate<'tcx> for GatherLoanCtxt<'a, 'tcx> {
|
||||
|
||||
if let Categorization::Downcast(..) = cmt.cat {
|
||||
gather_moves::gather_match_variant(
|
||||
self.bccx, &self.move_data, &self.move_error_collector,
|
||||
self.bccx, &self.move_data, &mut self.move_error_collector,
|
||||
matched_pat, cmt, mode);
|
||||
}
|
||||
}
|
||||
@ -124,7 +124,7 @@ impl<'a, 'tcx> euv::Delegate<'tcx> for GatherLoanCtxt<'a, 'tcx> {
|
||||
}
|
||||
|
||||
gather_moves::gather_move_from_pat(
|
||||
self.bccx, &self.move_data, &self.move_error_collector,
|
||||
self.bccx, &self.move_data, &mut self.move_error_collector,
|
||||
consume_pat, cmt);
|
||||
}
|
||||
|
||||
|
@ -13,28 +13,27 @@ use rustc::middle::mem_categorization as mc;
|
||||
use rustc::middle::mem_categorization::Categorization;
|
||||
use rustc::middle::mem_categorization::InteriorOffsetKind as Kind;
|
||||
use rustc::middle::ty;
|
||||
use std::cell::RefCell;
|
||||
use syntax::ast;
|
||||
use syntax::codemap;
|
||||
use rustc_front::hir;
|
||||
|
||||
pub struct MoveErrorCollector<'tcx> {
|
||||
errors: RefCell<Vec<MoveError<'tcx>>>
|
||||
errors: Vec<MoveError<'tcx>>
|
||||
}
|
||||
|
||||
impl<'tcx> MoveErrorCollector<'tcx> {
|
||||
pub fn new() -> MoveErrorCollector<'tcx> {
|
||||
MoveErrorCollector {
|
||||
errors: RefCell::new(Vec::new())
|
||||
errors: Vec::new()
|
||||
}
|
||||
}
|
||||
|
||||
pub fn add_error(&self, error: MoveError<'tcx>) {
|
||||
self.errors.borrow_mut().push(error);
|
||||
pub fn add_error(&mut self, error: MoveError<'tcx>) {
|
||||
self.errors.push(error);
|
||||
}
|
||||
|
||||
pub fn report_potential_errors<'a>(&self, bccx: &BorrowckCtxt<'a, 'tcx>) {
|
||||
report_move_errors(bccx, &*self.errors.borrow())
|
||||
report_move_errors(bccx, &self.errors)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user