mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-11 07:34:18 +00:00
Change suggestion to create_dir_all({})
from std::fs::create_dir_all({})
This commit is contained in:
parent
451ef78803
commit
a899ad2e12
4 changed files with 11 additions and 7 deletions
|
@ -42,7 +42,7 @@ impl LateLintPass<'_> for CreateDir {
|
||||||
expr.span,
|
expr.span,
|
||||||
"calling `std::fs::create_dir` where there may be a better way",
|
"calling `std::fs::create_dir` where there may be a better way",
|
||||||
"consider calling `std::fs::create_dir_all` instead",
|
"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,
|
Applicability::MaybeIncorrect,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,12 +2,14 @@
|
||||||
#![allow(unused_must_use)]
|
#![allow(unused_must_use)]
|
||||||
#![warn(clippy::create_dir)]
|
#![warn(clippy::create_dir)]
|
||||||
|
|
||||||
|
use std::fs::create_dir_all;
|
||||||
|
|
||||||
fn create_dir() {}
|
fn create_dir() {}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
// Should be warned
|
// Should be warned
|
||||||
std::fs::create_dir_all("foo");
|
create_dir_all("foo");
|
||||||
std::fs::create_dir_all("bar").unwrap();
|
create_dir_all("bar").unwrap();
|
||||||
|
|
||||||
// Shouldn't be warned
|
// Shouldn't be warned
|
||||||
create_dir();
|
create_dir();
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
#![allow(unused_must_use)]
|
#![allow(unused_must_use)]
|
||||||
#![warn(clippy::create_dir)]
|
#![warn(clippy::create_dir)]
|
||||||
|
|
||||||
|
use std::fs::create_dir_all;
|
||||||
|
|
||||||
fn create_dir() {}
|
fn create_dir() {}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
error: calling `std::fs::create_dir` where there may be a better way
|
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");
|
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`
|
= note: `-D clippy::create-dir` implied by `-D warnings`
|
||||||
|
|
||||||
error: calling `std::fs::create_dir` where there may be a better way
|
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();
|
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
|
error: aborting due to 2 previous errors
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue