Skip to content

Commit 0158404

Browse files
committed
Remove BorrowckAnalyses.
This results in two non-generic types being used: `BorrowckResults` and `BorrowckFlowState`. It's a net reduction in lines of code, and a little easier to read.
1 parent 60e7c68 commit 0158404

File tree

1 file changed

+18
-28
lines changed

1 file changed

+18
-28
lines changed

compiler/rustc_borrowck/src/dataflow.rs

+18-28
Original file line numberDiff line numberDiff line change
@@ -11,43 +11,33 @@ use rustc_middle::ty::TyCtxt;
1111
use rustc_mir_dataflow::impls::{EverInitializedPlaces, MaybeUninitializedPlaces};
1212
use rustc_mir_dataflow::ResultsVisitable;
1313
use rustc_mir_dataflow::{self, fmt::DebugWithContext, GenKill};
14-
use rustc_mir_dataflow::{Analysis, Direction, Results};
14+
use rustc_mir_dataflow::{Analysis, AnalysisDomain, Results};
1515
use std::fmt;
1616

1717
use crate::{places_conflict, BorrowSet, PlaceConflictBias, PlaceExt, RegionInferenceContext};
1818

19-
/// A tuple with named fields that can hold either the results or the transient state of the
20-
/// dataflow analyses used by the borrow checker.
21-
#[derive(Debug)]
22-
pub struct BorrowckAnalyses<B, U, E> {
23-
pub borrows: B,
24-
pub uninits: U,
25-
pub ever_inits: E,
26-
}
27-
2819
/// The results of the dataflow analyses used by the borrow checker.
29-
pub type BorrowckResults<'mir, 'tcx> = BorrowckAnalyses<
30-
Results<'tcx, Borrows<'mir, 'tcx>>,
31-
Results<'tcx, MaybeUninitializedPlaces<'mir, 'tcx>>,
32-
Results<'tcx, EverInitializedPlaces<'mir, 'tcx>>,
33-
>;
20+
pub struct BorrowckResults<'mir, 'tcx> {
21+
pub(crate) borrows: Results<'tcx, Borrows<'mir, 'tcx>>,
22+
pub(crate) uninits: Results<'tcx, MaybeUninitializedPlaces<'mir, 'tcx>>,
23+
pub(crate) ever_inits: Results<'tcx, EverInitializedPlaces<'mir, 'tcx>>,
24+
}
3425

3526
/// The transient state of the dataflow analyses used by the borrow checker.
36-
pub type BorrowckFlowState<'mir, 'tcx> =
37-
<BorrowckResults<'mir, 'tcx> as ResultsVisitable<'tcx>>::FlowState;
38-
39-
impl<'tcx, B, U, E, D: Direction> ResultsVisitable<'tcx>
40-
for BorrowckAnalyses<Results<'tcx, B>, Results<'tcx, U>, Results<'tcx, E>>
41-
where
42-
B: Analysis<'tcx, Direction = D>,
43-
U: Analysis<'tcx, Direction = D>,
44-
E: Analysis<'tcx, Direction = D>,
45-
{
46-
type Direction = D;
47-
type FlowState = BorrowckAnalyses<B::Domain, U::Domain, E::Domain>;
27+
#[derive(Debug)]
28+
pub struct BorrowckFlowState<'mir, 'tcx> {
29+
pub(crate) borrows: <Borrows<'mir, 'tcx> as AnalysisDomain<'tcx>>::Domain,
30+
pub(crate) uninits: <MaybeUninitializedPlaces<'mir, 'tcx> as AnalysisDomain<'tcx>>::Domain,
31+
pub(crate) ever_inits: <EverInitializedPlaces<'mir, 'tcx> as AnalysisDomain<'tcx>>::Domain,
32+
}
33+
34+
impl<'mir, 'tcx> ResultsVisitable<'tcx> for BorrowckResults<'mir, 'tcx> {
35+
// All three analyses are forward, but we have to use just one here.
36+
type Direction = <Borrows<'mir, 'tcx> as AnalysisDomain<'tcx>>::Direction;
37+
type FlowState = BorrowckFlowState<'mir, 'tcx>;
4838

4939
fn new_flow_state(&self, body: &mir::Body<'tcx>) -> Self::FlowState {
50-
BorrowckAnalyses {
40+
BorrowckFlowState {
5141
borrows: self.borrows.analysis.bottom_value(body),
5242
uninits: self.uninits.analysis.bottom_value(body),
5343
ever_inits: self.ever_inits.analysis.bottom_value(body),

0 commit comments

Comments
 (0)