]> git.lizzy.rs Git - rust.git/commitdiff
Change suggestion to `create_dir_all({})` from `std::fs::create_dir_all({})`
authorHirochika Matsumoto <matsujika@gmail.com>
Tue, 8 Sep 2020 14:35:19 +0000 (23:35 +0900)
committerHirochika Matsumoto <matsujika@gmail.com>
Tue, 8 Sep 2020 14:35:19 +0000 (23:35 +0900)
clippy_lints/src/create_dir.rs
tests/ui/create_dir.fixed
tests/ui/create_dir.rs
tests/ui/create_dir.stderr

index f80a0efa7a554af57789923fd632a606e63e83d1..4002fb655a5ebe18d99bed1c4933ed0d74992527 100644 (file)
@@ -42,7 +42,7 @@ fn check_expr(&mut self, cx: &LateContext<'_>, expr: &Expr<'_>) {
                     expr.span,
                     "calling `std::fs::create_dir` where there may be a better way",
                     "consider calling `std::fs::create_dir_all` instead",
-                    format!("std::fs::create_dir_all({})", snippet(cx, args[0].span, "..")),
+                    format!("create_dir_all({})", snippet(cx, args[0].span, "..")),
                     Applicability::MaybeIncorrect,
                 )
             }
index 0e28f87e33d4f8e81733765ce8c9f12239dff14a..8ed53a56ac043357ed4ad192d344eab357d99753 100644 (file)
@@ -2,12 +2,14 @@
 #![allow(unused_must_use)]
 #![warn(clippy::create_dir)]
 
+use std::fs::create_dir_all;
+
 fn create_dir() {}
 
 fn main() {
     // Should be warned
-    std::fs::create_dir_all("foo");
-    std::fs::create_dir_all("bar").unwrap();
+    create_dir_all("foo");
+    create_dir_all("bar").unwrap();
 
     // Shouldn't be warned
     create_dir();
index 1f226298c0d0d9c7da38f29f4779f3b9c63532bb..19c8fc24ba23fa26ff0ba6cf1419c26b70cb2d9d 100644 (file)
@@ -2,6 +2,8 @@
 #![allow(unused_must_use)]
 #![warn(clippy::create_dir)]
 
+use std::fs::create_dir_all;
+
 fn create_dir() {}
 
 fn main() {
index 0c97bdd0f7aba3fb232f5943f94239a696f62c7f..67298fc47095c98144b7994fce1fc058ebed0cb6 100644 (file)
@@ -1,16 +1,16 @@
 error: calling `std::fs::create_dir` where there may be a better way
-  --> $DIR/create_dir.rs:9:5
+  --> $DIR/create_dir.rs:11:5
    |
 LL |     std::fs::create_dir("foo");
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `std::fs::create_dir_all` instead: `std::fs::create_dir_all("foo")`
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `std::fs::create_dir_all` instead: `create_dir_all("foo")`
    |
    = note: `-D clippy::create-dir` implied by `-D warnings`
 
 error: calling `std::fs::create_dir` where there may be a better way
-  --> $DIR/create_dir.rs:10:5
+  --> $DIR/create_dir.rs:12:5
    |
 LL |     std::fs::create_dir("bar").unwrap();
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `std::fs::create_dir_all` instead: `std::fs::create_dir_all("bar")`
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `std::fs::create_dir_all` instead: `create_dir_all("bar")`
 
 error: aborting due to 2 previous errors