@@ -295,6 +295,7 @@ impl<'a, 'mir, 'tcx> ConstPropagator<'a, 'mir, 'tcx> {
295
295
}
296
296
297
297
fn eval_place ( & mut self , place : & Place < ' tcx > , source_info : SourceInfo ) -> Option < Const < ' tcx > > {
298
+ trace ! ( "eval_place(place={:?})" , place) ;
298
299
match * place {
299
300
Place :: Base ( PlaceBase :: Local ( loc) ) => self . places [ loc] . clone ( ) ,
300
301
Place :: Projection ( ref proj) => match proj. elem {
@@ -515,6 +516,7 @@ impl<'a, 'mir, 'tcx> ConstPropagator<'a, 'mir, 'tcx> {
515
516
}
516
517
517
518
fn replace_with_const ( & self , rval : & mut Rvalue < ' tcx > , value : Const < ' tcx > , span : Span ) {
519
+ trace ! ( "attepting to replace {:?} with {:?}" , rval, value) ;
518
520
self . ecx . validate_operand (
519
521
value,
520
522
vec ! [ ] ,
@@ -578,6 +580,10 @@ impl CanConstProp {
578
580
// FIXME(oli-obk): lint variables until they are used in a condition
579
581
// FIXME(oli-obk): lint if return value is constant
580
582
* 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
+ }
581
587
}
582
588
cpv. visit_mir ( mir) ;
583
589
cpv. can_const_prop
@@ -597,6 +603,7 @@ impl<'tcx> Visitor<'tcx> for CanConstProp {
597
603
// FIXME(oli-obk): we could be more powerful here, if the multiple writes
598
604
// only occur in independent execution paths
599
605
MutatingUse ( MutatingUseContext :: Store ) => if self . found_assignment [ local] {
606
+ trace ! ( "local {:?} can't be propagated because of multiple assignments" , local) ;
600
607
self . can_const_prop [ local] = false ;
601
608
} else {
602
609
self . found_assignment [ local] = true
@@ -608,7 +615,10 @@ impl<'tcx> Visitor<'tcx> for CanConstProp {
608
615
NonMutatingUse ( NonMutatingUseContext :: Projection ) |
609
616
MutatingUse ( MutatingUseContext :: Projection ) |
610
617
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
+ } ,
612
622
}
613
623
}
614
624
}
0 commit comments