11use crate :: rustc:: hir:: { Expr , ExprKind , QPath } ;
22use crate :: rustc:: lint:: { LateContext , LateLintPass , LintArray , LintPass } ;
33use crate :: rustc:: { declare_tool_lint, lint_array} ;
4- use crate :: utils:: span_lint_and_sugg;
4+ use crate :: utils:: { in_macro , span_lint_and_sugg} ;
55use if_chain:: if_chain;
66
77/// **What it does:** Checks for explicit deref() or deref_mut() method calls.
@@ -15,8 +15,7 @@ use if_chain::if_chain;
1515/// let c = a.deref_mut();
1616///
1717/// // excludes
18- /// let e = d.deref().unwrap();
19- /// let f = a.deref().unwrap();
18+ /// let e = d.unwrap().deref();
2019/// ```
2120declare_clippy_lint ! {
2221 pub EXPLICIT_DEREF_METHOD ,
@@ -34,6 +33,10 @@ impl LintPass for Pass {
3433
3534impl < ' a , ' tcx > LateLintPass < ' a , ' tcx > for Pass {
3635 fn check_expr ( & mut self , cx : & LateContext < ' _ , ' _ > , expr : & Expr ) {
36+ if in_macro ( expr. span ) {
37+ return ;
38+ }
39+
3740 if_chain ! {
3841 // if this is a method call
3942 if let ExprKind :: MethodCall ( ref method_name, _, ref args) = & expr. node;
0 commit comments