Skip to content

Commit a899ad2

Browse files
committed
Change suggestion to create_dir_all({}) from std::fs::create_dir_all({})
1 parent 451ef78 commit a899ad2

File tree

4 files changed

+11
-7
lines changed

4 files changed

+11
-7
lines changed

clippy_lints/src/create_dir.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ impl LateLintPass<'_> for CreateDir {
4242
expr.span,
4343
"calling `std::fs::create_dir` where there may be a better way",
4444
"consider calling `std::fs::create_dir_all` instead",
45-
format!("std::fs::create_dir_all({})", snippet(cx, args[0].span, "..")),
45+
format!("create_dir_all({})", snippet(cx, args[0].span, "..")),
4646
Applicability::MaybeIncorrect,
4747
)
4848
}

tests/ui/create_dir.fixed

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
22
#![allow(unused_must_use)]
33
#![warn(clippy::create_dir)]
44

5+
use std::fs::create_dir_all;
6+
57
fn create_dir() {}
68

79
fn main() {
810
// Should be warned
9-
std::fs::create_dir_all("foo");
10-
std::fs::create_dir_all("bar").unwrap();
11+
create_dir_all("foo");
12+
create_dir_all("bar").unwrap();
1113

1214
// Shouldn't be warned
1315
create_dir();

tests/ui/create_dir.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
#![allow(unused_must_use)]
33
#![warn(clippy::create_dir)]
44

5+
use std::fs::create_dir_all;
6+
57
fn create_dir() {}
68

79
fn main() {

tests/ui/create_dir.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
error: calling `std::fs::create_dir` where there may be a better way
2-
--> $DIR/create_dir.rs:9:5
2+
--> $DIR/create_dir.rs:11:5
33
|
44
LL | std::fs::create_dir("foo");
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `std::fs::create_dir_all` instead: `std::fs::create_dir_all("foo")`
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `std::fs::create_dir_all` instead: `create_dir_all("foo")`
66
|
77
= note: `-D clippy::create-dir` implied by `-D warnings`
88

99
error: calling `std::fs::create_dir` where there may be a better way
10-
--> $DIR/create_dir.rs:10:5
10+
--> $DIR/create_dir.rs:12:5
1111
|
1212
LL | std::fs::create_dir("bar").unwrap();
13-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `std::fs::create_dir_all` instead: `std::fs::create_dir_all("bar")`
13+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `std::fs::create_dir_all` instead: `create_dir_all("bar")`
1414

1515
error: aborting due to 2 previous errors
1616

0 commit comments

Comments
 (0)