address most easy comments
This commit is contained in:
parent
8fb4c41f35
commit
a52cc0a8c9
8 changed files with 33 additions and 42 deletions
|
@ -73,7 +73,10 @@ impl<'tcx> fmt::Display for BorrowData<'tcx> {
|
|||
mir::BorrowKind::Shared => "",
|
||||
mir::BorrowKind::Shallow => "shallow ",
|
||||
mir::BorrowKind::Mut { kind: mir::MutBorrowKind::ClosureCapture } => "uniq ",
|
||||
mir::BorrowKind::Mut { .. } => "mut ",
|
||||
// FIXME: differentiate `TwoPhaseBorrow`
|
||||
mir::BorrowKind::Mut {
|
||||
kind: mir::MutBorrowKind::Default | mir::MutBorrowKind::TwoPhaseBorrow,
|
||||
} => "mut ",
|
||||
};
|
||||
write!(w, "&{:?} {}{:?}", self.region, kind, self.borrowed_place)
|
||||
}
|
||||
|
|
|
@ -628,10 +628,9 @@ impl UseSpans<'_> {
|
|||
err.subdiagnostic(match kind {
|
||||
Some(kd) => match kd {
|
||||
rustc_middle::mir::BorrowKind::Shared
|
||||
| rustc_middle::mir::BorrowKind::Shallow
|
||||
| rustc_middle::mir::BorrowKind::Mut {
|
||||
kind: rustc_middle::mir::MutBorrowKind::ClosureCapture,
|
||||
} => CaptureVarKind::Immut { kind_span: capture_kind_span },
|
||||
| rustc_middle::mir::BorrowKind::Shallow => {
|
||||
CaptureVarKind::Immut { kind_span: capture_kind_span }
|
||||
}
|
||||
|
||||
rustc_middle::mir::BorrowKind::Mut { .. } => {
|
||||
CaptureVarKind::Mut { kind_span: capture_kind_span }
|
||||
|
|
|
@ -1958,14 +1958,15 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
|||
let the_place_err;
|
||||
|
||||
match kind {
|
||||
Reservation(WriteKind::MutableBorrow(borrow_kind @ BorrowKind::Mut { .. }))
|
||||
| Write(WriteKind::MutableBorrow(borrow_kind @ BorrowKind::Mut { .. })) => {
|
||||
let is_local_mutation_allowed = match borrow_kind {
|
||||
BorrowKind::Mut { kind: MutBorrowKind::ClosureCapture } => {
|
||||
LocalMutationIsAllowed::Yes
|
||||
Reservation(WriteKind::MutableBorrow(BorrowKind::Mut { kind: mut_borrow_kind }))
|
||||
| Write(WriteKind::MutableBorrow(BorrowKind::Mut { kind: mut_borrow_kind })) => {
|
||||
let is_local_mutation_allowed = match mut_borrow_kind {
|
||||
// `ClosureCapture` is used for mutable variable with a immutable binding.
|
||||
// This is only behaviour difference between `ClosureCapture` and mutable borrows.
|
||||
MutBorrowKind::ClosureCapture => LocalMutationIsAllowed::Yes,
|
||||
MutBorrowKind::Default | MutBorrowKind::TwoPhaseBorrow => {
|
||||
is_local_mutation_allowed
|
||||
}
|
||||
BorrowKind::Mut { .. } => is_local_mutation_allowed,
|
||||
BorrowKind::Shared | BorrowKind::Shallow => unreachable!(),
|
||||
};
|
||||
match self.is_mutable(place.as_ref(), is_local_mutation_allowed) {
|
||||
Ok(root_place) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue