@@ -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 {
@@ -516,6 +517,7 @@ impl<'a, 'mir, 'tcx> ConstPropagator<'a, 'mir, 'tcx> {
516
517
}
517
518
518
519
fn replace_with_const ( & self , rval : & mut Rvalue < ' tcx > , value : Const < ' tcx > , span : Span ) {
520
+ trace ! ( "attepting to replace {:?} with {:?}" , rval, value) ;
519
521
self . ecx . validate_operand (
520
522
value,
521
523
vec ! [ ] ,
@@ -579,6 +581,10 @@ impl CanConstProp {
579
581
// FIXME(oli-obk): lint variables until they are used in a condition
580
582
// FIXME(oli-obk): lint if return value is constant
581
583
* val = mir. local_kind ( local) == LocalKind :: Temp ;
584
+
585
+ if !* val {
586
+ trace ! ( "local {:?} can't be propagated because it's not a temporary" , local) ;
587
+ }
582
588
}
583
589
cpv. visit_mir ( mir) ;
584
590
cpv. can_const_prop
@@ -598,6 +604,7 @@ impl<'tcx> Visitor<'tcx> for CanConstProp {
598
604
// FIXME(oli-obk): we could be more powerful here, if the multiple writes
599
605
// only occur in independent execution paths
600
606
MutatingUse ( MutatingUseContext :: Store ) => if self . found_assignment [ local] {
607
+ trace ! ( "local {:?} can't be propagated because of multiple assignments" , local) ;
601
608
self . can_const_prop [ local] = false ;
602
609
} else {
603
610
self . found_assignment [ local] = true
@@ -609,7 +616,10 @@ impl<'tcx> Visitor<'tcx> for CanConstProp {
609
616
NonMutatingUse ( NonMutatingUseContext :: Projection ) |
610
617
MutatingUse ( MutatingUseContext :: Projection ) |
611
618
NonUse ( _) => { } ,
612
- _ => self . can_const_prop [ local] = false ,
619
+ _ => {
620
+ trace ! ( "local {:?} can't be propagaged because it's used: {:?}" , local, context) ;
621
+ self . can_const_prop [ local] = false ;
622
+ } ,
613
623
}
614
624
}
615
625
}
0 commit comments