Skip to content

MIR-borrowck: Adding notes to E0506 #44811

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Sep 29, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
mir-borrowck: Add span labels to report_illegal_mutation_of_borrowed()
  • Loading branch information
zilbuz committed Sep 26, 2017
commit e28c73d71fd9a31de37daf45c086e2a8b05ec05c
8 changes: 7 additions & 1 deletion src/librustc_mir/borrow_check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -979,9 +979,15 @@ impl<'c, 'b, 'a: 'b+'c, 'gcx, 'tcx: 'a> MirBorrowckCtxt<'c, 'b, 'a, 'gcx, 'tcx>
_: Context,
(lvalue, span): (&Lvalue, Span),
loan: &BorrowData) {
let describe_lvalue = self.describe_lvalue(lvalue);
let borrow_span = self.retrieve_borrow_span(loan);

let mut err = self.tcx.cannot_assign_to_borrowed(
span, &self.describe_lvalue(lvalue), Origin::Mir);
// FIXME: add span labels for borrow and assignment points

err.span_label(borrow_span, format!("borrow of `{}` occurs here", describe_lvalue));
err.span_label(span, format!("assignment to borrowed `{}` occurs here", describe_lvalue));

err.emit();
}

Expand Down