Skip to content

Commit 279c9d3

Browse files
committed
Remove no longer used MutateMode enum
1 parent 000b36c commit 279c9d3

File tree

2 files changed

+18
-54
lines changed

2 files changed

+18
-54
lines changed

compiler/rustc_borrowck/src/invalidation.rs

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ use rustc_middle::ty::TyCtxt;
88

99
use crate::{
1010
borrow_set::BorrowSet, facts::AllFacts, location::LocationTable, path_utils::*, AccessDepth,
11-
Activation, ArtificialField, BorrowIndex, Deep, JustWrite, LocalMutationIsAllowed, MutateMode,
12-
Read, ReadKind, ReadOrWrite, Reservation, Shallow, Write, WriteKind,
11+
Activation, ArtificialField, BorrowIndex, Deep, LocalMutationIsAllowed, Read, ReadKind,
12+
ReadOrWrite, Reservation, Shallow, Write, WriteKind,
1313
};
1414

1515
pub(super) fn generate_invalidates<'tcx>(
@@ -58,13 +58,13 @@ impl<'cx, 'tcx> Visitor<'tcx> for InvalidationGenerator<'cx, 'tcx> {
5858
StatementKind::Assign(box (lhs, rhs)) => {
5959
self.consume_rvalue(location, rhs);
6060

61-
self.mutate_place(location, *lhs, Shallow(None), JustWrite);
61+
self.mutate_place(location, *lhs, Shallow(None));
6262
}
6363
StatementKind::FakeRead(box (_, _)) => {
6464
// Only relevant for initialized/liveness/safety checks.
6565
}
6666
StatementKind::SetDiscriminant { place, variant_index: _ } => {
67-
self.mutate_place(location, **place, Shallow(None), JustWrite);
67+
self.mutate_place(location, **place, Shallow(None));
6868
}
6969
StatementKind::CopyNonOverlapping(box rustc_middle::mir::CopyNonOverlapping {
7070
ref src,
@@ -117,7 +117,7 @@ impl<'cx, 'tcx> Visitor<'tcx> for InvalidationGenerator<'cx, 'tcx> {
117117
target: _,
118118
unwind: _,
119119
} => {
120-
self.mutate_place(location, *drop_place, Deep, JustWrite);
120+
self.mutate_place(location, *drop_place, Deep);
121121
self.consume_operand(location, new_value);
122122
}
123123
TerminatorKind::Call {
@@ -133,7 +133,7 @@ impl<'cx, 'tcx> Visitor<'tcx> for InvalidationGenerator<'cx, 'tcx> {
133133
self.consume_operand(location, arg);
134134
}
135135
if let Some((dest, _ /*bb*/)) = destination {
136-
self.mutate_place(location, *dest, Deep, JustWrite);
136+
self.mutate_place(location, *dest, Deep);
137137
}
138138
}
139139
TerminatorKind::Assert { ref cond, expected: _, ref msg, target: _, cleanup: _ } => {
@@ -156,7 +156,7 @@ impl<'cx, 'tcx> Visitor<'tcx> for InvalidationGenerator<'cx, 'tcx> {
156156
}
157157
}
158158

159-
self.mutate_place(location, *resume_arg, Deep, JustWrite);
159+
self.mutate_place(location, *resume_arg, Deep);
160160
}
161161
TerminatorKind::Resume | TerminatorKind::Return | TerminatorKind::GeneratorDrop => {
162162
// Invalidate all borrows of local places
@@ -183,13 +183,13 @@ impl<'cx, 'tcx> Visitor<'tcx> for InvalidationGenerator<'cx, 'tcx> {
183183
}
184184
InlineAsmOperand::Out { reg: _, late: _, place, .. } => {
185185
if let Some(place) = place {
186-
self.mutate_place(location, place, Shallow(None), JustWrite);
186+
self.mutate_place(location, place, Shallow(None));
187187
}
188188
}
189189
InlineAsmOperand::InOut { reg: _, late: _, ref in_value, out_place } => {
190190
self.consume_operand(location, in_value);
191191
if let Some(out_place) = out_place {
192-
self.mutate_place(location, out_place, Shallow(None), JustWrite);
192+
self.mutate_place(location, out_place, Shallow(None));
193193
}
194194
}
195195
InlineAsmOperand::Const { value: _ }
@@ -213,13 +213,7 @@ impl<'cx, 'tcx> Visitor<'tcx> for InvalidationGenerator<'cx, 'tcx> {
213213

