@@ -98,33 +98,36 @@ struct Collector<'a, 'tcx> {
98
98
}
99
99
100
100
impl < ' tcx > Visitor < ' tcx > for Collector < ' _ , ' tcx > {
101
+ #[ instrument( level = "debug" , skip( self ) ) ]
101
102
fn visit_local ( & mut self , index : Local , context : PlaceContext , location : Location ) {
102
- debug ! ( "visit_local: index={:?} context={:?} location={:?}" , index, context, location) ;
103
103
// We're only interested in temporaries and the return place
104
104
match self . ccx . body . local_kind ( index) {
105
105
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
+ }
107
115
LocalKind :: ReturnPointer | LocalKind :: Temp => { }
108
116
}
109
117
110
118
// Ignore drops, if the temp gets promoted,
111
119
// then it's constant and thus drop is noop.
112
120
// Non-uses are also irrelevant.
113
121
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( ) ) ;
119
123
return ;
120
124
}
121
125
122
126
let temp = & mut self . temps [ index] ;
123
- debug ! ( "visit_local: temp={:?}" , temp) ;
127
+ debug ! ( ? temp) ;
124
128
* temp = match * temp {
125
129
TempState :: Undefined => match context {
126
- PlaceContext :: MutatingUse ( MutatingUseContext :: Store )
127
- | PlaceContext :: MutatingUse ( MutatingUseContext :: Call ) => {
130
+ PlaceContext :: MutatingUse ( MutatingUseContext :: Store | MutatingUseContext :: Call ) => {
128
131
TempState :: Defined { location, uses : 0 , valid : Err ( ( ) ) }
129
132
}
130
133
_ => TempState :: Unpromotable ,
@@ -137,7 +140,7 @@ impl<'tcx> Visitor<'tcx> for Collector<'_, 'tcx> {
137
140
| PlaceContext :: NonMutatingUse ( _) => true ,
138
141
PlaceContext :: MutatingUse ( _) | PlaceContext :: NonUse ( _) => false ,
139
142
} ;
140
- debug ! ( "visit_local: allowed_use={:?}" , allowed_use) ;
143
+ debug ! ( ? allowed_use) ;
141
144
if allowed_use {
142
145
* uses += 1 ;
143
146
return ;
@@ -146,6 +149,7 @@ impl<'tcx> Visitor<'tcx> for Collector<'_, 'tcx> {
146
149
}
147
150
TempState :: Unpromotable | TempState :: PromotedOut => TempState :: Unpromotable ,
148
151
} ;
152
+ debug ! ( ?temp) ;
149
153
}
150
154
151
155
fn visit_rvalue ( & mut self , rvalue : & Rvalue < ' tcx > , location : Location ) {
@@ -972,7 +976,12 @@ fn promote_candidates<'tcx>(
972
976
candidates : Vec < Candidate > ,
973
977
) -> IndexVec < Promoted , Body < ' tcx > > {
974
978
// 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
+ }
976
985
977
986
let mut promotions = IndexVec :: new ( ) ;
978
987
0 commit comments