@@ -232,9 +232,18 @@ fn late_report_deprecation(
232
232
return ;
233
233
}
234
234
235
+ let is_in_effect = depr. is_in_effect ( ) ;
236
+ let lint = deprecation_lint ( is_in_effect) ;
237
+
238
+ // Calculating message for lint involves calling `self.def_path_str`,
239
+ // which will by default invoke the expensive `visible_parent_map` query.
240
+ // Skip all that work if the lint is allowed anyway.
241
+ if tcx. lint_level_at_node ( lint, hir_id) . 0 == Level :: Allow {
242
+ return ;
243
+ }
244
+
235
245
let def_path = with_no_trimmed_paths ! ( tcx. def_path_str( def_id) ) ;
236
246
let def_kind = tcx. def_descr ( def_id) ;
237
- let is_in_effect = depr. is_in_effect ( ) ;
238
247
239
248
let method_span = method_span. unwrap_or ( span) ;
240
249
let suggestion =
@@ -250,7 +259,7 @@ fn late_report_deprecation(
250
259
note : depr. note ,
251
260
since_kind : deprecated_since_kind ( is_in_effect, depr. since ) ,
252
261
} ;
253
- tcx. emit_node_span_lint ( deprecation_lint ( is_in_effect ) , hir_id, method_span, diag) ;
262
+ tcx. emit_node_span_lint ( lint , hir_id, method_span, diag) ;
254
263
}
255
264
256
265
/// Result of `TyCtxt::eval_stability`.
@@ -360,13 +369,7 @@ impl<'tcx> TyCtxt<'tcx> {
360
369
// hierarchy.
361
370
let depr_attr = & depr_entry. attr ;
362
371
if !skip || depr_attr. is_since_rustc_version ( ) {
363
- // Calculating message for lint involves calling `self.def_path_str`.
364
- // Which by default to calculate visible path will invoke expensive `visible_parent_map` query.
365
- // So we skip message calculation altogether, if lint is allowed.
366
- let lint = deprecation_lint ( depr_attr. is_in_effect ( ) ) ;
367
- if self . lint_level_at_node ( lint, id) . 0 != Level :: Allow {
368
- late_report_deprecation ( self , depr_attr, span, method_span, id, def_id) ;
369
- }
372
+ late_report_deprecation ( self , depr_attr, span, method_span, id, def_id) ;
370
373
}
371
374
} ;
372
375
}
0 commit comments