Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit ad84311

Browse files
committedOct 31, 2024·
Remove ResultsVisitable.
Now that `Results` is the only impl of `ResultsVisitable`, the trait can be removed. This simplifies things by removining unnecessary layers of indirection and abstraction. - `ResultsVisitor` is simpler. - Its type parameter changes from `R` (an analysis result) to the simpler `A` (an analysis). - It no longer needs the `Domain` associated type, because it can use `A::Domain`. - Occurrences of `R` become `Results<'tcx, A>`, because there is now only one kind of analysis results. - `save_as_intervals` also changes type parameter from `R` to `A`. - The `results.reconstruct_*` method calls are replaced with `results.analysis.apply_*` method calls, which are equivalent. - `Direction::visit_results_in_block` is simpler, with a single generic param (`A`) instead of two (`D` and `R`/`F`, with a bound connecting them). Likewise for `visit_results`. - The `ResultsVisitor` impls for `MirBorrowCtxt` and `StorageConflictVisitor` are now specific about the type of the analysis results they work with. They both used to have a type param `R` but they weren't genuinely generic. In both cases there was only a single results type that made sense to instantiate them with.
1 parent db849dc commit ad84311

File tree

10 files changed

+91
-201
lines changed

10 files changed

+91
-201
lines changed
 

‎compiler/rustc_borrowck/src/lib.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ use rustc_mir_dataflow::impls::{
4242
use rustc_mir_dataflow::move_paths::{
4343
InitIndex, InitLocation, LookupResult, MoveData, MoveOutIndex, MovePathIndex,
4444
};
45-
use rustc_mir_dataflow::{Analysis, EntrySets, Results};
45+
use rustc_mir_dataflow::{Analysis, EntrySets, Results, ResultsVisitor, visit_results};
4646
use rustc_session::lint::builtin::UNUSED_MUT;
4747
use rustc_span::{Span, Symbol};
4848
use rustc_target::abi::FieldIdx;
@@ -326,7 +326,7 @@ fn do_mir_borrowck<'tcx>(
326326
mbcx.report_region_errors(nll_errors);
327327

328328
let mut flow_results = get_flow_results(tcx, body, &move_data, &borrow_set, &regioncx);
329-
rustc_mir_dataflow::visit_results(
329+
visit_results(
330330
body,
331331
traversal::reverse_postorder(body).map(|(bb, _)| bb),
332332
&mut flow_results,
@@ -615,14 +615,10 @@ struct MirBorrowckCtxt<'a, 'infcx, 'tcx> {
615615
// 2. loans made in overlapping scopes do not conflict
616616
// 3. assignments do not affect things loaned out as immutable
617617
// 4. moves do not affect things loaned out in any way
618-
impl<'a, 'tcx, R> rustc_mir_dataflow::ResultsVisitor<'a, 'tcx, R>
619-
for MirBorrowckCtxt<'a, '_, 'tcx>
620-
{
621-
type Domain = BorrowckDomain<'a, 'tcx>;
622-
618+
impl<'a, 'tcx> ResultsVisitor<'a, 'tcx, Borrowck<'a, 'tcx>> for MirBorrowckCtxt<'a, '_, 'tcx> {
623619
fn visit_statement_before_primary_effect(
624620
&mut self,
625-
_results: &mut R,
621+
_results: &mut Results<'tcx, Borrowck<'a, 'tcx>>,
626622
state: &BorrowckDomain<'a, 'tcx>,
627623
stmt: &'a Statement<'tcx>,
628624
location: Location,
@@ -692,7 +688,7 @@ impl<'a, 'tcx, R> rustc_mir_dataflow::ResultsVisitor<'a, 'tcx, R>
692688

693689
fn visit_terminator_before_primary_effect(
694690
&mut self,
695-
_results: &mut R,
691+
_results: &mut Results<'tcx, Borrowck<'a, 'tcx>>,
696692
state: &BorrowckDomain<'a, 'tcx>,
697693
term: &'a Terminator<'tcx>,
698694
loc: Location,
@@ -805,7 +801,7 @@ impl<'a, 'tcx, R> rustc_mir_dataflow::ResultsVisitor<'a, 'tcx, R>
805801

806802
fn visit_terminator_after_primary_effect(
807803
&mut self,
808-
_results: &mut R,
804+
_results: &mut Results<'tcx, Borrowck<'a, 'tcx>>,
809805
state: &BorrowckDomain<'a, 'tcx>,
810806
term: &'a Terminator<'tcx>,
811807
loc: Location,

‎compiler/rustc_mir_dataflow/src/framework/direction.rs

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ use rustc_middle::mir::{
44
self, BasicBlock, CallReturnPlaces, Location, SwitchTargets, TerminatorEdges,
55
};
66

7-
use super::visitor::{ResultsVisitable, ResultsVisitor};
8-
use super::{Analysis, Effect, EffectIndex, SwitchIntTarget};
7+
use super::visitor::ResultsVisitor;
8+
use super::{Analysis, Effect, EffectIndex, Results, SwitchIntTarget};
99

1010
pub trait Direction {
1111
const IS_FORWARD: bool;
@@ -33,14 +33,14 @@ pub trait Direction {
3333
where
3434
A: Analysis<'tcx>;
3535

36-
fn visit_results_in_block<'mir, 'tcx, D, R>(
37-
state: &mut D,
36+
fn visit_results_in_block<'mir, 'tcx, A>(
37+
state: &mut A::Domain,
3838
block: BasicBlock,
3939
block_data: &'mir mir::BasicBlockData<'tcx>,
40-
results: &mut R,
41-
vis: &mut impl ResultsVisitor<'mir, 'tcx, R, Domain = D>,
40+
results: &mut Results<'tcx, A>,
41+
vis: &mut impl ResultsVisitor<'mir, 'tcx, A>,
4242
) where
43-
R: ResultsVisitable<'tcx, Domain = D>;
43+
A: Analysis<'tcx>;
4444

4545
fn join_state_into_successors_of<'tcx, A>(
4646
analysis: &mut A,
@@ -53,7 +53,7 @@ pub trait Direction {
5353
A: Analysis<'tcx>;
5454
}
5555

56-
/// Dataflow that runs from the exit of a block (the terminator), to its entry (the first statement).
56+
/// Dataflow that runs from the exit of a block (terminator), to its entry (the first statement).
5757
pub struct Backward;
5858

5959
impl Direction for Backward {
@@ -157,32 +157,32 @@ impl Direction for Backward {
157157
analysis.apply_statement_effect(state, statement, location);
158158
}
159159

160-
fn visit_results_in_block<'mir, 'tcx, D, R>(
161-
state: &mut D,
160+
fn visit_results_in_block<'mir, 'tcx, A>(
161+
state: &mut A::Domain,
162162
block: BasicBlock,
163163
block_data: &'mir mir::BasicBlockData<'tcx>,
164-
results: &mut R,
165-
vis: &mut impl ResultsVisitor<'mir, 'tcx, R, Domain = D>,
164+
results: &mut Results<'tcx, A>,
165+
vis: &mut impl ResultsVisitor<'mir, 'tcx, A>,
166166
) where
167-
R: ResultsVisitable<'tcx, Domain = D>,
167+
A: Analysis<'tcx>,
168168
{
169-
results.reset_to_block_entry(state, block);
169+
state.clone_from(results.entry_set_for_block(block));
170170

171171
vis.visit_block_end(state);
172172

173173
// Terminator
174174
let loc = Location { block, statement_index: block_data.statements.len() };
175175
let term = block_data.terminator();
176-
results.reconstruct_before_terminator_effect(state, term, loc);
176+
results.analysis.apply_before_terminator_effect(state, term, loc);
177177
vis.visit_terminator_before_primary_effect(results, state, term, loc);
178-
results.reconstruct_terminator_effect(state, term, loc);
178+
results.analysis.apply_terminator_effect(state, term, loc);
179179
vis.visit_terminator_after_primary_effect(results, state, term, loc);
180180

181181
for (statement_index, stmt) in block_data.statements.iter().enumerate().rev() {
182182
let loc = Location { block, statement_index };
183-
results.reconstruct_before_statement_effect(state, stmt, loc);
183+
results.analysis.apply_before_statement_effect(state, stmt, loc);
184184
vis.visit_statement_before_primary_effect(results, state, stmt, loc);
185-
results.reconstruct_statement_effect(state, stmt, loc);
185+
results.analysis.apply_statement_effect(state, stmt, loc);
186186
vis.visit_statement_after_primary_effect(results, state, stmt, loc);
187187
}
188188

@@ -389,32 +389,32 @@ impl Direction for Forward {
389389
}
390390
}
391391

392-
fn visit_results_in_block<'mir, 'tcx, F, R>(
393-
state: &mut F,
392+
fn visit_results_in_block<'mir, 'tcx, A>(
393+
state: &mut A::Domain,
394394
block: BasicBlock,
395395
block_data: &'mir mir::BasicBlockData<'tcx>,
396-
results: &mut R,
397-
vis: &mut impl ResultsVisitor<'mir, 'tcx, R, Domain = F>,
396+
results: &mut Results<'tcx, A>,
397+
vis: &mut impl ResultsVisitor<'mir, 'tcx, A>,
398398
) where
399-
R: ResultsVisitable<'tcx, Domain = F>,
399+
A: Analysis<'tcx>,
400400
{
401-
results.reset_to_block_entry(state, block);
401+
state.clone_from(results.entry_set_for_block(block));
402402

403403
vis.visit_block_start(state);
404404

405405
for (statement_index, stmt) in block_data.statements.iter().enumerate() {
406406
let loc = Location { block, statement_index };
407-
results.reconstruct_before_statement_effect(state, stmt, loc);
407+
results.analysis.apply_before_statement_effect(state, stmt, loc);
408408
vis.visit_statement_before_primary_effect(results, state, stmt, loc);
409-
results.reconstruct_statement_effect(state, stmt, loc);
409+
results.analysis.apply_statement_effect(state, stmt, loc);
410410
vis.visit_statement_after_primary_effect(results, state, stmt, loc);
411411
}
412412

413413
let loc = Location { block, statement_index: block_data.statements.len() };
414414
let term = block_data.terminator();
415-
results.reconstruct_before_terminator_effect(state, term, loc);
415+
results.analysis.apply_before_terminator_effect(state, term, loc);
416416
vis.visit_terminator_before_primary_effect(results, state, term, loc);
417-
results.reconstruct_terminator_effect(state, term, loc);
417+
results.analysis.apply_terminator_effect(state, term, loc);
418418
vis.visit_terminator_after_primary_effect(results, state, term, loc);
419419

420420
vis.visit_block_end(state);

‎compiler/rustc_mir_dataflow/src/framework/graphviz.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -544,20 +544,18 @@ impl<D> StateDiffCollector<D> {
544544
}
545545
}
546546

547-
impl<'tcx, A> ResultsVisitor<'_, 'tcx, Results<'tcx, A>> for StateDiffCollector<A::Domain>
547+
impl<'tcx, A> ResultsVisitor<'_, 'tcx, A> for StateDiffCollector<A::Domain>
548548
where
549549
A: Analysis<'tcx>,
550550
A::Domain: DebugWithContext<A>,
551551
{
552-
type Domain = A::Domain;
553-
554-
fn visit_block_start(&mut self, state: &Self::Domain) {
552+
fn visit_block_start(&mut self, state: &A::Domain) {
555553
if A::Direction::IS_FORWARD {
556554
self.prev_state.clone_from(state);
557555
}
558556
}
559557

560-
fn visit_block_end(&mut self, state: &Self::Domain) {
558+
fn visit_block_end(&mut self, state: &A::Domain) {
561559
if A::Direction::IS_BACKWARD {
562560
self.prev_state.clone_from(state);
563561
}
@@ -566,7 +564,7 @@ where
566564
fn visit_statement_before_primary_effect(
567565
&mut self,
568566
results: &mut Results<'tcx, A>,
569-
state: &Self::Domain,
567+
state: &A::Domain,
570568
_statement: &mir::Statement<'tcx>,
571569
_location: Location,
572570
) {
@@ -579,7 +577,7 @@ where
579577
fn visit_statement_after_primary_effect(
580578
&mut self,
581579
results: &mut Results<'tcx, A>,
582-
state: &Self::Domain,
580+
state: &A::Domain,
583581
_statement: &mir::Statement<'tcx>,
584582
_location: Location,
585583
) {
@@ -590,7 +588,7 @@ where
590588
fn visit_terminator_before_primary_effect(
591589
&mut self,
592590
results: &mut Results<'tcx, A>,
593-
state: &Self::Domain,
591+
state: &A::Domain,
594592
_terminator: &mir::Terminator<'tcx>,
595593
_location: Location,
596594
) {
@@ -603,7 +601,7 @@ where
603601
fn visit_terminator_after_primary_effect(
604602
&mut self,
605603
results: &mut Results<'tcx, A>,
606-
state: &Self::Domain,
604+
state: &A::Domain,
607605
_terminator: &mir::Terminator<'tcx>,
608606
_location: Location,
609607
) {

‎compiler/rustc_mir_dataflow/src/framework/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ pub use self::cursor::ResultsCursor;
5656
pub use self::direction::{Backward, Direction, Forward};
5757
pub use self::lattice::{JoinSemiLattice, MaybeReachable};
5858
pub use self::results::{EntrySets, Results};
59-
pub use self::visitor::{ResultsVisitable, ResultsVisitor, visit_results};
59+
pub use self::visitor::{ResultsVisitor, visit_results};
6060

6161
/// Analysis domains are all bitsets of various kinds. This trait holds
6262
/// operations needed by all of them.

‎compiler/rustc_mir_dataflow/src/framework/results.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,15 @@ where
5151
&mut self,
5252
body: &'mir mir::Body<'tcx>,
5353
blocks: impl IntoIterator<Item = BasicBlock>,
54-
vis: &mut impl ResultsVisitor<'mir, 'tcx, Self, Domain = A::Domain>,
54+
vis: &mut impl ResultsVisitor<'mir, 'tcx, A>,
5555
) {
5656
visit_results(body, blocks, self, vis)
5757
}
5858

5959
pub fn visit_reachable_with<'mir>(
6060
&mut self,
6161
body: &'mir mir::Body<'tcx>,
62-
vis: &mut impl ResultsVisitor<'mir, 'tcx, Self, Domain = A::Domain>,
62+
vis: &mut impl ResultsVisitor<'mir, 'tcx, A>,
6363
) {
6464
let blocks = traversal::reachable(body);
6565
visit_results(body, blocks.map(|(bb, _)| bb), self, vis)

‎compiler/rustc_mir_dataflow/src/framework/visitor.rs

Lines changed: 23 additions & 120 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ use super::{Analysis, Direction, Results};
44

55
/// Calls the corresponding method in `ResultsVisitor` for every location in a `mir::Body` with the
66
/// dataflow state at that location.
7-
pub fn visit_results<'mir, 'tcx, D, R>(
7+
pub fn visit_results<'mir, 'tcx, A>(
88
body: &'mir mir::Body<'tcx>,
99
blocks: impl IntoIterator<Item = BasicBlock>,
10-
results: &mut R,
11-
vis: &mut impl ResultsVisitor<'mir, 'tcx, R, Domain = D>,
10+
results: &mut Results<'tcx, A>,
11+
vis: &mut impl ResultsVisitor<'mir, 'tcx, A>,
1212
) where
13-
R: ResultsVisitable<'tcx, Domain = D>,
13+
A: Analysis<'tcx>,
1414
{
15-
let mut state = results.bottom_value(body);
15+
let mut state = results.analysis.bottom_value(body);
1616

1717
#[cfg(debug_assertions)]
1818
let reachable_blocks = mir::traversal::reachable_as_bitset(body);
@@ -22,23 +22,23 @@ pub fn visit_results<'mir, 'tcx, D, R>(
2222
assert!(reachable_blocks.contains(block));
2323

2424
let block_data = &body[block];
25-
R::Direction::visit_results_in_block(&mut state, block, block_data, results, vis);
25+
A::Direction::visit_results_in_block(&mut state, block, block_data, results, vis);
2626
}
2727
}
2828

29-
/// A visitor over the results of an `Analysis`. The type parameter `R` is the results type being
30-
/// visited.
31-
pub trait ResultsVisitor<'mir, 'tcx, R> {
32-
type Domain;
33-
34-
fn visit_block_start(&mut self, _state: &Self::Domain) {}
29+
/// A visitor over the results of an `Analysis`.
30+
pub trait ResultsVisitor<'mir, 'tcx, A>
31+
where
32+
A: Analysis<'tcx>,
33+
{
34+
fn visit_block_start(&mut self, _state: &A::Domain) {}
3535

3636
/// Called with the `before_statement_effect` of the given statement applied to `state` but not
3737
/// its `statement_effect`.
3838
fn visit_statement_before_primary_effect(
3939
&mut self,
40-
_results: &mut R,
41-
_state: &Self::Domain,
40+
_results: &mut Results<'tcx, A>,
41+
_state: &A::Domain,
4242
_statement: &'mir mir::Statement<'tcx>,
4343
_location: Location,
4444
) {
@@ -48,19 +48,19 @@ pub trait ResultsVisitor<'mir, 'tcx, R> {
4848
/// statement applied to `state`.
4949
fn visit_statement_after_primary_effect(
5050
&mut self,
51-
_results: &mut R,
52-
_state: &Self::Domain,
51+
_results: &mut Results<'tcx, A>,
52+
_state: &A::Domain,
5353
_statement: &'mir mir::Statement<'tcx>,
5454
_location: Location,
5555
) {
5656
}
5757

58-
/// Called with the `before_terminator_effect` of the given terminator applied to `state` but not
59-
/// its `terminator_effect`.
58+
/// Called with the `before_terminator_effect` of the given terminator applied to `state` but
59+
/// not its `terminator_effect`.
6060
fn visit_terminator_before_primary_effect(
6161
&mut self,
62-
_results: &mut R,
63-
_state: &Self::Domain,
62+
_results: &mut Results<'tcx, A>,
63+
_state: &A::Domain,
6464
_terminator: &'mir mir::Terminator<'tcx>,
6565
_location: Location,
6666
) {
@@ -72,109 +72,12 @@ pub trait ResultsVisitor<'mir, 'tcx, R> {
7272
/// The `call_return_effect` (if one exists) will *not* be applied to `state`.
7373
fn visit_terminator_after_primary_effect(
7474
&mut self,
75-
_results: &mut R,
76-
_state: &Self::Domain,
75+
_results: &mut Results<'tcx, A>,
76+
_state: &A::Domain,
7777
_terminator: &'mir mir::Terminator<'tcx>,
7878
_location: Location,
7979
) {
8080
}
8181

82-
fn visit_block_end(&mut self, _state: &Self::Domain) {}
83-
}
84-
85-
/// Things that can be visited by a `ResultsVisitor`.
86-
///
87-
/// This trait exists so that we can visit the results of one or more dataflow analyses
88-
/// simultaneously.
89-
pub trait ResultsVisitable<'tcx> {
90-
type Direction: Direction;
91-
type Domain;
92-
93-
/// Creates an empty `Domain` to hold the transient state for these dataflow results.
94-
///
95-
/// The value of the newly created `Domain` will be overwritten by `reset_to_block_entry`
96-
/// before it can be observed by a `ResultsVisitor`.
97-
fn bottom_value(&self, body: &mir::Body<'tcx>) -> Self::Domain;
98-
99-
fn reset_to_block_entry(&self, state: &mut Self::Domain, block: BasicBlock);
100-
101-
fn reconstruct_before_statement_effect(
102-
&mut self,
103-
state: &mut Self::Domain,
104-
statement: &mir::Statement<'tcx>,
105-
location: Location,
106-
);
107-
108-
fn reconstruct_statement_effect(
109-
&mut self,
110-
state: &mut Self::Domain,
111-
statement: &mir::Statement<'tcx>,
112-
location: Location,
113-
);
114-
115-
fn reconstruct_before_terminator_effect(
116-
&mut self,
117-
state: &mut Self::Domain,
118-
terminator: &mir::Terminator<'tcx>,
119-
location: Location,
120-
);
121-
122-
fn reconstruct_terminator_effect(
123-
&mut self,
124-
state: &mut Self::Domain,
125-
terminator: &mir::Terminator<'tcx>,
126-
location: Location,
127-
);
128-
}
129-
130-
impl<'tcx, A> ResultsVisitable<'tcx> for Results<'tcx, A>
131-
where
132-
A: Analysis<'tcx>,
133-
{
134-
type Domain = A::Domain;
135-
type Direction = A::Direction;
136-
137-
fn bottom_value(&self, body: &mir::Body<'tcx>) -> Self::Domain {
138-
self.analysis.bottom_value(body)
139-
}
140-
141-
fn reset_to_block_entry(&self, state: &mut Self::Domain, block: BasicBlock) {
142-
state.clone_from(self.entry_set_for_block(block));
143-
}
144-
145-
fn reconstruct_before_statement_effect(
146-
&mut self,
147-
state: &mut Self::Domain,
148-
stmt: &mir::Statement<'tcx>,
149-
loc: Location,
150-
) {
151-
self.analysis.apply_before_statement_effect(state, stmt, loc);
152-
}
153-
154-
fn reconstruct_statement_effect(
155-
&mut self,
156-
state: &mut Self::Domain,
157-
stmt: &mir::Statement<'tcx>,
158-
loc: Location,
159-
) {
160-
self.analysis.apply_statement_effect(state, stmt, loc);
161-
}
162-
163-
fn reconstruct_before_terminator_effect(
164-
&mut self,
165-
state: &mut Self::Domain,
166-
term: &mir::Terminator<'tcx>,
167-
loc: Location,
168-
) {
169-
self.analysis.apply_before_terminator_effect(state, term, loc);
170-
}
171-
172-
fn reconstruct_terminator_effect(
173-
&mut self,
174-
state: &mut Self::Domain,
175-
term: &mir::Terminator<'tcx>,
176-
loc: Location,
177-
) {
178-
self.analysis.apply_terminator_effect(state, term, loc);
179-
}
82+
fn visit_block_end(&mut self, _state: &A::Domain) {}
18083
}

‎compiler/rustc_mir_dataflow/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ pub use self::drop_flag_effects::{
1919
};
2020
pub use self::framework::{
2121
Analysis, Backward, Direction, EntrySets, Forward, GenKill, JoinSemiLattice, MaybeReachable,
22-
Results, ResultsCursor, ResultsVisitable, ResultsVisitor, SwitchIntEdgeEffects, fmt, graphviz,
23-
lattice, visit_results,
22+
Results, ResultsCursor, ResultsVisitor, SwitchIntEdgeEffects, fmt, graphviz, lattice,
23+
visit_results,
2424
};
2525
use self::move_paths::MoveData;
2626

‎compiler/rustc_mir_dataflow/src/points.rs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use rustc_index::interval::SparseIntervalMatrix;
33
use rustc_index::{Idx, IndexVec};
44
use rustc_middle::mir::{self, BasicBlock, Body, Location};
55

6-
use crate::framework::{ResultsVisitable, ResultsVisitor, visit_results};
6+
use crate::framework::{Analysis, Results, ResultsVisitor, visit_results};
77

88
/// Maps between a `Location` and a `PointIndex` (and vice versa).
99
pub struct DenseLocationMap {
@@ -95,14 +95,14 @@ rustc_index::newtype_index! {
9595
}
9696

9797
/// Add points depending on the result of the given dataflow analysis.
98-
pub fn save_as_intervals<'tcx, N, R>(
98+
pub fn save_as_intervals<'tcx, N, A>(
9999
elements: &DenseLocationMap,
100100
body: &mir::Body<'tcx>,
101-
mut results: R,
101+
mut results: Results<'tcx, A>,
102102
) -> SparseIntervalMatrix<N, PointIndex>
103103
where
104104
N: Idx,
105-
R: ResultsVisitable<'tcx, Domain = BitSet<N>>,
105+
A: Analysis<'tcx, Domain = BitSet<N>>,
106106
{
107107
let values = SparseIntervalMatrix::new(elements.num_points());
108108
let mut visitor = Visitor { elements, values };
@@ -120,16 +120,15 @@ struct Visitor<'a, N: Idx> {
120120
values: SparseIntervalMatrix<N, PointIndex>,
121121
}
122122

123-
impl<'mir, 'tcx, R, N> ResultsVisitor<'mir, 'tcx, R> for Visitor<'_, N>
123+
impl<'mir, 'tcx, A, N> ResultsVisitor<'mir, 'tcx, A> for Visitor<'_, N>
124124
where
125+
A: Analysis<'tcx, Domain = BitSet<N>>,
125126
N: Idx,
126127
{
127-
type Domain = BitSet<N>;
128-
129128
fn visit_statement_after_primary_effect(
130129
&mut self,
131-
_results: &mut R,
132-
state: &Self::Domain,
130+
_results: &mut Results<'tcx, A>,
131+
state: &A::Domain,
133132
_statement: &'mir mir::Statement<'tcx>,
134133
location: Location,
135134
) {
@@ -142,8 +141,8 @@ where
142141

143142
fn visit_terminator_after_primary_effect(
144143
&mut self,
145-
_results: &mut R,
146-
state: &Self::Domain,
144+
_results: &mut Results<'tcx, A>,
145+
state: &A::Domain,
147146
_terminator: &'mir mir::Terminator<'tcx>,
148147
location: Location,
149148
) {

‎compiler/rustc_mir_transform/src/coroutine.rs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,11 @@ use rustc_middle::ty::{
6767
self, CoroutineArgs, CoroutineArgsExt, GenericArgsRef, InstanceKind, Ty, TyCtxt, TypingMode,
6868
};
6969
use rustc_middle::{bug, span_bug};
70-
use rustc_mir_dataflow::Analysis;
7170
use rustc_mir_dataflow::impls::{
7271
MaybeBorrowedLocals, MaybeLiveLocals, MaybeRequiresStorage, MaybeStorageLive,
7372
};
7473
use rustc_mir_dataflow::storage::always_storage_live_locals;
74+
use rustc_mir_dataflow::{Analysis, Results, ResultsVisitor};
7575
use rustc_span::Span;
7676
use rustc_span::def_id::{DefId, LocalDefId};
7777
use rustc_span::symbol::sym;
@@ -817,9 +817,9 @@ impl ops::Deref for CoroutineSavedLocals {
817817
/// computation; see `CoroutineLayout` for more.
818818
fn compute_storage_conflicts<'mir, 'tcx>(
819819
body: &'mir Body<'tcx>,
820-
saved_locals: &CoroutineSavedLocals,
820+
saved_locals: &'mir CoroutineSavedLocals,
821821
always_live_locals: BitSet<Local>,
822-
mut requires_storage: rustc_mir_dataflow::Results<'tcx, MaybeRequiresStorage<'mir, 'tcx>>,
822+
mut requires_storage: Results<'tcx, MaybeRequiresStorage<'mir, 'tcx>>,
823823
) -> BitMatrix<CoroutineSavedLocal, CoroutineSavedLocal> {
824824
assert_eq!(body.local_decls.len(), saved_locals.domain_size());
825825

@@ -877,15 +877,13 @@ struct StorageConflictVisitor<'a, 'tcx> {
877877
eligible_storage_live: BitSet<Local>,
878878
}
879879

880-
impl<'a, 'tcx, R> rustc_mir_dataflow::ResultsVisitor<'a, 'tcx, R>
880+
impl<'a, 'tcx> ResultsVisitor<'a, 'tcx, MaybeRequiresStorage<'a, 'tcx>>
881881
for StorageConflictVisitor<'a, 'tcx>
882882
{
883-
type Domain = BitSet<Local>;
884-
885883
fn visit_statement_before_primary_effect(
886884
&mut self,
887-
_results: &mut R,
888-
state: &Self::Domain,
885+
_results: &mut Results<'tcx, MaybeRequiresStorage<'a, 'tcx>>,
886+
state: &BitSet<Local>,
889887
_statement: &'a Statement<'tcx>,
890888
loc: Location,
891889
) {
@@ -894,8 +892,8 @@ impl<'a, 'tcx, R> rustc_mir_dataflow::ResultsVisitor<'a, 'tcx, R>
894892

895893
fn visit_terminator_before_primary_effect(
896894
&mut self,
897-
_results: &mut R,
898-
state: &Self::Domain,
895+
_results: &mut Results<'tcx, MaybeRequiresStorage<'a, 'tcx>>,
896+
state: &BitSet<Local>,
899897
_terminator: &'a Terminator<'tcx>,
900898
loc: Location,
901899
) {

‎compiler/rustc_mir_transform/src/dataflow_const_prop.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -941,16 +941,12 @@ fn try_write_constant<'tcx>(
941941
interp_ok(())
942942
}
943943

944-
impl<'mir, 'tcx> ResultsVisitor<'mir, 'tcx, Results<'tcx, ConstAnalysis<'_, 'tcx>>>
945-
for Collector<'_, 'tcx>
946-
{
947-
type Domain = State<FlatSet<Scalar>>;
948-
944+
impl<'mir, 'tcx> ResultsVisitor<'mir, 'tcx, ConstAnalysis<'_, 'tcx>> for Collector<'_, 'tcx> {
949945
#[instrument(level = "trace", skip(self, results, statement))]
950946
fn visit_statement_before_primary_effect(
951947
&mut self,
952948
results: &mut Results<'tcx, ConstAnalysis<'_, 'tcx>>,
953-
state: &Self::Domain,
949+
state: &State<FlatSet<Scalar>>,
954950
statement: &'mir Statement<'tcx>,
955951
location: Location,
956952
) {
@@ -972,7 +968,7 @@ impl<'mir, 'tcx> ResultsVisitor<'mir, 'tcx, Results<'tcx, ConstAnalysis<'_, 'tcx
972968
fn visit_statement_after_primary_effect(
973969
&mut self,
974970
results: &mut Results<'tcx, ConstAnalysis<'_, 'tcx>>,
975-
state: &Self::Domain,
971+
state: &State<FlatSet<Scalar>>,
976972
statement: &'mir Statement<'tcx>,
977973
location: Location,
978974
) {
@@ -997,7 +993,7 @@ impl<'mir, 'tcx> ResultsVisitor<'mir, 'tcx, Results<'tcx, ConstAnalysis<'_, 'tcx
997993
fn visit_terminator_before_primary_effect(
998994
&mut self,
999995
results: &mut Results<'tcx, ConstAnalysis<'_, 'tcx>>,
1000-
state: &Self::Domain,
996+
state: &State<FlatSet<Scalar>>,
1001997
terminator: &'mir Terminator<'tcx>,
1002998
location: Location,
1003999
) {

0 commit comments

Comments
 (0)
Please sign in to comment.