@@ -75,10 +75,9 @@ impl<'tcx> LateLintPass<'tcx> for ImplicitAutorefs {
75
75
_ => return ,
76
76
} ,
77
77
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.
82
81
inner
83
82
}
84
83
ExprKind :: Field ( inner, _) => inner,
@@ -99,6 +98,14 @@ impl<'tcx> LateLintPass<'tcx> for ImplicitAutorefs {
99
98
peel_place_mappers ( inner) . kind
100
99
// 1. Deref of a raw pointer.
101
100
&& 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
+ }
102
109
{
103
110
cx. emit_span_lint (
104
111
DANGEROUS_IMPLICIT_AUTOREFS ,
0 commit comments