Skip to content

Commit 9d444c2

Browse files
committed
remove borrowck duplicate of std::ops::ControlFlow
1 parent 79d761d commit 9d444c2

File tree

3 files changed

+16
-19
lines changed

3 files changed

+16
-19
lines changed

compiler/rustc_borrowck/src/lib.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
use std::cell::RefCell;
1919
use std::marker::PhantomData;
20-
use std::ops::Deref;
20+
use std::ops::{ControlFlow, Deref};
2121

2222
use rustc_abi::FieldIdx;
2323
use rustc_data_structures::fx::{FxIndexMap, FxIndexSet};
@@ -1053,31 +1053,31 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, '_, 'tcx> {
10531053
rw,
10541054
(borrow_index, borrow),
10551055
);
1056-
Control::Continue
1056+
ControlFlow::Continue(())
10571057
}
10581058

10591059
(Read(_), BorrowKind::Shared | BorrowKind::Fake(_))
10601060
| (
10611061
Read(ReadKind::Borrow(BorrowKind::Fake(FakeBorrowKind::Shallow))),
10621062
BorrowKind::Mut { .. },
1063-
) => Control::Continue,
1063+
) => ControlFlow::Continue(()),
10641064

10651065
(Reservation(_), BorrowKind::Fake(_) | BorrowKind::Shared) => {
10661066
// This used to be a future compatibility warning (to be
10671067
// disallowed on NLL). See rust-lang/rust#56254
1068-
Control::Continue
1068+
ControlFlow::Continue(())
10691069
}
10701070

10711071
(Write(WriteKind::Move), BorrowKind::Fake(FakeBorrowKind::Shallow)) => {
10721072
// Handled by initialization checks.
1073-
Control::Continue
1073+
ControlFlow::Continue(())
10741074
}
10751075

10761076
(Read(kind), BorrowKind::Mut { .. }) => {
10771077
// Reading from mere reservations of mutable-borrows is OK.
10781078
if !is_active(this.dominators(), borrow, location) {
10791079
assert!(borrow.kind.allows_two_phase_borrow());
1080-
return Control::Continue;
1080+
return ControlFlow::Continue(());
10811081
}
10821082

10831083
error_reported = true;
@@ -1093,7 +1093,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, '_, 'tcx> {
10931093
this.buffer_error(err);
10941094
}
10951095
}
1096-
Control::Break
1096+
ControlFlow::Break(())
10971097
}
10981098

10991099
(Reservation(kind) | Activation(kind, _) | Write(kind), _) => {
@@ -1140,7 +1140,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, '_, 'tcx> {
11401140
this.report_illegal_mutation_of_borrowed(location, place_span, borrow)
11411141
}
11421142
}
1143-
Control::Break
1143+
ControlFlow::Break(())
11441144
}
11451145
},
11461146
);

compiler/rustc_borrowck/src/path_utils.rs

+4-9
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use std::ops::ControlFlow;
2+
13
use rustc_abi::FieldIdx;
24
use rustc_data_structures::graph::dominators::Dominators;
35
use rustc_middle::mir::{BasicBlock, Body, Location, Place, PlaceRef, ProjectionElem};
@@ -7,13 +9,6 @@ use tracing::debug;
79
use crate::borrow_set::{BorrowData, BorrowSet, TwoPhaseActivation};
810
use crate::{AccessDepth, BorrowIndex, places_conflict};
911

10-
/// Control for the path borrow checking code
11-
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
12-
pub(super) enum Control {
13-
Continue,
14-
Break,
15-
}
16-
1712
/// Encapsulates the idea of iterating over every borrow that involves a particular path
1813
pub(super) fn each_borrow_involving_path<'tcx, F, I, S>(
1914
s: &mut S,
@@ -24,7 +19,7 @@ pub(super) fn each_borrow_involving_path<'tcx, F, I, S>(
2419
is_candidate: I,
2520
mut op: F,
2621
) where
27-
F: FnMut(&mut S, BorrowIndex, &BorrowData<'tcx>) -> Control,
22+
F: FnMut(&mut S, BorrowIndex, &BorrowData<'tcx>) -> ControlFlow<()>,
2823
I: Fn(BorrowIndex) -> bool,
2924
{
3025
let (access, place) = access_place;
@@ -55,7 +50,7 @@ pub(super) fn each_borrow_involving_path<'tcx, F, I, S>(
5550
i, borrowed, place, access
5651
);
5752
let ctrl = op(s, i, borrowed);
58-
if ctrl == Control::Break {
53+
if matches!(ctrl, ControlFlow::Break(_)) {
5954
return;
6055
}
6156
}

compiler/rustc_borrowck/src/polonius/legacy/loan_invalidations.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use std::ops::ControlFlow;
2+
13
use rustc_data_structures::graph::dominators::Dominators;
24
use rustc_middle::bug;
35
use rustc_middle::mir::visit::Visitor;
@@ -379,7 +381,7 @@ impl<'a, 'tcx> LoanInvalidationsGenerator<'a, 'tcx> {
379381
if !is_active(this.dominators, borrow, location) {
380382
// If the borrow isn't active yet, reads don't invalidate it
381383
assert!(borrow.kind.allows_two_phase_borrow());
382-
return Control::Continue;
384+
return ControlFlow::Continue(());
383385
}
384386

385387
// Unique and mutable borrows are invalidated by reads from any
@@ -395,7 +397,7 @@ impl<'a, 'tcx> LoanInvalidationsGenerator<'a, 'tcx> {
395397
this.emit_loan_invalidated_at(borrow_index, location);
396398
}
397399
}
398-
Control::Continue
400+
ControlFlow::Continue(())
399401
},
400402
);
401403
}

0 commit comments

Comments
 (0)