@@ -633,24 +633,22 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
633633 fn propagate_operand ( & mut self , operand : & mut Operand < ' tcx > ) {
634634 match * operand {
635635 Operand :: Copy ( l) | Operand :: Move ( l) => {
636- if let Some ( value) = self . get_const ( l) {
637- if self . should_const_prop ( & value) {
638- // FIXME(felix91gr): this code only handles `Scalar` cases.
639- // For now, we're not handling `ScalarPair` cases because
640- // doing so here would require a lot of code duplication.
641- // We should hopefully generalize `Operand` handling into a fn,
642- // and use it to do const-prop here and everywhere else
643- // where it makes sense.
644- if let interpret:: Operand :: Immediate ( interpret:: Immediate :: Scalar (
645- ScalarMaybeUninit :: Scalar ( scalar) ,
646- ) ) = * value
647- {
648- * operand = self . operand_from_scalar (
649- scalar,
650- value. layout . ty ,
651- self . source_info . unwrap ( ) . span ,
652- ) ;
653- }
636+ if let Some ( value) = self . get_const ( l) && self . should_const_prop ( & value) {
637+ // FIXME(felix91gr): this code only handles `Scalar` cases.
638+ // For now, we're not handling `ScalarPair` cases because
639+ // doing so here would require a lot of code duplication.
640+ // We should hopefully generalize `Operand` handling into a fn,
641+ // and use it to do const-prop here and everywhere else
642+ // where it makes sense.
643+ if let interpret:: Operand :: Immediate ( interpret:: Immediate :: Scalar (
644+ ScalarMaybeUninit :: Scalar ( scalar) ,
645+ ) ) = * value
646+ {
647+ * operand = self . operand_from_scalar (
648+ scalar,
649+ value. layout . ty ,
650+ self . source_info . unwrap ( ) . span ,
651+ ) ;
654652 }
655653 }
656654 }
@@ -1086,15 +1084,13 @@ impl<'tcx> MutVisitor<'tcx> for ConstPropagator<'_, 'tcx> {
10861084 // This will return None if the above `const_prop` invocation only "wrote" a
10871085 // type whose creation requires no write. E.g. a generator whose initial state
10881086 // consists solely of uninitialized memory (so it doesn't capture any locals).
1089- if let Some ( ref value) = self . get_const ( place) {
1090- if self . should_const_prop ( value) {
1091- trace ! ( "replacing {:?} with {:?}" , rval, value) ;
1092- self . replace_with_const ( rval, value, source_info) ;
1093- if can_const_prop == ConstPropMode :: FullConstProp
1094- || can_const_prop == ConstPropMode :: OnlyInsideOwnBlock
1095- {
1096- trace ! ( "propagated into {:?}" , place) ;
1097- }
1087+ if let Some ( ref value) = self . get_const ( place) && self . should_const_prop ( value) {
1088+ trace ! ( "replacing {:?} with {:?}" , rval, value) ;
1089+ self . replace_with_const ( rval, value, source_info) ;
1090+ if can_const_prop == ConstPropMode :: FullConstProp
1091+ || can_const_prop == ConstPropMode :: OnlyInsideOwnBlock
1092+ {
1093+ trace ! ( "propagated into {:?}" , place) ;
10981094 }
10991095 }
11001096 match can_const_prop {
0 commit comments