Skip to content

Commit 490c17a

Browse files
committed
remove borrowck duplicate of std::ops::ControlFlow
1 parent a64591b commit 490c17a

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
@@ -18,7 +18,7 @@
1818
use std::cell::RefCell;
1919
use std::collections::BTreeMap;
2020
use std::marker::PhantomData;
21-
use std::ops::Deref;
21+
use std::ops::{ControlFlow, Deref};
2222

2323
use rustc_abi::FieldIdx;
2424
use rustc_data_structures::fx::{FxIndexMap, FxIndexSet};
@@ -1050,31 +1050,31 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, '_, 'tcx> {
10501050
rw,
10511051
(borrow_index, borrow),
10521052
);
1053-
Control::Continue
1053+
ControlFlow::Continue(())
10541054
}
10551055

10561056
(Read(_), BorrowKind::Shared | BorrowKind::Fake(_))
10571057
| (
10581058
Read(ReadKind::Borrow(BorrowKind::Fake(FakeBorrowKind::Shallow))),
10591059
BorrowKind::Mut { .. },
1060-
) => Control::Continue,
1060+
) => ControlFlow::Continue(()),
10611061

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

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

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

10801080
error_reported = true;
@@ -1090,7 +1090,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, '_, 'tcx> {
10901090
this.buffer_error(err);
10911091
}
10921092
}
1093-
Control::Break
1093+
ControlFlow::Break(())
10941094
}
10951095

10961096
(Reservation(kind) | Activation(kind, _) | Write(kind), _) => {
@@ -1137,7 +1137,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, '_, 'tcx> {
11371137
this.report_illegal_mutation_of_borrowed(location, place_span, borrow)
11381138
}
11391139
}
1140-
Control::Break
1140+
ControlFlow::Break(())
11411141
}
11421142
},
11431143
);

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;
@@ -380,7 +382,7 @@ impl<'a, 'tcx> LoanInvalidationsGenerator<'a, 'tcx> {
380382
if !is_active(this.dominators, borrow, location) {
381383
// If the borrow isn't active yet, reads don't invalidate it
382384
assert!(borrow.kind.allows_two_phase_borrow());
383-
return Control::Continue;
385+
return ControlFlow::Continue(());
384386
}
385387

386388
// Unique and mutable borrows are invalidated by reads from any
@@ -396,7 +398,7 @@ impl<'a, 'tcx> LoanInvalidationsGenerator<'a, 'tcx> {
396398
this.emit_loan_invalidated_at(borrow_index, location);
397399
}
398400
}
399-
Control::Continue
401+
ControlFlow::Continue(())
400402
},
401403
);
402404
}

0 commit comments

Comments
 (0)