From b6528f073fcf5ed08502242eb1be18a2d07280bb Mon Sep 17 00:00:00 2001 From: "Felix S. Klock II" Date: Wed, 5 Jul 2017 15:14:12 +0200 Subject: [PATCH] Cleanup: Every `BitDenotation` is a `DataflowOperator`, so build that in. Post-rebase: ariel confirmed `SetDiscriminant` should indeed be a mutate. --- src/librustc_mir/dataflow/mod.rs | 31 ++++++++-------------- src/librustc_mir/transform/borrow_check.rs | 1 - 2 files changed, 11 insertions(+), 21 deletions(-) diff --git a/src/librustc_mir/dataflow/mod.rs b/src/librustc_mir/dataflow/mod.rs index ed6145a19c6..e460848450e 100644 --- a/src/librustc_mir/dataflow/mod.rs +++ b/src/librustc_mir/dataflow/mod.rs @@ -62,8 +62,7 @@ pub trait Dataflow { fn propagate(&mut self); } -impl<'a, 'tcx: 'a, BD> Dataflow for DataflowBuilder<'a, 'tcx, BD> - where BD: BitDenotation + DataflowOperator +impl<'a, 'tcx: 'a, BD> Dataflow for DataflowBuilder<'a, 'tcx, BD> where BD: BitDenotation { fn dataflow

(&mut self, p: P) where P: Fn(&BD, BD::Idx) -> &Debug { self.flow_state.build_sets(); @@ -104,7 +103,7 @@ pub(crate) fn do_dataflow<'a, 'tcx, BD, P>(tcx: TyCtxt<'a, 'tcx, 'tcx>, bd: BD, p: P) -> DataflowResults - where BD: BitDenotation + DataflowOperator, + where BD: BitDenotation, P: Fn(&BD, BD::Idx) -> &fmt::Debug { let name_found = |sess: &Session, attrs: &[ast::Attribute], name| -> Option { @@ -137,15 +136,13 @@ pub(crate) fn do_dataflow<'a, 'tcx, BD, P>(tcx: TyCtxt<'a, 'tcx, 'tcx>, mbcx.flow_state.results() } -struct PropagationContext<'b, 'a: 'b, 'tcx: 'a, O> - where O: 'b + BitDenotation +struct PropagationContext<'b, 'a: 'b, 'tcx: 'a, O> where O: 'b + BitDenotation { builder: &'b mut DataflowAnalysis<'a, 'tcx, O>, changed: bool, } -impl<'a, 'tcx: 'a, BD> DataflowAnalysis<'a, 'tcx, BD> - where BD: BitDenotation + DataflowOperator +impl<'a, 'tcx: 'a, BD> DataflowAnalysis<'a, 'tcx, BD> where BD: BitDenotation { fn propagate(&mut self) { let mut temp = IdxSetBuf::new_empty(self.flow_state.sets.bits_per_block); @@ -189,8 +186,7 @@ impl<'a, 'tcx: 'a, BD> DataflowAnalysis<'a, 'tcx, BD> } } -impl<'b, 'a: 'b, 'tcx: 'a, BD> PropagationContext<'b, 'a, 'tcx, BD> - where BD: BitDenotation + DataflowOperator +impl<'b, 'a: 'b, 'tcx: 'a, BD> PropagationContext<'b, 'a, 'tcx, BD> where BD: BitDenotation { fn reset(&mut self, bits: &mut IdxSet) { let e = if BD::bottom_value() {!0} else {0}; @@ -227,8 +223,7 @@ fn dataflow_path(context: &str, prepost: &str, path: &str) -> PathBuf { path } -impl<'a, 'tcx: 'a, BD> DataflowBuilder<'a, 'tcx, BD> - where BD: BitDenotation +impl<'a, 'tcx: 'a, BD> DataflowBuilder<'a, 'tcx, BD> where BD: BitDenotation { fn pre_dataflow_instrumentation

(&self, p: P) -> io::Result<()> where P: Fn(&BD, BD::Idx) -> &Debug @@ -356,16 +351,14 @@ pub trait DataflowResultsConsumer<'a, 'tcx: 'a> { flow_state: &mut Self::FlowState); } -pub struct DataflowAnalysis<'a, 'tcx: 'a, O> - where O: BitDenotation +pub struct DataflowAnalysis<'a, 'tcx: 'a, O> where O: BitDenotation { flow_state: DataflowState, dead_unwinds: &'a IdxSet, mir: &'a Mir<'tcx>, } -impl<'a, 'tcx: 'a, O> DataflowAnalysis<'a, 'tcx, O> - where O: BitDenotation +impl<'a, 'tcx: 'a, O> DataflowAnalysis<'a, 'tcx, O> where O: BitDenotation { pub fn results(self) -> DataflowResults { DataflowResults(self.flow_state) @@ -516,7 +509,7 @@ pub trait DataflowOperator: BitwiseOperator { fn bottom_value() -> bool; } -pub trait BitDenotation { +pub trait BitDenotation: DataflowOperator { /// Specifies what index type is used to access the bitvector. type Idx: Idx; @@ -597,8 +590,7 @@ pub trait BitDenotation { dest_lval: &mir::Lvalue); } -impl<'a, 'tcx: 'a, D> DataflowAnalysis<'a, 'tcx, D> - where D: BitDenotation + DataflowOperator +impl<'a, 'tcx: 'a, D> DataflowAnalysis<'a, 'tcx, D> where D: BitDenotation { pub fn new(_tcx: TyCtxt<'a, 'tcx, 'tcx>, mir: &'a Mir<'tcx>, @@ -639,8 +631,7 @@ impl<'a, 'tcx: 'a, D> DataflowAnalysis<'a, 'tcx, D> } } -impl<'a, 'tcx: 'a, D> DataflowAnalysis<'a, 'tcx, D> - where D: BitDenotation + DataflowOperator +impl<'a, 'tcx: 'a, D> DataflowAnalysis<'a, 'tcx, D> where D: BitDenotation { /// Propagates the bits of `in_out` into all the successors of `bb`, /// using bitwise operator denoted by `self.operator`. diff --git a/src/librustc_mir/transform/borrow_check.rs b/src/librustc_mir/transform/borrow_check.rs index 2676fdbb9b4..e1f79c2f364 100644 --- a/src/librustc_mir/transform/borrow_check.rs +++ b/src/librustc_mir/transform/borrow_check.rs @@ -193,7 +193,6 @@ impl<'c, 'b, 'a: 'b+'c, 'gcx, 'tcx: 'a> DataflowResultsConsumer<'b, 'gcx> (rhs, span), location, flow_state); } StatementKind::SetDiscriminant { ref lvalue, variant_index: _ } => { - // FIXME: should this count as a mutate from borrowck POV? self.mutate_lvalue(ContextKind::SetDiscrim.new(location), (lvalue, span), JustWrite, flow_state); }