diff options
| author | Wesley Wiser <wwiser@gmail.com> | 2019-10-12 08:21:51 -0400 |
|---|---|---|
| committer | Wesley Wiser <wwiser@gmail.com> | 2019-10-20 23:49:12 -0400 |
| commit | 4592a9eb3f240cef2994ee76f6975c4946d4d269 (patch) | |
| tree | b4912e76e719e7e97d6e62cec5ae69369ba53ac7 | |
| parent | 770b9e3012bd58bdf6046d328dabfd57df163eb6 (diff) | |
| download | rust-4592a9eb3f240cef2994ee76f6975c4946d4d269.tar.gz rust-4592a9eb3f240cef2994ee76f6975c4946d4d269.zip | |
Cleanup `ConstProp::visit_statement()`
| -rw-r--r-- | src/librustc_mir/transform/const_prop.rs | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/src/librustc_mir/transform/const_prop.rs b/src/librustc_mir/transform/const_prop.rs index 780b49cd9db..4a3a182cea2 100644 --- a/src/librustc_mir/transform/const_prop.rs +++ b/src/librustc_mir/transform/const_prop.rs @@ -431,7 +431,7 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> { place_layout: TyLayout<'tcx>, source_info: SourceInfo, place: &Place<'tcx>, - ) -> Option<Const<'tcx>> { + ) -> Option<()> { let span = source_info.span; let overflow_check = self.tcx.sess.overflow_checks(); @@ -553,7 +553,7 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> { self.use_ecx(source_info, |this| { trace!("calling eval_rvalue_into_place(rvalue = {:?}, place = {:?})", rvalue, place); this.ecx.eval_rvalue_into_place(rvalue, place)?; - this.ecx.eval_place_to_op(place, Some(place_layout)) + Ok(()) }) } @@ -717,16 +717,15 @@ impl<'mir, 'tcx> MutVisitor<'tcx> for ConstPropagator<'mir, 'tcx> { base: PlaceBase::Local(local), projection: box [], } = *place { - if let Some(value) = self.const_prop(rval, - place_layout, - statement.source_info, - place) { - trace!("checking whether {:?} can be stored to {:?}", value, local); + let source = statement.source_info; + if let Some(()) = self.const_prop(rval, place_layout, source, place) { if self.can_const_prop[local] { - trace!("stored {:?} to {:?}", value, local); - assert_eq!(self.get_const(local), Some(value)); + trace!("propagated into {:?}", local); if self.should_const_prop() { + let value = + self.get_const(local).expect("local was dead/uninitialized"); + trace!("replacing {:?} with {:?}", rval, value); self.replace_with_const( rval, value, @@ -734,7 +733,7 @@ impl<'mir, 'tcx> MutVisitor<'tcx> for ConstPropagator<'mir, 'tcx> { ); } } else { - trace!("can't propagate {:?} to {:?}", value, local); + trace!("can't propagate into {:?}", local); self.remove_const(local); } } |
