|
2 | 2 |
|
3 | 3 | use crate::utils::{match_type, paths, snippet_with_applicability, span_lint_and_sugg, SpanlessEq};
|
4 | 4 | use if_chain::if_chain;
|
5 |
| -use rustc::hir::{Expr, ExprKind}; |
| 5 | +use rustc::hir::{Expr, ExprKind, BinOpKind}; |
6 | 6 | use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
|
7 | 7 | use rustc::{declare_lint_pass, declare_tool_lint};
|
8 | 8 | use rustc_errors::Applicability;
|
9 | 9 | use syntax::ast::LitKind;
|
| 10 | +use syntax::symbol::Symbol; |
| 11 | +use syntax::source_map::Spanned; |
10 | 12 |
|
11 | 13 | declare_clippy_lint! {
|
12 | 14 | /// **What it does:** Checks for using `x.get(x.len() - 1)` instead of
|
@@ -49,12 +51,12 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UseLast {
|
49 | 51 | if let ExprKind::MethodCall(ref path, _, ref args) = expr.node;
|
50 | 52 |
|
51 | 53 | // Method name is "get"
|
52 |
| - if path.ident.name == "get"; |
| 54 | + if path.ident.name == Symbol::intern("get"); |
53 | 55 |
|
54 | 56 | // Argument 0 (the struct we're calling the method on) is a vector
|
55 | 57 | if let Some(struct_calling_on) = args.get(0);
|
56 | 58 | let struct_ty = cx.tables.expr_ty(struct_calling_on);
|
57 |
| - if match_type(cx, struct_ty, &paths::VEC); |
| 59 | + if match_type(cx, struct_ty, &*paths::VEC); |
58 | 60 |
|
59 | 61 | // Argument to "get" is a binary operation
|
60 | 62 | if let Some(get_index_arg) = args.get(1);
|
|
0 commit comments