|
3 | 3 | //! This lint is **warn** by default
|
4 | 4 |
|
5 | 5 | use rustc::lint::*;
|
6 |
| -use rustc::hir::{MutImmutable, Pat, PatKind, BindByRef}; |
7 |
| -use rustc::ty; |
| 6 | +use rustc::hir::{MutImmutable, Pat, PatKind, BindingAnnotation}; |
8 | 7 | use utils::{span_lint_and_then, in_macro, snippet};
|
9 | 8 |
|
10 | 9 | /// **What it does:** Checks for useless borrowed references.
|
@@ -63,16 +62,11 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessBorrowedRef {
|
63 | 62 | }
|
64 | 63 |
|
65 | 64 | if_let_chain! {[
|
66 |
| - // Pat is a pattern whose node |
67 |
| - // is a binding which "involves" an immutable reference... |
68 |
| - let PatKind::Binding(BindingAnnotation::Ref, ..) = pat.node, |
69 |
| - // Pattern's type is a reference. Get the type and mutability of referenced value (tam: TypeAndMut). |
70 |
| - let ty::TyRef(_, ref tam) = cx.tables.pat_ty(pat).sty, |
71 | 65 | // Only lint immutable refs, because `&mut ref T` may be useful.
|
72 | 66 | let PatKind::Ref(ref sub_pat, MutImmutable) = pat.node,
|
73 | 67 |
|
74 | 68 | // Check sub_pat got a `ref` keyword (excluding `ref mut`).
|
75 |
| - let PatKind::Binding(BindByRef(MutImmutable), _, spanned_name, ..) = sub_pat.node, |
| 69 | + let PatKind::Binding(BindingAnnotation::Ref, _, spanned_name, ..) = sub_pat.node, |
76 | 70 | ], {
|
77 | 71 | span_lint_and_then(cx, NEEDLESS_BORROWED_REFERENCE, pat.span,
|
78 | 72 | "this pattern takes a reference on something that is being de-referenced",
|
|
0 commit comments