@@ -252,6 +252,11 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for ConstPropMachine<'mir, 'tcx>
252252 throw_machine_stop_str ! ( "tried to write to a local that is marked as not propagatable" )
253253 }
254254 if frame == 0 && ecx. machine . only_propagate_inside_block_locals . contains ( local) {
255+ trace ! (
256+ "mutating local {:?} which is restricted to its block. \
257+ Will remove it from const-prop after block is finished.",
258+ local
259+ ) ;
255260 ecx. machine . written_only_inside_own_block_locals . insert ( local) ;
256261 }
257262 ecx. machine . stack [ frame] . locals [ local] . access_mut ( )
@@ -427,6 +432,7 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
427432 match f ( self ) {
428433 Ok ( val) => Some ( val) ,
429434 Err ( error) => {
435+ trace ! ( "InterpCx operation failed: {:?}" , error) ;
430436 // Some errors shouldn't come up because creating them causes
431437 // an allocation, which we should avoid. When that happens,
432438 // dedicated error variants should be introduced instead.
@@ -969,10 +975,10 @@ impl<'tcx> Visitor<'tcx> for CanConstProp {
969975 ConstPropMode :: OnlyPropagateInto => { }
970976 other @ ConstPropMode :: FullConstProp => {
971977 trace ! (
972- "local {:?} can't be propagated because of multiple assignments" ,
973- local,
978+ "local {:?} can't be propagated because of multiple assignments. Previous state: {:?} " ,
979+ local, other ,
974980 ) ;
975- * other = ConstPropMode :: OnlyPropagateInto ;
981+ * other = ConstPropMode :: OnlyInsideOwnBlock ;
976982 }
977983 }
978984 }
@@ -1089,6 +1095,20 @@ impl<'mir, 'tcx> MutVisitor<'tcx> for ConstPropagator<'mir, 'tcx> {
10891095 }
10901096 } else {
10911097 match statement. kind {
1098+ StatementKind :: SetDiscriminant { ref place, .. } => {
1099+ match self . ecx . machine . can_const_prop [ place. local ] {
1100+ ConstPropMode :: FullConstProp | ConstPropMode :: OnlyInsideOwnBlock => {
1101+ if self . use_ecx ( |this| this. ecx . statement ( statement) ) . is_some ( ) {
1102+ trace ! ( "propped discriminant into {:?}" , place) ;
1103+ } else {
1104+ Self :: remove_const ( & mut self . ecx , place. local ) ;
1105+ }
1106+ }
1107+ ConstPropMode :: OnlyPropagateInto | ConstPropMode :: NoPropagation => {
1108+ Self :: remove_const ( & mut self . ecx , place. local ) ;
1109+ }
1110+ }
1111+ }
10921112 StatementKind :: StorageLive ( local) | StatementKind :: StorageDead ( local) => {
10931113 let frame = self . ecx . frame_mut ( ) ;
10941114 frame. locals [ local] . value =
0 commit comments