@@ -176,7 +176,8 @@ impl<'tcx> Inliner<'tcx> {
176
176
callee : & Instance < ' tcx > ,
177
177
) -> Result < ( ) , & ' static str > {
178
178
let caller_def_id = caller_body. source . def_id ( ) ;
179
- if callee. def_id ( ) == caller_def_id {
179
+ let callee_def_id = callee. def_id ( ) ;
180
+ if callee_def_id == caller_def_id {
180
181
return Err ( "self-recursion" ) ;
181
182
}
182
183
@@ -185,7 +186,7 @@ impl<'tcx> Inliner<'tcx> {
185
186
// If there is no MIR available (either because it was not in metadata or
186
187
// because it has no MIR because it's an extern function), then the inliner
187
188
// won't cause cycles on this.
188
- if !self . tcx . is_mir_available ( callee . def_id ( ) ) {
189
+ if !self . tcx . is_mir_available ( callee_def_id ) {
189
190
return Err ( "item MIR unavailable" ) ;
190
191
}
191
192
}
@@ -205,19 +206,19 @@ impl<'tcx> Inliner<'tcx> {
205
206
| InstanceDef :: CloneShim ( ..) => return Ok ( ( ) ) ,
206
207
}
207
208
208
- if self . tcx . is_constructor ( callee . def_id ( ) ) {
209
+ if self . tcx . is_constructor ( callee_def_id ) {
209
210
trace ! ( "constructors always have MIR" ) ;
210
211
// Constructor functions cannot cause a query cycle.
211
212
return Ok ( ( ) ) ;
212
213
}
213
214
214
- if let Some ( callee_def_id) = callee . def_id ( ) . as_local ( ) {
215
+ if callee_def_id. is_local ( ) {
215
216
// Avoid a cycle here by only using `instance_mir` only if we have
216
217
// a lower `DefPathHash` than the callee. This ensures that the callee will
217
218
// not inline us. This trick even works with incremental compilation,
218
219
// since `DefPathHash` is stable.
219
220
if self . tcx . def_path_hash ( caller_def_id) . local_hash ( )
220
- < self . tcx . def_path_hash ( callee_def_id. to_def_id ( ) ) . local_hash ( )
221
+ < self . tcx . def_path_hash ( callee_def_id) . local_hash ( )
221
222
{
222
223
return Ok ( ( ) ) ;
223
224
}
0 commit comments