]> git.lizzy.rs Git - rust.git/blobdiff - clippy_lints/src/vec_init_then_push.rs
modify code
[rust.git] / clippy_lints / src / vec_init_then_push.rs
index 478314c08368ef058745f9a789a6c4fb7a429970..fbf2b3e081b823220e0c1fbc792de34b1daaeba1 100644 (file)
@@ -1,6 +1,7 @@
 use clippy_utils::diagnostics::span_lint_and_sugg;
+use clippy_utils::higher::{get_vec_init_kind, VecInitKind};
 use clippy_utils::source::snippet;
-use clippy_utils::{get_vec_init_kind, path_to_local, path_to_local_id, VecInitKind};
+use clippy_utils::{path_to_local, path_to_local_id};
 use if_chain::if_chain;
 use rustc_errors::Applicability;
 use rustc_hir::{BindingAnnotation, Block, Expr, ExprKind, HirId, Local, PatKind, Stmt, StmtKind};
@@ -26,6 +27,7 @@
     /// ```rust
     /// let v = vec![0];
     /// ```
+    #[clippy::version = "1.51.0"]
     pub VEC_INIT_THEN_PUSH,
     perf,
     "`push` immediately after `Vec` creation"
@@ -75,7 +77,7 @@ fn display_err(&self, cx: &LateContext<'_>) {
     }
 }
 
-impl LateLintPass<'_> for VecInitThenPush {
+impl<'tcx> LateLintPass<'tcx> for VecInitThenPush {
     fn check_block(&mut self, _: &LateContext<'tcx>, _: &'tcx Block<'tcx>) {
         self.searcher = None;
     }
@@ -123,7 +125,7 @@ fn check_stmt(&mut self, cx: &LateContext<'tcx>, stmt: &'tcx Stmt<'_>) {
         if let Some(searcher) = self.searcher.take() {
             if_chain! {
                 if let StmtKind::Expr(expr) | StmtKind::Semi(expr) = stmt.kind;
-                if let ExprKind::MethodCall(path, _, [self_arg, _], _) = expr.kind;
+                if let ExprKind::MethodCall(path, [self_arg, _], _) = expr.kind;
                 if path_to_local_id(self_arg, searcher.local_id);
                 if path.ident.name.as_str() == "push";
                 then {