Skip to content

Commit 0b2b10b

Browse files
committed
Cleanup: Misc.
1 parent a91a12b commit 0b2b10b

File tree

6 files changed

+16
-25
lines changed

6 files changed

+16
-25
lines changed

tests/testsuite/init.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,11 @@ fn simple_bin() {
6161
fn simple_git_ignore_exists() {
6262
// write a .gitignore file with one entry
6363
fs::create_dir_all(paths::root().join("foo")).unwrap();
64-
let mut ignore_file = File::create(paths::root().join("foo/.gitignore")).unwrap();
65-
ignore_file
66-
.write("/target\n**/some.file".as_bytes())
67-
.unwrap();
64+
fs::write(
65+
paths::root().join("foo/.gitignore"),
66+
"/target\n**/some.file",
67+
)
68+
.unwrap();
6869

6970
cargo_process("init --lib foo --edition 2015")
7071
.env("USER", "foo")

tests/testsuite/install.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1343,7 +1343,7 @@ fn install_global_cargo_config() {
13431343
pkg("bar", "0.0.1");
13441344

13451345
let config = cargo_home().join("config");
1346-
let mut toml = fs::read_to_string(&config).unwrap_or(String::new());
1346+
let mut toml = fs::read_to_string(&config).unwrap_or_default();
13471347

13481348
toml.push_str(
13491349
r#"

tests/testsuite/metabuild.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -434,8 +434,7 @@ fn metabuild_metadata() {
434434
.as_array()
435435
.unwrap()
436436
.iter()
437-
.filter(|p| p["name"].as_str().unwrap() == "foo")
438-
.next()
437+
.find(|p| p["name"].as_str().unwrap() == "foo")
439438
.unwrap()["metabuild"]
440439
.as_array()
441440
.unwrap()

tests/testsuite/resolve.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,10 @@ proptest! {
112112
let reg = registry(input.clone());
113113
let mut removed_input = input.clone();
114114
for (summery_idx, dep_idx) in indexes_to_remove {
115-
if removed_input.len() > 0 {
115+
if !removed_input.is_empty() {
116116
let summery_idx = summery_idx.index(removed_input.len());
117117
let deps = removed_input[summery_idx].dependencies();
118-
if deps.len() > 0 {
118+
if !deps.is_empty() {
119119
let new = remove_dep(&removed_input[summery_idx], dep_idx.index(deps.len()));
120120
removed_input[summery_idx] = new;
121121
}

tests/testsuite/support/mod.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1084,10 +1084,7 @@ impl Execs {
10841084

10851085
// On Windows, we need to use a wildcard for the drive,
10861086
// because we don't actually know what it will be.
1087-
let replaced =
1088-
replaced.replace("[ROOT]", if cfg!(windows) { r#"[..]:\"# } else { "/" });
1089-
1090-
replaced
1087+
replaced.replace("[ROOT]", if cfg!(windows) { r#"[..]:\"# } else { "/" })
10911088
}
10921089
None => return Ok(()),
10931090
};

tests/testsuite/tool_paths.rs

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -188,13 +188,11 @@ fn custom_runner_cfg() {
188188

189189
p.cargo("run -- --param")
190190
.with_status(101)
191-
.with_stderr_contains(&format!(
192-
"\
191+
.with_stderr_contains("\
193192
[COMPILING] foo v0.0.1 ([CWD])
194193
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
195194
[RUNNING] `nonexistent-runner -r target/debug/foo[EXE] --param`
196-
",
197-
))
195+
")
198196
.run();
199197
}
200198

@@ -222,13 +220,11 @@ fn custom_runner_cfg_precedence() {
222220

223221
p.cargo("run -- --param")
224222
.with_status(101)
225-
.with_stderr_contains(&format!(
226-
"\
223+
.with_stderr_contains("\
227224
[COMPILING] foo v0.0.1 ([CWD])
228225
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
229226
[RUNNING] `nonexistent-runner -r target/debug/foo[EXE] --param`
230-
",
231-
))
227+
")
232228
.run();
233229
}
234230

@@ -250,10 +246,8 @@ fn custom_runner_cfg_collision() {
250246

251247
p.cargo("run -- --param")
252248
.with_status(101)
253-
.with_stderr_contains(&format!(
254-
"\
249+
.with_stderr_contains("\
255250
[ERROR] several matching instances of `target.'cfg(..)'.runner` in `.cargo/config`
256-
",
257-
))
251+
")
258252
.run();
259253
}

0 commit comments

Comments
 (0)