1
1
use crate :: rustc:: hir:: { Expr , ExprKind , QPath } ;
2
2
use crate :: rustc:: lint:: { LateContext , LateLintPass , LintArray , LintPass } ;
3
3
use 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} ;
5
5
use if_chain:: if_chain;
6
6
7
7
/// **What it does:** Checks for explicit deref() or deref_mut() method calls.
@@ -15,8 +15,7 @@ use if_chain::if_chain;
15
15
/// let c = a.deref_mut();
16
16
///
17
17
/// // excludes
18
- /// let e = d.deref().unwrap();
19
- /// let f = a.deref().unwrap();
18
+ /// let e = d.unwrap().deref();
20
19
/// ```
21
20
declare_clippy_lint ! {
22
21
pub EXPLICIT_DEREF_METHOD ,
@@ -34,6 +33,10 @@ impl LintPass for Pass {
34
33
35
34
impl < ' a , ' tcx > LateLintPass < ' a , ' tcx > for Pass {
36
35
fn check_expr ( & mut self , cx : & LateContext < ' _ , ' _ > , expr : & Expr ) {
36
+ if in_macro ( expr. span ) {
37
+ return ;
38
+ }
39
+
37
40
if_chain ! {
38
41
// if this is a method call
39
42
if let ExprKind :: MethodCall ( ref method_name, _, ref args) = & expr. node;
0 commit comments