214214
impl<'cx, 'tcx> InvalidationGenerator<'cx, 'tcx> {
215215
/// Simulates mutation of a place.
216-
fn mutate_place(
217-
&mut self,
218-
location: Location,
219-
place: Place<'tcx>,
220-
kind: AccessDepth,
221-
_mode: MutateMode,
222-
) {
216+
fn mutate_place(&mut self, location: Location, place: Place<'tcx>, kind: AccessDepth) {
223217
self.access_place(
224218
location,
225219
place,

compiler/rustc_borrowck/src/lib.rs

Lines changed: 8 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ use rustc_mir_dataflow::MoveDataParamEnv;
5454
use self::diagnostics::{AccessKind, RegionName};
5555
use self::location::LocationTable;
5656
use self::prefixes::PrefixSet;
57-
use self::MutateMode::JustWrite;
5857
use facts::AllFacts;
5958

6059
use self::path_utils::*;
@@ -629,7 +628,7 @@ impl<'cx, 'tcx> rustc_mir_dataflow::ResultsVisitor<'cx, 'tcx> for MirBorrowckCtx
629628
StatementKind::Assign(box (lhs, ref rhs)) => {
630629
self.consume_rvalue(location, (rhs, span), flow_state);
631630

632-
self.mutate_place(location, (*lhs, span), Shallow(None), JustWrite, flow_state);
631+
self.mutate_place(location, (*lhs, span), Shallow(None), flow_state);
633632
}
634633
StatementKind::FakeRead(box (_, ref place)) => {
635634
// Read for match doesn't access any memory and is used to
@@ -650,7 +649,7 @@ impl<'cx, 'tcx> rustc_mir_dataflow::ResultsVisitor<'cx, 'tcx> for MirBorrowckCtx
650649
);
651650
}
652651
StatementKind::SetDiscriminant { place, variant_index: _ } => {
653-
self.mutate_place(location, (**place, span), Shallow(None), JustWrite, flow_state);
652+
self.mutate_place(location, (**place, span), Shallow(None), flow_state);
654653
}
655654
StatementKind::CopyNonOverlapping(box rustc_middle::mir::CopyNonOverlapping {
656655
..
@@ -716,7 +715,7 @@ impl<'cx, 'tcx> rustc_mir_dataflow::ResultsVisitor<'cx, 'tcx> for MirBorrowckCtx
716715
target: _,
717716
unwind: _,
718717
} => {
719-
self.mutate_place(loc, (drop_place, span), Deep, JustWrite, flow_state);
718+
self.mutate_place(loc, (drop_place, span), Deep, flow_state);
720719
self.consume_operand(loc, (new_value, span), flow_state);
721720
}
722721
TerminatorKind::Call {
@@ -732,7 +731,7 @@ impl<'cx, 'tcx> rustc_mir_dataflow::ResultsVisitor<'cx, 'tcx> for MirBorrowckCtx
732731
self.consume_operand(loc, (arg, span), flow_state);
733732
}
734733
if let Some((dest, _ /*bb*/)) = *destination {
735-
self.mutate_place(loc, (dest, span), Deep, JustWrite, flow_state);
734+
self.mutate_place(loc, (dest, span), Deep, flow_state);
736735
}
737736
}
738737
TerminatorKind::Assert { ref cond, expected: _, ref msg, target: _, cleanup: _ } => {
@@ -746,7 +745,7 @@ impl<'cx, 'tcx> rustc_mir_dataflow::ResultsVisitor<'cx, 'tcx> for MirBorrowckCtx
746745

747746
TerminatorKind::Yield { ref value, resume: _, resume_arg, drop: _ } => {
748747
self.consume_operand(loc, (value, span), flow_state);
749-
self.mutate_place(loc, (resume_arg, span), Deep, JustWrite, flow_state);
748+
self.mutate_place(loc, (resume_arg, span), Deep, flow_state);
750749
}
751750

752751
TerminatorKind::InlineAsm {
@@ -764,13 +763,7 @@ impl<'cx, 'tcx> rustc_mir_dataflow::ResultsVisitor<'cx, 'tcx> for MirBorrowckCtx
764763
}
765764
InlineAsmOperand::Out { reg: _, late: _, place, .. } => {
766765
if let Some(place) = place {
767-
self.mutate_place(
768-
loc,
769-
(place, span),
770-
Shallow(None),
771-
JustWrite,
772-
flow_state,
773-
);
766+
self.mutate_place(loc, (place, span), Shallow(None), flow_state);
774767
}
775768
}
776769
InlineAsmOperand::InOut { reg: _, late: _, ref in_value, out_place } => {
@@ -780,7 +773,6 @@ impl<'cx, 'tcx> rustc_mir_dataflow::ResultsVisitor<'cx, 'tcx> for MirBorrowckCtx
780773
loc,
781774
(out_place, span),
782775
Shallow(None),
783-
JustWrite,
784776
flow_state,
785777
);
786778
}
@@ -852,12 +844,6 @@ impl<'cx, 'tcx> rustc_mir_dataflow::ResultsVisitor<'cx, 'tcx> for MirBorrowckCtx
852844
}
853845
}
854846

855-
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
856-
enum MutateMode {
857-
JustWrite,
858-
WriteAndRead,
859-
}
860-
861847
use self::AccessDepth::{Deep, Shallow};
862848
use self::ReadOrWrite::{Activation, Read, Reservation, Write};
863849

@@ -943,7 +929,6 @@ enum LocalMutationIsAllowed {
943929

944930
#[derive(Copy, Clone, Debug)]
945931
enum InitializationRequiringAction {
946-
Update,
947932
Borrow,
948933
MatchOn,
949934
Use,
@@ -960,7 +945,6 @@ struct RootPlace<'tcx> {
960945
impl InitializationRequiringAction {
961946
fn as_noun(self) -> &'static str {
962947
match self {
963-
InitializationRequiringAction::Update => "update",
964948
InitializationRequiringAction::Borrow => "borrow",
965949
InitializationRequiringAction::MatchOn => "use", // no good noun
966950
InitializationRequiringAction::Use => "use",
@@ -971,7 +955,6 @@ impl InitializationRequiringAction {
971955

972956
fn as_verb_in_past_tense(self) -> &'static str {
973957
match self {
974-
InitializationRequiringAction::Update => "updated",
975958
InitializationRequiringAction::Borrow => "borrowed",
976959
InitializationRequiringAction::MatchOn => "matched on",
977960
InitializationRequiringAction::Use => "used",
@@ -1208,23 +1191,10 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
12081191
location: Location,
12091192
place_span: (Place<'tcx>, Span),
12101193
kind: AccessDepth,
1211-
mode: MutateMode,
12121194
flow_state: &Flows<'cx, 'tcx>,
12131195
) {
1214-
// Write of P[i] or *P, or WriteAndRead of any P, requires P init'd.
1215-
match mode {
1216-
MutateMode::WriteAndRead => {
1217-
self.check_if_path_or_subpath_is_moved(
1218-
location,
1219-
InitializationRequiringAction::Update,
1220-
(place_span.0.as_ref(), place_span.1),
1221-
flow_state,
1222-
);
1223-
}
1224-
MutateMode::JustWrite => {
1225-
self.check_if_assigned_path_is_moved(location, place_span, flow_state);
1226-
}
1227-
}
1196+
// Write of P[i] or *P requires P init'd.
1197+
self.check_if_assigned_path_is_moved(location, place_span, flow_state);
12281198

12291199
// Special case: you can assign an immutable local variable
12301200
// (e.g., `x = ...`) so long as it has never been initialized

0 commit comments

Comments
 (0)