1
Fork 0

Rollup merge of #104055 - AndyJado:bck_errors, r=davidtwco

Migrate diagnostics in `rustc_borrowck`

sorry for making a new PR, [#103559](https://github.com/rust-lang/rust/pull/103559) and [#103960](https://github.com/rust-lang/rust/pull/103960).

I am crawling, joyfully.
This commit is contained in:
Matthias Krüger 2023-04-17 18:13:33 +02:00 committed by GitHub
commit 91fe117418
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 612 additions and 252 deletions

View file

@ -231,14 +231,18 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
}
}
if suggest {
borrow_spans.var_span_label(
&mut err,
format!(
"mutable borrow occurs due to use of {} in closure",
self.describe_any_place(access_place.as_ref()),
),
"mutable",
);
borrow_spans.var_subdiag(
None,
&mut err,
Some(mir::BorrowKind::Mut { allow_two_phase_borrow: false }),
|_kind, var_span| {
let place = self.describe_any_place(access_place.as_ref());
crate::session_diagnostics::CaptureVarCause::MutableBorrowUsePlaceClosure {
place,
var_span,
}
},
);
}
borrow_span
}