@@ -98,33 +98,36 @@ struct Collector<'a, 'tcx> {
9898}
9999
100100impl < ' tcx > Visitor < ' tcx > for Collector < ' _ , ' tcx > {
101+ #[ instrument( level = "debug" , skip( self ) ) ]
101102 fn visit_local ( & mut self , index : Local , context : PlaceContext , location : Location ) {
102- debug ! ( "visit_local: index={:?} context={:?} location={:?}" , index, context, location) ;
103103 // We're only interested in temporaries and the return place
104104 match self . ccx . body . local_kind ( index) {
105105 LocalKind :: Arg => return ,
106- LocalKind :: Temp if self . ccx . body . local_decls [ index] . is_user_variable ( ) => return ,
106+ LocalKind :: Temp
107+ if {
108+ let is_user_variable = self . ccx . body . local_decls [ index] . is_user_variable ( ) ;
109+ debug ! ( ?is_user_variable) ;
110+ is_user_variable
111+ } =>
112+ {
113+ return ;
114+ }
107115 LocalKind :: ReturnPointer | LocalKind :: Temp => { }
108116 }
109117
110118 // Ignore drops, if the temp gets promoted,
111119 // then it's constant and thus drop is noop.
112120 // Non-uses are also irrelevant.
113121 if context. is_drop ( ) || !context. is_use ( ) {
114- debug ! (
115- "visit_local: context.is_drop={:?} context.is_use={:?}" ,
116- context. is_drop( ) ,
117- context. is_use( ) ,
118- ) ;
122+ debug ! ( is_drop = context. is_drop( ) , is_use = context. is_use( ) ) ;
119123 return ;
120124 }
121125
122126 let temp = & mut self . temps [ index] ;
123- debug ! ( "visit_local: temp={:?}" , temp) ;
127+ debug ! ( ? temp) ;
124128 * temp = match * temp {
125129 TempState :: Undefined => match context {
126- PlaceContext :: MutatingUse ( MutatingUseContext :: Store )
127- | PlaceContext :: MutatingUse ( MutatingUseContext :: Call ) => {
130+ PlaceContext :: MutatingUse ( MutatingUseContext :: Store | MutatingUseContext :: Call ) => {
128131 TempState :: Defined { location, uses : 0 , valid : Err ( ( ) ) }
129132 }
130133 _ => TempState :: Unpromotable ,
@@ -137,7 +140,7 @@ impl<'tcx> Visitor<'tcx> for Collector<'_, 'tcx> {
137140 | PlaceContext :: NonMutatingUse ( _) => true ,
138141 PlaceContext :: MutatingUse ( _) | PlaceContext :: NonUse ( _) => false ,
139142 } ;
140- debug ! ( "visit_local: allowed_use={:?}" , allowed_use) ;
143+ debug ! ( ? allowed_use) ;
141144 if allowed_use {
142145 * uses += 1 ;
143146 return ;
@@ -146,6 +149,7 @@ impl<'tcx> Visitor<'tcx> for Collector<'_, 'tcx> {
146149 }
147150 TempState :: Unpromotable | TempState :: PromotedOut => TempState :: Unpromotable ,
148151 } ;
152+ debug ! ( ?temp) ;
149153 }
150154
151155 fn visit_rvalue ( & mut self , rvalue : & Rvalue < ' tcx > , location : Location ) {
@@ -972,7 +976,12 @@ fn promote_candidates<'tcx>(
972976 candidates : Vec < Candidate > ,
973977) -> IndexVec < Promoted , Body < ' tcx > > {
974978 // Visit candidates in reverse, in case they're nested.
975- debug ! ( "promote_candidates({:?})" , candidates) ;
979+ debug ! ( promote_candidates = ?candidates) ;
980+
981+ // eagerly fail fast
982+ if candidates. is_empty ( ) {
983+ return IndexVec :: new ( ) ;
984+ }
976985
977986 let mut promotions = IndexVec :: new ( ) ;
978987
0 commit comments