remove borrowck duplicate of std::ops::ControlFlow
This commit is contained in:
parent
79d761d93c
commit
9d444c26c9
3 changed files with 16 additions and 19 deletions
|
@ -17,7 +17,7 @@
|
||||||
|
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
use std::marker::PhantomData;
|
use std::marker::PhantomData;
|
||||||
use std::ops::Deref;
|
use std::ops::{ControlFlow, Deref};
|
||||||
|
|
||||||
use rustc_abi::FieldIdx;
|
use rustc_abi::FieldIdx;
|
||||||
use rustc_data_structures::fx::{FxIndexMap, FxIndexSet};
|
use rustc_data_structures::fx::{FxIndexMap, FxIndexSet};
|
||||||
|
@ -1053,31 +1053,31 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, '_, 'tcx> {
|
||||||
rw,
|
rw,
|
||||||
(borrow_index, borrow),
|
(borrow_index, borrow),
|
||||||
);
|
);
|
||||||
Control::Continue
|
ControlFlow::Continue(())
|
||||||
}
|
}
|
||||||
|
|
||||||
(Read(_), BorrowKind::Shared | BorrowKind::Fake(_))
|
(Read(_), BorrowKind::Shared | BorrowKind::Fake(_))
|
||||||
| (
|
| (
|
||||||
Read(ReadKind::Borrow(BorrowKind::Fake(FakeBorrowKind::Shallow))),
|
Read(ReadKind::Borrow(BorrowKind::Fake(FakeBorrowKind::Shallow))),
|
||||||
BorrowKind::Mut { .. },
|
BorrowKind::Mut { .. },
|
||||||
) => Control::Continue,
|
) => ControlFlow::Continue(()),
|
||||||
|
|
||||||
(Reservation(_), BorrowKind::Fake(_) | BorrowKind::Shared) => {
|
(Reservation(_), BorrowKind::Fake(_) | BorrowKind::Shared) => {
|
||||||
// This used to be a future compatibility warning (to be
|
// This used to be a future compatibility warning (to be
|
||||||
// disallowed on NLL). See rust-lang/rust#56254
|
// disallowed on NLL). See rust-lang/rust#56254
|
||||||
Control::Continue
|
ControlFlow::Continue(())
|
||||||
}
|
}
|
||||||
|
|
||||||
(Write(WriteKind::Move), BorrowKind::Fake(FakeBorrowKind::Shallow)) => {
|
(Write(WriteKind::Move), BorrowKind::Fake(FakeBorrowKind::Shallow)) => {
|
||||||
// Handled by initialization checks.
|
// Handled by initialization checks.
|
||||||
Control::Continue
|
ControlFlow::Continue(())
|
||||||
}
|
}
|
||||||
|
|
||||||
(Read(kind), BorrowKind::Mut { .. }) => {
|
(Read(kind), BorrowKind::Mut { .. }) => {
|
||||||
// Reading from mere reservations of mutable-borrows is OK.
|
// Reading from mere reservations of mutable-borrows is OK.
|
||||||
if !is_active(this.dominators(), borrow, location) {
|
if !is_active(this.dominators(), borrow, location) {
|
||||||
assert!(borrow.kind.allows_two_phase_borrow());
|
assert!(borrow.kind.allows_two_phase_borrow());
|
||||||
return Control::Continue;
|
return ControlFlow::Continue(());
|
||||||
}
|
}
|
||||||
|
|
||||||
error_reported = true;
|
error_reported = true;
|
||||||
|
@ -1093,7 +1093,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, '_, 'tcx> {
|
||||||
this.buffer_error(err);
|
this.buffer_error(err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Control::Break
|
ControlFlow::Break(())
|
||||||
}
|
}
|
||||||
|
|
||||||
(Reservation(kind) | Activation(kind, _) | Write(kind), _) => {
|
(Reservation(kind) | Activation(kind, _) | Write(kind), _) => {
|
||||||
|
@ -1140,7 +1140,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, '_, 'tcx> {
|
||||||
this.report_illegal_mutation_of_borrowed(location, place_span, borrow)
|
this.report_illegal_mutation_of_borrowed(location, place_span, borrow)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Control::Break
|
ControlFlow::Break(())
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
use std::ops::ControlFlow;
|
||||||
|
|
||||||
use rustc_abi::FieldIdx;
|
use rustc_abi::FieldIdx;
|
||||||
use rustc_data_structures::graph::dominators::Dominators;
|
use rustc_data_structures::graph::dominators::Dominators;
|
||||||
use rustc_middle::mir::{BasicBlock, Body, Location, Place, PlaceRef, ProjectionElem};
|
use rustc_middle::mir::{BasicBlock, Body, Location, Place, PlaceRef, ProjectionElem};
|
||||||
|
@ -7,13 +9,6 @@ use tracing::debug;
|
||||||
use crate::borrow_set::{BorrowData, BorrowSet, TwoPhaseActivation};
|
use crate::borrow_set::{BorrowData, BorrowSet, TwoPhaseActivation};
|
||||||
use crate::{AccessDepth, BorrowIndex, places_conflict};
|
use crate::{AccessDepth, BorrowIndex, places_conflict};
|
||||||
|
|
||||||
/// Control for the path borrow checking code
|
|
||||||
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
|
|
||||||
pub(super) enum Control {
|
|
||||||
Continue,
|
|
||||||
Break,
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Encapsulates the idea of iterating over every borrow that involves a particular path
|
/// Encapsulates the idea of iterating over every borrow that involves a particular path
|
||||||
pub(super) fn each_borrow_involving_path<'tcx, F, I, S>(
|
pub(super) fn each_borrow_involving_path<'tcx, F, I, S>(
|
||||||
s: &mut S,
|
s: &mut S,
|
||||||
|
@ -24,7 +19,7 @@ pub(super) fn each_borrow_involving_path<'tcx, F, I, S>(
|
||||||
is_candidate: I,
|
is_candidate: I,
|
||||||
mut op: F,
|
mut op: F,
|
||||||
) where
|
) where
|
||||||
F: FnMut(&mut S, BorrowIndex, &BorrowData<'tcx>) -> Control,
|
F: FnMut(&mut S, BorrowIndex, &BorrowData<'tcx>) -> ControlFlow<()>,
|
||||||
I: Fn(BorrowIndex) -> bool,
|
I: Fn(BorrowIndex) -> bool,
|
||||||
{
|
{
|
||||||
let (access, place) = access_place;
|
let (access, place) = access_place;
|
||||||
|
@ -55,7 +50,7 @@ pub(super) fn each_borrow_involving_path<'tcx, F, I, S>(
|
||||||
i, borrowed, place, access
|
i, borrowed, place, access
|
||||||
);
|
);
|
||||||
let ctrl = op(s, i, borrowed);
|
let ctrl = op(s, i, borrowed);
|
||||||
if ctrl == Control::Break {
|
if matches!(ctrl, ControlFlow::Break(_)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
use std::ops::ControlFlow;
|
||||||
|
|
||||||
use rustc_data_structures::graph::dominators::Dominators;
|
use rustc_data_structures::graph::dominators::Dominators;
|
||||||
use rustc_middle::bug;
|
use rustc_middle::bug;
|
||||||
use rustc_middle::mir::visit::Visitor;
|
use rustc_middle::mir::visit::Visitor;
|
||||||
|
@ -379,7 +381,7 @@ impl<'a, 'tcx> LoanInvalidationsGenerator<'a, 'tcx> {
|
||||||
if !is_active(this.dominators, borrow, location) {
|
if !is_active(this.dominators, borrow, location) {
|
||||||
// If the borrow isn't active yet, reads don't invalidate it
|
// If the borrow isn't active yet, reads don't invalidate it
|
||||||
assert!(borrow.kind.allows_two_phase_borrow());
|
assert!(borrow.kind.allows_two_phase_borrow());
|
||||||
return Control::Continue;
|
return ControlFlow::Continue(());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unique and mutable borrows are invalidated by reads from any
|
// Unique and mutable borrows are invalidated by reads from any
|
||||||
|
@ -395,7 +397,7 @@ impl<'a, 'tcx> LoanInvalidationsGenerator<'a, 'tcx> {
|
||||||
this.emit_loan_invalidated_at(borrow_index, location);
|
this.emit_loan_invalidated_at(borrow_index, location);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Control::Continue
|
ControlFlow::Continue(())
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue