diff --git a/compiler/rustc_mir_dataflow/src/value_analysis.rs b/compiler/rustc_mir_dataflow/src/value_analysis.rs index 64e45083fc0..5fe768f8310 100644 --- a/compiler/rustc_mir_dataflow/src/value_analysis.rs +++ b/compiler/rustc_mir_dataflow/src/value_analysis.rs @@ -146,10 +146,7 @@ pub trait ValueAnalysis<'tcx> { Rvalue::CopyForDeref(place) => { self.handle_operand(&Operand::Copy(*place), state).into() } - _ => { - // FIXME: Check that other Rvalues really have no side-effect. - ValueOrPlaceOrRef::Unknown - } + _ => ValueOrPlaceOrRef::Unknown, } } @@ -200,7 +197,20 @@ pub trait ValueAnalysis<'tcx> { self.super_terminator(terminator, state) } - fn super_terminator(&self, _terminator: &Terminator<'tcx>, _state: &mut State) {} + fn super_terminator(&self, terminator: &Terminator<'tcx>, _state: &mut State) { + match &terminator.kind { + TerminatorKind::Call { .. } | TerminatorKind::InlineAsm { .. } => { + // Effect is applied by `handle_call_return`. + } + TerminatorKind::DropAndReplace { .. } | TerminatorKind::Yield { .. } => { + // They would have an effect, but are not allowed in this phase. + bug!("encountered disallowed terminator"); + } + _ => { + // The other terminators can be ignored. + } + } + } fn handle_call_return( &self, diff --git a/compiler/rustc_mir_transform/src/dataflow_const_prop.rs b/compiler/rustc_mir_transform/src/dataflow_const_prop.rs index f461514716e..c80ff3dd3ec 100644 --- a/compiler/rustc_mir_transform/src/dataflow_const_prop.rs +++ b/compiler/rustc_mir_transform/src/dataflow_const_prop.rs @@ -35,7 +35,6 @@ impl<'tcx> MirPass<'tcx> for DataflowConstProp { } } -// FIXME: Consider support for discriminants, mutable references, arrays and slices. struct ConstAnalysis<'tcx> { map: Map, tcx: TyCtxt<'tcx>,