mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-26 08:44:35 +00:00
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.
This commit is contained in:
parent
60e7c6898b
commit
0158404e78
@ -11,43 +11,33 @@ use rustc_middle::ty::TyCtxt;
|
|||||||
use rustc_mir_dataflow::impls::{EverInitializedPlaces, MaybeUninitializedPlaces};
|
use rustc_mir_dataflow::impls::{EverInitializedPlaces, MaybeUninitializedPlaces};
|
||||||
use rustc_mir_dataflow::ResultsVisitable;
|
use rustc_mir_dataflow::ResultsVisitable;
|
||||||
use rustc_mir_dataflow::{self, fmt::DebugWithContext, GenKill};
|
use rustc_mir_dataflow::{self, fmt::DebugWithContext, GenKill};
|
||||||
use rustc_mir_dataflow::{Analysis, Direction, Results};
|
use rustc_mir_dataflow::{Analysis, AnalysisDomain, Results};
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
|
||||||
use crate::{places_conflict, BorrowSet, PlaceConflictBias, PlaceExt, RegionInferenceContext};
|
use crate::{places_conflict, BorrowSet, PlaceConflictBias, PlaceExt, RegionInferenceContext};
|
||||||
|
|
||||||
/// A tuple with named fields that can hold either the results or the transient state of the
|
/// The results of the dataflow analyses used by the borrow checker.
|
||||||
/// dataflow analyses used by the borrow checker.
|
pub struct BorrowckResults<'mir, 'tcx> {
|
||||||
#[derive(Debug)]
|
pub(crate) borrows: Results<'tcx, Borrows<'mir, 'tcx>>,
|
||||||
pub struct BorrowckAnalyses<B, U, E> {
|
pub(crate) uninits: Results<'tcx, MaybeUninitializedPlaces<'mir, 'tcx>>,
|
||||||
pub borrows: B,
|
pub(crate) ever_inits: Results<'tcx, EverInitializedPlaces<'mir, 'tcx>>,
|
||||||
pub uninits: U,
|
|
||||||
pub ever_inits: E,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The results of the dataflow analyses used by the borrow checker.
|
|
||||||
pub type BorrowckResults<'mir, 'tcx> = BorrowckAnalyses<
|
|
||||||
Results<'tcx, Borrows<'mir, 'tcx>>,
|
|
||||||
Results<'tcx, MaybeUninitializedPlaces<'mir, 'tcx>>,
|
|
||||||
Results<'tcx, EverInitializedPlaces<'mir, 'tcx>>,
|
|
||||||
>;
|
|
||||||
|
|
||||||
/// The transient state of the dataflow analyses used by the borrow checker.
|
/// The transient state of the dataflow analyses used by the borrow checker.
|
||||||
pub type BorrowckFlowState<'mir, 'tcx> =
|
#[derive(Debug)]
|
||||||
<BorrowckResults<'mir, 'tcx> as ResultsVisitable<'tcx>>::FlowState;
|
pub struct BorrowckFlowState<'mir, 'tcx> {
|
||||||
|
pub(crate) borrows: <Borrows<'mir, 'tcx> as AnalysisDomain<'tcx>>::Domain,
|
||||||
|
pub(crate) uninits: <MaybeUninitializedPlaces<'mir, 'tcx> as AnalysisDomain<'tcx>>::Domain,
|
||||||
|
pub(crate) ever_inits: <EverInitializedPlaces<'mir, 'tcx> as AnalysisDomain<'tcx>>::Domain,
|
||||||
|
}
|
||||||
|
|
||||||
impl<'tcx, B, U, E, D: Direction> ResultsVisitable<'tcx>
|
impl<'mir, 'tcx> ResultsVisitable<'tcx> for BorrowckResults<'mir, 'tcx> {
|
||||||
for BorrowckAnalyses<Results<'tcx, B>, Results<'tcx, U>, Results<'tcx, E>>
|
// All three analyses are forward, but we have to use just one here.
|
||||||
where
|
type Direction = <Borrows<'mir, 'tcx> as AnalysisDomain<'tcx>>::Direction;
|
||||||
B: Analysis<'tcx, Direction = D>,
|
type FlowState = BorrowckFlowState<'mir, 'tcx>;
|
||||||
U: Analysis<'tcx, Direction = D>,
|
|
||||||
E: Analysis<'tcx, Direction = D>,
|
|
||||||
{
|
|
||||||
type Direction = D;
|
|
||||||
type FlowState = BorrowckAnalyses<B::Domain, U::Domain, E::Domain>;
|
|
||||||
|
|
||||||
fn new_flow_state(&self, body: &mir::Body<'tcx>) -> Self::FlowState {
|
fn new_flow_state(&self, body: &mir::Body<'tcx>) -> Self::FlowState {
|
||||||
BorrowckAnalyses {
|
BorrowckFlowState {
|
||||||
borrows: self.borrows.analysis.bottom_value(body),
|
borrows: self.borrows.analysis.bottom_value(body),
|
||||||
uninits: self.uninits.analysis.bottom_value(body),
|
uninits: self.uninits.analysis.bottom_value(body),
|
||||||
ever_inits: self.ever_inits.analysis.bottom_value(body),
|
ever_inits: self.ever_inits.analysis.bottom_value(body),
|
||||||
|
Loading…
Reference in New Issue
Block a user