diff options
| author | Keith Yeung <kungfukeith11@gmail.com> | 2017-09-23 11:52:53 -0700 |
|---|---|---|
| committer | Keith Yeung <kungfukeith11@gmail.com> | 2017-09-23 23:44:51 -0700 |
| commit | ed59a868dddbd56749c13bc7ddc7ea849d83e107 (patch) | |
| tree | be5dd3a337eb5d2873bf7956560a4b3272c36983 | |
| parent | 1797a942b710f911cb5b0b0ae56b5dcf62a81d2d (diff) | |
| download | rust-ed59a868dddbd56749c13bc7ddc7ea849d83e107.tar.gz rust-ed59a868dddbd56749c13bc7ddc7ea849d83e107.zip | |
Add span labels for E0505 for MIR borrowck
| -rw-r--r-- | src/librustc_mir/borrow_check.rs | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/src/librustc_mir/borrow_check.rs b/src/librustc_mir/borrow_check.rs index 9b478fe2309..10825323e41 100644 --- a/src/librustc_mir/borrow_check.rs +++ b/src/librustc_mir/borrow_check.rs @@ -408,7 +408,7 @@ impl<'c, 'b, 'a: 'b+'c, 'gcx, 'tcx: 'a> MirBorrowckCtxt<'c, 'b, 'a, 'gcx, 'tcx> self.each_borrow_involving_path( context, lvalue_span.0, flow_state, |this, _idx, borrow| { if !borrow.compatible_with(BorrowKind::Mut) { - this.report_move_out_while_borrowed(context, lvalue_span); + this.report_move_out_while_borrowed(context, lvalue_span, borrow); Control::Break } else { Control::Continue @@ -907,12 +907,17 @@ impl<'c, 'b, 'a: 'b+'c, 'gcx, 'tcx: 'a> MirBorrowckCtxt<'c, 'b, 'a, 'gcx, 'tcx> fn report_move_out_while_borrowed(&mut self, _context: Context, - (lvalue, span): (&Lvalue, Span)) { - let mut err = self.tcx.cannot_move_when_borrowed( - span, &self.describe_lvalue(lvalue), Origin::Mir); - // FIXME 1: add span_label for "borrow of `()` occurs here" - // FIXME 2: add span_label for "move out of `{}` occurs here" - err.emit(); + (lvalue, span): (&Lvalue, Span), + borrow: &BorrowData) { + self.tcx.cannot_move_when_borrowed(span, + &self.describe_lvalue(lvalue), + Origin::Mir) + .span_label(self.retrieve_borrow_span(borrow), + format!("borrow of `{}` occurs here", + self.describe_lvalue(&borrow.lvalue))) + .span_label(span, format!("move out of `{}` occurs here", + self.describe_lvalue(lvalue))) + .emit(); } fn report_use_while_mutably_borrowed(&mut self, |
