@@ -232,9 +232,18 @@ fn late_report_deprecation(
232232 return ;
233233 }
234234
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+
235245 let def_path = with_no_trimmed_paths ! ( tcx. def_path_str( def_id) ) ;
236246 let def_kind = tcx. def_descr ( def_id) ;
237- let is_in_effect = depr. is_in_effect ( ) ;
238247
239248 let method_span = method_span. unwrap_or ( span) ;
240249 let suggestion =
@@ -250,7 +259,7 @@ fn late_report_deprecation(
250259 note : depr. note ,
251260 since_kind : deprecated_since_kind ( is_in_effect, depr. since ) ,
252261 } ;
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) ;
254263}
255264
256265/// Result of `TyCtxt::eval_stability`.
@@ -360,13 +369,7 @@ impl<'tcx> TyCtxt<'tcx> {
360369 // hierarchy.
361370 let depr_attr = & depr_entry. attr ;
362371 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) ;
370373 }
371374 } ;
372375 }
0 commit comments