Skip to content

Commit 33abf6a

Browse files
committed
Add defaults for Analysis::apply_{call_return_effect,terminator_effect}.
To avoid some low-value boilerplate code.
1 parent ba13775 commit 33abf6a

File tree

5 files changed

+11
-72
lines changed

5 files changed

+11
-72
lines changed

compiler/rustc_borrowck/src/dataflow.rs

+1-11
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
use rustc_data_structures::fx::FxIndexMap;
22
use rustc_data_structures::graph;
33
use rustc_index::bit_set::BitSet;
4-
use rustc_middle::mir::{
5-
self, BasicBlock, Body, CallReturnPlaces, Location, Place, TerminatorEdges,
6-
};
4+
use rustc_middle::mir::{self, BasicBlock, Body, Location, Place, TerminatorEdges};
75
use rustc_middle::ty::{RegionVid, TyCtxt};
86
use rustc_mir_dataflow::fmt::DebugWithContext;
97
use rustc_mir_dataflow::impls::{EverInitializedPlaces, MaybeUninitializedPlaces};
@@ -595,14 +593,6 @@ impl<'tcx> rustc_mir_dataflow::Analysis<'tcx> for Borrows<'_, 'tcx> {
595593
}
596594
terminator.edges()
597595
}
598-
599-
fn apply_call_return_effect(
600-
&mut self,
601-
_trans: &mut Self::Domain,
602-
_block: mir::BasicBlock,
603-
_return_places: CallReturnPlaces<'_, 'tcx>,
604-
) {
605-
}
606596
}
607597

608598
impl<C> DebugWithContext<C> for BorrowIndex {}

compiler/rustc_mir_dataflow/src/framework/mod.rs

+10-7
Original file line numberDiff line numberDiff line change
@@ -164,10 +164,12 @@ pub trait Analysis<'tcx> {
164164
/// initialized here.
165165
fn apply_terminator_effect<'mir>(
166166
&mut self,
167-
state: &mut Self::Domain,
167+
_state: &mut Self::Domain,
168168
terminator: &'mir mir::Terminator<'tcx>,
169-
location: Location,
170-
) -> TerminatorEdges<'mir, 'tcx>;
169+
_location: Location,
170+
) -> TerminatorEdges<'mir, 'tcx> {
171+
terminator.edges()
172+
}
171173

172174
/// Updates the current dataflow state with an effect that occurs immediately *before* the
173175
/// given terminator.
@@ -192,10 +194,11 @@ pub trait Analysis<'tcx> {
192194
/// edges.
193195
fn apply_call_return_effect(
194196
&mut self,
195-
state: &mut Self::Domain,
196-
block: BasicBlock,
197-
return_places: CallReturnPlaces<'_, 'tcx>,
198-
);
197+
_state: &mut Self::Domain,
198+
_block: BasicBlock,
199+
_return_places: CallReturnPlaces<'_, 'tcx>,
200+
) {
201+
}
199202

200203
/// Updates the current dataflow state with the effect of taking a particular branch in a
201204
/// `SwitchInt` terminator.

compiler/rustc_mir_dataflow/src/framework/tests.rs

-8
Original file line numberDiff line numberDiff line change
@@ -208,14 +208,6 @@ impl<'tcx, D: Direction> Analysis<'tcx> for MockAnalysis<'tcx, D> {
208208
let idx = self.effect(Effect::Before.at_index(location.statement_index));
209209
assert!(state.insert(idx));
210210
}
211-
212-
fn apply_call_return_effect(
213-
&mut self,
214-
_state: &mut Self::Domain,
215-
_block: BasicBlock,
216-
_return_places: CallReturnPlaces<'_, 'tcx>,
217-
) {
218-
}
219211
}
220212

221213
#[derive(Clone, Copy, Debug, PartialEq, Eq)]

compiler/rustc_mir_dataflow/src/impls/borrowed_locals.rs

-8
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,6 @@ impl<'tcx> Analysis<'tcx> for MaybeBorrowedLocals {
5151
self.transfer_function(trans).visit_terminator(terminator, location);
5252
terminator.edges()
5353
}
54-
55-
fn apply_call_return_effect(
56-
&mut self,
57-
_trans: &mut Self::Domain,
58-
_block: BasicBlock,
59-
_return_places: CallReturnPlaces<'_, 'tcx>,
60-
) {
61-
}
6254
}
6355

6456
/// A `Visitor` that defines the transfer function for `MaybeBorrowedLocals`.

compiler/rustc_mir_dataflow/src/impls/storage_liveness.rs

-38
Original file line numberDiff line numberDiff line change
@@ -50,25 +50,6 @@ impl<'a, 'tcx> Analysis<'tcx> for MaybeStorageLive<'a> {
5050
_ => (),
5151
}
5252
}
53-
54-
fn apply_terminator_effect<'mir>(
55-
&mut self,
56-
_trans: &mut Self::Domain,
57-
terminator: &'mir Terminator<'tcx>,
58-
_: Location,
59-
) -> TerminatorEdges<'mir, 'tcx> {
60-
// Terminators have no effect
61-
terminator.edges()
62-
}
63-
64-
fn apply_call_return_effect(
65-
&mut self,
66-
_trans: &mut Self::Domain,
67-
_block: BasicBlock,
68-
_return_places: CallReturnPlaces<'_, 'tcx>,
69-
) {
70-
// Nothing to do when a call returns successfully
71-
}
7253
}
7354

7455
pub struct MaybeStorageDead<'a> {
@@ -113,25 +94,6 @@ impl<'a, 'tcx> Analysis<'tcx> for MaybeStorageDead<'a> {
11394
_ => (),
11495
}
11596
}
116-
117-
fn apply_terminator_effect<'mir>(
118-
&mut self,
119-
_: &mut Self::Domain,
120-
terminator: &'mir Terminator<'tcx>,
121-
_: Location,
122-
) -> TerminatorEdges<'mir, 'tcx> {
123-
// Terminators have no effect
124-
terminator.edges()
125-
}
126-
127-
fn apply_call_return_effect(
128-
&mut self,
129-
_trans: &mut Self::Domain,
130-
_block: BasicBlock,
131-
_return_places: CallReturnPlaces<'_, 'tcx>,
132-
) {
133-
// Nothing to do when a call returns successfully
134-
}
13597
}
13698

13799
type BorrowedLocalsResults<'mir, 'tcx> = ResultsCursor<'mir, 'tcx, MaybeBorrowedLocals>;

0 commit comments

Comments
 (0)