@@ -295,6 +295,7 @@ impl<'a, 'mir, 'tcx> ConstPropagator<'a, 'mir, 'tcx> {
295295 }
296296
297297 fn eval_place ( & mut self , place : & Place < ' tcx > , source_info : SourceInfo ) -> Option < Const < ' tcx > > {
298+ trace ! ( "eval_place(place={:?})" , place) ;
298299 match * place {
299300 Place :: Base ( PlaceBase :: Local ( loc) ) => self . places [ loc] . clone ( ) ,
300301 Place :: Projection ( ref proj) => match proj. elem {
@@ -515,6 +516,7 @@ impl<'a, 'mir, 'tcx> ConstPropagator<'a, 'mir, 'tcx> {
515516 }
516517
517518 fn replace_with_const ( & self , rval : & mut Rvalue < ' tcx > , value : Const < ' tcx > , span : Span ) {
519+ trace ! ( "attepting to replace {:?} with {:?}" , rval, value) ;
518520 self . ecx . validate_operand (
519521 value,
520522 vec ! [ ] ,
@@ -578,6 +580,10 @@ impl CanConstProp {
578580 // FIXME(oli-obk): lint variables until they are used in a condition
579581 // FIXME(oli-obk): lint if return value is constant
580582 * val = mir. local_kind ( local) == LocalKind :: Temp ;
583+
584+ if !* val {
585+ trace ! ( "local {:?} can't be propagated because it's not a temporary" , local) ;
586+ }
581587 }
582588 cpv. visit_mir ( mir) ;
583589 cpv. can_const_prop
@@ -597,6 +603,7 @@ impl<'tcx> Visitor<'tcx> for CanConstProp {
597603 // FIXME(oli-obk): we could be more powerful here, if the multiple writes
598604 // only occur in independent execution paths
599605 MutatingUse ( MutatingUseContext :: Store ) => if self . found_assignment [ local] {
606+ trace ! ( "local {:?} can't be propagated because of multiple assignments" , local) ;
600607 self . can_const_prop [ local] = false ;
601608 } else {
602609 self . found_assignment [ local] = true
@@ -608,7 +615,10 @@ impl<'tcx> Visitor<'tcx> for CanConstProp {
608615 NonMutatingUse ( NonMutatingUseContext :: Projection ) |
609616 MutatingUse ( MutatingUseContext :: Projection ) |
610617 NonUse ( _) => { } ,
611- _ => self . can_const_prop [ local] = false ,
618+ _ => {
619+ trace ! ( "local {:?} can't be propagaged because it's used: {:?}" , local, context) ;
620+ self . can_const_prop [ local] = false ;
621+ } ,
612622 }
613623 }
614624}
0 commit comments