@@ -75,10 +75,9 @@ impl<'tcx> LateLintPass<'tcx> for ImplicitAutorefs {
7575 _ => return ,
7676 } ,
7777 ExprKind :: Index ( base, _, _) => base,
78- ExprKind :: MethodCall ( _, inner, _, _)
79- if let Some ( def_id) = cx. typeck_results ( ) . type_dependent_def_id ( expr. hir_id )
80- && cx. tcx . has_attr ( def_id, sym:: rustc_no_implicit_autorefs) =>
81- {
78+ ExprKind :: MethodCall ( _, inner, _, _) => {
79+ // PERF: Checking of `#[rustc_no_implicit_refs]` is deferred below
80+ // because checking for attribute is a bit costly.
8281 inner
8382 }
8483 ExprKind :: Field ( inner, _) => inner,
@@ -99,6 +98,14 @@ impl<'tcx> LateLintPass<'tcx> for ImplicitAutorefs {
9998 peel_place_mappers ( inner) . kind
10099 // 1. Deref of a raw pointer.
101100 && typeck. expr_ty ( dereferenced) . is_raw_ptr ( )
101+ // PERF: 5. b. A method call annotated with `#[rustc_no_implicit_refs]`
102+ && match expr. kind {
103+ ExprKind :: MethodCall ( ..) => matches ! (
104+ cx. typeck_results( ) . type_dependent_def_id( expr. hir_id) ,
105+ Some ( def_id) if cx. tcx. has_attr( def_id, sym:: rustc_no_implicit_autorefs)
106+ ) ,
107+ _ => true ,
108+ }
102109 {
103110 cx. emit_span_lint (
104111 DANGEROUS_IMPLICIT_AUTOREFS ,
0 commit comments