Replaced String with &str in API for add_explanation_to_diagnostic.
This commit is contained in:
parent
9eebe77a86
commit
504ab34e62
2 changed files with 14 additions and 14 deletions
|
|
@ -262,7 +262,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
|
|||
move_spans.var_span_label(&mut err, "move occurs due to use in closure");
|
||||
|
||||
self.explain_why_borrow_contains_point(context, borrow, None)
|
||||
.add_explanation_to_diagnostic(self.infcx.tcx, self.mir, &mut err, String::new());
|
||||
.add_explanation_to_diagnostic(self.infcx.tcx, self.mir, &mut err, "");
|
||||
err.buffer(&mut self.errors_buffer);
|
||||
}
|
||||
|
||||
|
|
@ -299,7 +299,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
|
|||
});
|
||||
|
||||
self.explain_why_borrow_contains_point(context, borrow, None)
|
||||
.add_explanation_to_diagnostic(self.infcx.tcx, self.mir, &mut err, String::new());
|
||||
.add_explanation_to_diagnostic(self.infcx.tcx, self.mir, &mut err, "");
|
||||
err.buffer(&mut self.errors_buffer);
|
||||
}
|
||||
|
||||
|
|
@ -483,7 +483,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
|
|||
}
|
||||
|
||||
self.explain_why_borrow_contains_point(context, issued_borrow, None)
|
||||
.add_explanation_to_diagnostic(self.infcx.tcx, self.mir, &mut err, first_borrow_desc.to_string());
|
||||
.add_explanation_to_diagnostic(self.infcx.tcx, self.mir, &mut err, first_borrow_desc);
|
||||
|
||||
err.buffer(&mut self.errors_buffer);
|
||||
}
|
||||
|
|
@ -638,7 +638,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
|
|||
|
||||
if let BorrowExplanation::MustBeValidFor(..) = explanation {
|
||||
} else {
|
||||
explanation.add_explanation_to_diagnostic(self.infcx.tcx, self.mir, &mut err, String::new());
|
||||
explanation.add_explanation_to_diagnostic(self.infcx.tcx, self.mir, &mut err, "");
|
||||
}
|
||||
} else {
|
||||
err.span_label(borrow_span, "borrowed value does not live long enough");
|
||||
|
|
@ -649,7 +649,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
|
|||
|
||||
borrow_spans.args_span_label(&mut err, "value captured here");
|
||||
|
||||
explanation.add_explanation_to_diagnostic(self.infcx.tcx, self.mir, &mut err, String::new());
|
||||
explanation.add_explanation_to_diagnostic(self.infcx.tcx, self.mir, &mut err, "");
|
||||
}
|
||||
|
||||
err
|
||||
|
|
@ -709,7 +709,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
|
|||
_ => {}
|
||||
}
|
||||
|
||||
explanation.add_explanation_to_diagnostic(self.infcx.tcx, self.mir, &mut err, String::new());
|
||||
explanation.add_explanation_to_diagnostic(self.infcx.tcx, self.mir, &mut err, "");
|
||||
|
||||
err.buffer(&mut self.errors_buffer);
|
||||
}
|
||||
|
|
@ -776,7 +776,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
|
|||
}
|
||||
_ => {}
|
||||
}
|
||||
explanation.add_explanation_to_diagnostic(self.infcx.tcx, self.mir, &mut err, String::new());
|
||||
explanation.add_explanation_to_diagnostic(self.infcx.tcx, self.mir, &mut err, "");
|
||||
|
||||
borrow_spans.args_span_label(&mut err, "value captured here");
|
||||
|
||||
|
|
@ -913,7 +913,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
|
|||
loan_spans.var_span_label(&mut err, "borrow occurs due to use in closure");
|
||||
|
||||
self.explain_why_borrow_contains_point(context, loan, None)
|
||||
.add_explanation_to_diagnostic(self.infcx.tcx, self.mir, &mut err, String::new());
|
||||
.add_explanation_to_diagnostic(self.infcx.tcx, self.mir, &mut err, "");
|
||||
|
||||
err.buffer(&mut self.errors_buffer);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,20 +42,20 @@ impl<'tcx> BorrowExplanation<'tcx> {
|
|||
tcx: TyCtxt<'cx, 'gcx, 'tcx>,
|
||||
_mir: &Mir<'tcx>,
|
||||
err: &mut DiagnosticBuilder<'_>,
|
||||
borrow_desc: String,
|
||||
borrow_desc: &str,
|
||||
) {
|
||||
match *self {
|
||||
BorrowExplanation::UsedLater(later_use_kind, var_or_use_span) => {
|
||||
let message = borrow_desc + match later_use_kind {
|
||||
let message = match later_use_kind {
|
||||
LaterUseKind::ClosureCapture => "borrow later captured here by closure",
|
||||
LaterUseKind::Call => "borrow later used by call",
|
||||
LaterUseKind::FakeLetRead => "borrow later stored here",
|
||||
LaterUseKind::Other => "borrow later used here",
|
||||
};
|
||||
err.span_label(var_or_use_span, message);
|
||||
err.span_label(var_or_use_span, format!("{}{}", borrow_desc, message));
|
||||
},
|
||||
BorrowExplanation::UsedLaterInLoop(later_use_kind, var_or_use_span) => {
|
||||
let message = borrow_desc + match later_use_kind {
|
||||
let message = match later_use_kind {
|
||||
LaterUseKind::ClosureCapture => {
|
||||
"borrow captured here by closure, in later iteration of loop"
|
||||
},
|
||||
|
|
@ -63,7 +63,7 @@ impl<'tcx> BorrowExplanation<'tcx> {
|
|||
LaterUseKind::FakeLetRead => "borrow later stored here",
|
||||
LaterUseKind::Other => "borrow used here, in later iteration of loop",
|
||||
};
|
||||
err.span_label(var_or_use_span, message);
|
||||
err.span_label(var_or_use_span, format!("{}{}", borrow_desc, message));
|
||||
},
|
||||
BorrowExplanation::UsedLaterWhenDropped(span, local_name, should_note_order) => {
|
||||
err.span_label(
|
||||
|
|
@ -85,7 +85,7 @@ impl<'tcx> BorrowExplanation<'tcx> {
|
|||
BorrowExplanation::MustBeValidFor(region) => {
|
||||
tcx.note_and_explain_free_region(
|
||||
err,
|
||||
&(borrow_desc + "borrowed value must be valid for "),
|
||||
&format!("{}{}", borrow_desc, "borrowed value must be valid for "),
|
||||
region,
|
||||
"...",
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue