]> git.lizzy.rs Git - rust.git/blobdiff - src/tools/clippy/clippy_lints/src/slow_vector_initialization.rs
Rollup merge of #85760 - ChrisDenton:path-doc-platform-specific, r=m-ou-se
[rust.git] / src / tools / clippy / clippy_lints / src / slow_vector_initialization.rs
index 191781be000cf8177919236a38389dafac24c3df..e5c58d70b603e60318b90fb45bc65a20add965bf 100644 (file)
@@ -7,7 +7,7 @@
 use rustc_errors::Applicability;
 use rustc_hir::intravisit::{walk_block, walk_expr, walk_stmt, NestedVisitorMap, Visitor};
 use rustc_hir::{BindingAnnotation, Block, Expr, ExprKind, HirId, PatKind, QPath, Stmt, StmtKind};
-use rustc_lint::{LateContext, LateLintPass, Lint};
+use rustc_lint::{LateContext, LateLintPass};
 use rustc_middle::hir::map::Map;
 use rustc_session::{declare_lint_pass, declare_tool_lint};
 use rustc_span::symbol::sym;
@@ -157,26 +157,16 @@ fn lint_initialization<'tcx>(
         vec_alloc: &VecAllocation<'_>,
     ) {
         match initialization {
-            InitializationType::Extend(e) | InitializationType::Resize(e) => Self::emit_lint(
-                cx,
-                e,
-                vec_alloc,
-                "slow zero-filling initialization",
-                SLOW_VECTOR_INITIALIZATION,
-            ),
+            InitializationType::Extend(e) | InitializationType::Resize(e) => {
+                Self::emit_lint(cx, e, vec_alloc, "slow zero-filling initialization");
+            },
         };
     }
 
-    fn emit_lint<'tcx>(
-        cx: &LateContext<'tcx>,
-        slow_fill: &Expr<'_>,
-        vec_alloc: &VecAllocation<'_>,
-        msg: &str,
-        lint: &'static Lint,
-    ) {
+    fn emit_lint<'tcx>(cx: &LateContext<'tcx>, slow_fill: &Expr<'_>, vec_alloc: &VecAllocation<'_>, msg: &str) {
         let len_expr = Sugg::hir(cx, vec_alloc.len_expr, "len");
 
-        span_lint_and_then(cx, lint, slow_fill.span, msg, |diag| {
+        span_lint_and_then(cx, SLOW_VECTOR_INITIALIZATION, slow_fill.span, msg, |diag| {
             diag.span_suggestion(
                 vec_alloc.allocation_expr.span,
                 "consider replace allocation with",
@@ -300,7 +290,7 @@ fn visit_stmt(&mut self, stmt: &'tcx Stmt<'_>) {
     fn visit_block(&mut self, block: &'tcx Block<'_>) {
         if self.initialization_found {
             if let Some(s) = block.stmts.get(0) {
-                self.visit_stmt(s)
+                self.visit_stmt(s);
             }
 
             self.initialization_found = false;