store output in FlowState

This commit is contained in:
Douglas Campos 2018-05-26 01:38:50 +00:00 committed by Santiago Pastorino
parent 2cd09f27b8
commit db39ec8f9a
No known key found for this signature in database
GPG Key ID: 88C941CDA1D46432
2 changed files with 13 additions and 7 deletions

View File

@ -14,8 +14,13 @@
//! but is not as ugly as it is right now.
use rustc::mir::{BasicBlock, Location};
use rustc::ty::RegionVid;
use rustc_data_structures::indexed_set::Iter;
use borrow_check::location::LocationIndex;
use polonius_engine::Output;
use dataflow::{MaybeInitializedPlaces, MaybeUninitializedPlaces};
use dataflow::{EverInitializedPlaces, MovingOutStatements};
use dataflow::{Borrows};
@ -23,6 +28,7 @@
use dataflow::move_paths::HasMoveData;
use dataflow::move_paths::indexes::BorrowIndex;
use std::fmt;
use std::rc::Rc;
// (forced to be `pub` due to its use as an associated type below.)
crate struct Flows<'b, 'gcx: 'tcx, 'tcx: 'b> {
@ -31,6 +37,9 @@
pub uninits: FlowAtLocation<MaybeUninitializedPlaces<'b, 'gcx, 'tcx>>,
pub move_outs: FlowAtLocation<MovingOutStatements<'b, 'gcx, 'tcx>>,
pub ever_inits: FlowAtLocation<EverInitializedPlaces<'b, 'gcx, 'tcx>>,
/// Polonius Output
pub polonius_output: Option<Rc<Output<RegionVid, BorrowIndex, LocationIndex>>>,
}
impl<'b, 'gcx, 'tcx> Flows<'b, 'gcx, 'tcx> {
@ -40,6 +49,7 @@ impl<'b, 'gcx, 'tcx> Flows<'b, 'gcx, 'tcx> {
uninits: FlowAtLocation<MaybeUninitializedPlaces<'b, 'gcx, 'tcx>>,
move_outs: FlowAtLocation<MovingOutStatements<'b, 'gcx, 'tcx>>,
ever_inits: FlowAtLocation<EverInitializedPlaces<'b, 'gcx, 'tcx>>,
polonius_output: Option<Rc<Output<RegionVid, BorrowIndex, LocationIndex>>>,
) -> Self {
Flows {
borrows,
@ -47,6 +57,7 @@ impl<'b, 'gcx, 'tcx> Flows<'b, 'gcx, 'tcx> {
uninits,
move_outs,
ever_inits,
polonius_output,
}
}

View File

@ -11,12 +11,11 @@
//! This query borrow-checks the MIR to (further) ensure it is not broken.
use borrow_check::nll::region_infer::RegionInferenceContext;
use borrow_check::location::LocationIndex;
use rustc::hir;
use rustc::hir::def_id::DefId;
use rustc::hir::map::definitions::DefPathData;
use rustc::infer::InferCtxt;
use rustc::ty::{self, ParamEnv, RegionVid, TyCtxt};
use rustc::ty::{self, ParamEnv, TyCtxt};
use rustc::ty::maps::Providers;
use rustc::lint::builtin::UNUSED_MUT;
use rustc::mir::{AggregateKind, BasicBlock, BorrowCheckResult, BorrowKind};
@ -46,7 +45,6 @@
use dataflow::move_paths::{HasMoveData, LookupResult, MoveData, MovePathIndex};
use util::borrowck_errors::{BorrowckErrors, Origin};
use util::collect_writes::FindAssignments;
use polonius_engine::Output;
use self::borrow_set::{BorrowSet, BorrowData};
use self::flows::Flows;
@ -253,7 +251,6 @@ fn do_mir_borrowck<'a, 'gcx, 'tcx>(
used_mut_upvars: SmallVec::new(),
borrow_set,
dominators,
polonius_output,
};
let mut state = Flows::new(
@ -262,6 +259,7 @@ fn do_mir_borrowck<'a, 'gcx, 'tcx>(
flow_uninits,
flow_move_outs,
flow_ever_inits,
polonius_output,
);
mbcx.analyze_results(&mut state); // entry point for DataflowResultsConsumer
@ -376,9 +374,6 @@ pub struct MirBorrowckCtxt<'cx, 'gcx: 'tcx, 'tcx: 'cx> {
/// Dominators for MIR
dominators: Dominators<BasicBlock>,
/// Polonius Output
polonius_output: Option<Rc<Output<RegionVid, BorrowIndex, LocationIndex>>>,
}
// Check that: