]> git.lizzy.rs Git - rust.git/blobdiff - clippy_lints/src/get_last_with_len.rs
Rollup merge of #83092 - petrochenkov:qspan, r=estebank
[rust.git] / clippy_lints / src / get_last_with_len.rs
index 3629ba623ce43a64dc6176ccac1e21722fe3cbd0..cdd8a42e7cd12c003363c1e538b2f4564b79803b 100644 (file)
@@ -8,6 +8,7 @@
 use rustc_lint::{LateContext, LateLintPass};
 use rustc_session::{declare_lint_pass, declare_tool_lint};
 use rustc_span::source_map::Spanned;
+use rustc_span::sym;
 
 declare_clippy_lint! {
     /// **What it does:** Checks for using `x.get(x.len() - 1)` instead of
@@ -43,8 +44,8 @@
 
 declare_lint_pass!(GetLastWithLen => [GET_LAST_WITH_LEN]);
 
-impl<'a, 'tcx> LateLintPass<'a, 'tcx> for GetLastWithLen {
-    fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr<'_>) {
+impl<'tcx> LateLintPass<'tcx> for GetLastWithLen {
+    fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
         if_chain! {
             // Is a method call
             if let ExprKind::MethodCall(ref path, _, ref args, _) = expr.kind;
@@ -54,8 +55,8 @@ fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr<'_>) {
 
             // Argument 0 (the struct we're calling the method on) is a vector
             if let Some(struct_calling_on) = args.get(0);
-            let struct_ty = cx.tables.expr_ty(struct_calling_on);
-            if is_type_diagnostic_item(cx, struct_ty, sym!(vec_type));
+            let struct_ty = cx.typeck_results().expr_ty(struct_calling_on);
+            if is_type_diagnostic_item(cx, struct_ty, sym::vec_type);
 
             // Argument to "get" is a subtraction
             if let Some(get_index_arg) = args.get(1);