Skip to content

Commit 7ba0abf

Browse files
ChrisDentonrami3l
authored andcommitted
Fix cargo lints on Windows
Produced by running: cargo clippy --fix --all-targets --all-features
1 parent a92432f commit 7ba0abf

File tree

11 files changed

+50
-70
lines changed

11 files changed

+50
-70
lines changed

src/cli/rustup_mode.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1053,7 +1053,7 @@ async fn show(cfg: &Cfg<'_>, verbose: bool) -> Result<utils::ExitCode> {
10531053
&active_reason,
10541054
)?;
10551055
writeln!(t.lock(), "name: {}", active_toolchain.name())?;
1056-
writeln!(t.lock(), "active because: {}", active_reason)?;
1056+
writeln!(t.lock(), "active because: {active_reason}")?;
10571057
if verbose {
10581058
writeln!(t.lock(), "compiler: {}", active_toolchain.rustc_version())?;
10591059
writeln!(t.lock(), "path: {}", active_toolchain.path().display())?;
@@ -1063,7 +1063,7 @@ async fn show(cfg: &Cfg<'_>, verbose: bool) -> Result<utils::ExitCode> {
10631063
writeln!(t.lock(), "installed targets:")?;
10641064

10651065
for target in active_toolchain_targets {
1066-
writeln!(t.lock(), " {}", target)?;
1066+
writeln!(t.lock(), " {target}")?;
10671067
}
10681068
}
10691069
None => {

src/command.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,7 @@ pub(crate) fn run_command_for_dir<S: AsRef<OsStr> + Debug>(
4444
}
4545
unsafe {
4646
if SetConsoleCtrlHandler(Some(ctrlc_handler), TRUE) == FALSE {
47-
return Err(io::Error::new(
48-
io::ErrorKind::Other,
49-
"Unable to set console handler",
50-
));
47+
return Err(io::Error::other("Unable to set console handler"));
5148
}
5249
}
5350

src/download/tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ async fn run_server(addr_tx: Sender<SocketAddr>, addr: SocketAddr, contents: Vec
308308
let svc = svc.clone();
309309
tokio::spawn(async move {
310310
if let Err(err) = http1::Builder::new().serve_connection(io, svc).await {
311-
eprintln!("failed to serve connection: {:?}", err);
311+
eprintln!("failed to serve connection: {err:?}");
312312
}
313313
});
314314
}

src/errors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ pub enum RustupError {
153153

154154
fn suggest_message(suggestion: &Option<String>) -> String {
155155
if let Some(suggestion) = suggestion {
156-
format!("; did you mean '{}'?", suggestion)
156+
format!("; did you mean '{suggestion}'?")
157157
} else {
158158
String::new()
159159
}

src/test/clitools.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,9 +322,9 @@ impl Config {
322322
let status = out.status;
323323
let output = SanitizedOutput::try_from(out).unwrap();
324324

325-
println!("ran: {} {:?}", name, args);
325+
println!("ran: {name} {args:?}");
326326
println!("inprocess: {inprocess}");
327-
println!("status: {:?}", status);
327+
println!("status: {status:?}");
328328
println!("duration: {:.3}s", duration.as_secs_f32());
329329
println!("stdout:\n====\n{}\n====\n", output.stdout);
330330
println!("stderr:\n====\n{}\n====\n", output.stderr);

src/utils/raw.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ pub(crate) mod windows {
284284
pub(crate) fn to_u16s<S: AsRef<OsStr>>(s: S) -> io::Result<Vec<u16>> {
285285
fn inner(s: &OsStr) -> io::Result<Vec<u16>> {
286286
let mut maybe_result: Vec<u16> = s.encode_wide().collect();
287-
if maybe_result.iter().any(|&u| u == 0) {
287+
if maybe_result.contains(&0) {
288288
return Err(io::Error::new(
289289
io::ErrorKind::InvalidInput,
290290
"strings passed to WinAPI cannot contain NULs",

tests/suite/cli_exact.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,7 @@ async fn list_targets() {
609609
let trip = this_host_triple();
610610
let mut sorted = [
611611
format!("{} (installed)", &*trip),
612-
format!("{} (installed)", CROSS_ARCH1),
612+
format!("{CROSS_ARCH1} (installed)"),
613613
CROSS_ARCH2.to_string(),
614614
];
615615
sorted.sort();
@@ -674,10 +674,9 @@ async fn cross_install_indicates_target() {
674674
&["rustup", "target", "add", CROSS_ARCH1],
675675
r"",
676676
&format!(
677-
r"info: downloading component 'rust-std' for '{0}'
678-
info: installing component 'rust-std' for '{0}'
679-
",
680-
CROSS_ARCH1
677+
r"info: downloading component 'rust-std' for '{CROSS_ARCH1}'
678+
info: installing component 'rust-std' for '{CROSS_ARCH1}'
679+
"
681680
),
682681
)
683682
.await;

tests/suite/cli_misc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ async fn multi_host_smoke_test() {
207207
assert_ne!(this_host_triple(), MULTI_ARCH1);
208208

209209
let mut cx = CliTestContext::new(Scenario::MultiHost).await;
210-
let toolchain = format!("nightly-{}", MULTI_ARCH1);
210+
let toolchain = format!("nightly-{MULTI_ARCH1}");
211211
cx.config
212212
.expect_ok(&["rustup", "default", &toolchain, "--force-non-host"])
213213
.await;

tests/suite/cli_rustup.rs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,7 @@ async fn recursive_cargo() {
578578
let output = cx.config.run("rustup", ["which", "cargo"], &[]).await;
579579
let real_mock_cargo = output.stdout.trim();
580580
let cargo_bin_path = cx.config.cargodir.join("bin");
581-
let cargo_subcommand = cargo_bin_path.join(format!("cargo-foo{}", EXE_SUFFIX));
581+
let cargo_subcommand = cargo_bin_path.join(format!("cargo-foo{EXE_SUFFIX}"));
582582
fs::create_dir_all(&cargo_bin_path).unwrap();
583583
fs::copy(real_mock_cargo, cargo_subcommand).unwrap();
584584

@@ -736,7 +736,7 @@ async fn show_multiple_targets() {
736736
.expect_ok(&[
737737
"rustup",
738738
"default",
739-
&format!("nightly-{}", MULTI_ARCH1),
739+
&format!("nightly-{MULTI_ARCH1}"),
740740
"--force-non-host",
741741
])
742742
.await;
@@ -783,7 +783,7 @@ async fn show_multiple_toolchains_and_targets() {
783783
.expect_ok(&[
784784
"rustup",
785785
"default",
786-
&format!("nightly-{}", MULTI_ARCH1),
786+
&format!("nightly-{MULTI_ARCH1}"),
787787
"--force-non-host",
788788
])
789789
.await;
@@ -795,7 +795,7 @@ async fn show_multiple_toolchains_and_targets() {
795795
"rustup",
796796
"update",
797797
"--force-non-host",
798-
&format!("stable-{}", MULTI_ARCH1),
798+
&format!("stable-{MULTI_ARCH1}"),
799799
])
800800
.await;
801801
cx.config
@@ -1542,7 +1542,7 @@ async fn add_component_by_target_triple() {
15421542
"rustup",
15431543
"component",
15441544
"add",
1545-
&format!("rust-std-{}", CROSS_ARCH1),
1545+
&format!("rust-std-{CROSS_ARCH1}"),
15461546
])
15471547
.await;
15481548
let path = format!(
@@ -1595,7 +1595,7 @@ async fn fail_invalid_component_name() {
15951595
"rustup",
15961596
"component",
15971597
"add",
1598-
&format!("dummy-{}", CROSS_ARCH1),
1598+
&format!("dummy-{CROSS_ARCH1}"),
15991599
],
16001600
&format!(
16011601
"error: toolchain 'stable-{}' does not contain component 'dummy-{}' for target '{}'",
@@ -1642,7 +1642,7 @@ async fn remove_component() {
16421642

16431643
#[tokio::test]
16441644
async fn remove_component_by_target_triple() {
1645-
let component_with_triple = format!("rust-std-{}", CROSS_ARCH1);
1645+
let component_with_triple = format!("rust-std-{CROSS_ARCH1}");
16461646
let mut cx = CliTestContext::new(Scenario::SimpleV2).await;
16471647
cx.config.expect_ok(&["rustup", "default", "stable"]).await;
16481648
cx.config
@@ -1665,11 +1665,11 @@ async fn add_remove_multiple_components() {
16651665
let files = [
16661666
"lib/rustlib/src/rust-src/foo.rs".to_owned(),
16671667
format!("lib/rustlib/{}/analysis/libfoo.json", this_host_triple()),
1668-
format!("lib/rustlib/{}/lib/libstd.rlib", CROSS_ARCH1),
1669-
format!("lib/rustlib/{}/lib/libstd.rlib", CROSS_ARCH2),
1668+
format!("lib/rustlib/{CROSS_ARCH1}/lib/libstd.rlib"),
1669+
format!("lib/rustlib/{CROSS_ARCH2}/lib/libstd.rlib"),
16701670
];
1671-
let component_with_triple1 = format!("rust-std-{}", CROSS_ARCH1);
1672-
let component_with_triple2 = format!("rust-std-{}", CROSS_ARCH2);
1671+
let component_with_triple1 = format!("rust-std-{CROSS_ARCH1}");
1672+
let component_with_triple2 = format!("rust-std-{CROSS_ARCH2}");
16731673

16741674
let mut cx = CliTestContext::new(Scenario::SimpleV2).await;
16751675
cx.config.expect_ok(&["rustup", "default", "nightly"]).await;
@@ -2358,11 +2358,11 @@ async fn override_order() {
23582358
let mut cx = CliTestContext::new(Scenario::ArchivesV2).await;
23592359
let host = this_host_triple();
23602360
// give each override type a different toolchain
2361-
let default_tc = &format!("beta-2015-01-01-{}", host);
2362-
let env_tc = &format!("stable-2015-01-01-{}", host);
2363-
let dir_tc = &format!("beta-2015-01-02-{}", host);
2364-
let file_tc = &format!("stable-2015-01-02-{}", host);
2365-
let command_tc = &format!("nightly-2015-01-01-{}", host);
2361+
let default_tc = &format!("beta-2015-01-01-{host}");
2362+
let env_tc = &format!("stable-2015-01-01-{host}");
2363+
let dir_tc = &format!("beta-2015-01-02-{host}");
2364+
let file_tc = &format!("stable-2015-01-02-{host}");
2365+
let command_tc = &format!("nightly-2015-01-01-{host}");
23662366
cx.config
23672367
.expect_ok(&["rustup", "install", default_tc])
23682368
.await;
@@ -2395,7 +2395,7 @@ async fn override_order() {
23952395
let toolchain_file = cx.config.current_dir().join("rust-toolchain.toml");
23962396
raw::write_file(
23972397
&toolchain_file,
2398-
&format!("[toolchain]\nchannel='{}'", file_tc),
2398+
&format!("[toolchain]\nchannel='{file_tc}'"),
23992399
)
24002400
.unwrap();
24012401
cx.config
@@ -2427,7 +2427,7 @@ async fn override_order() {
24272427
.config
24282428
.run(
24292429
"rustup",
2430-
[&format!("+{}", command_tc), "show", "active-toolchain"],
2430+
[&format!("+{command_tc}"), "show", "active-toolchain"],
24312431
&[("RUSTUP_TOOLCHAIN", env_tc)],
24322432
)
24332433
.await;

tests/suite/cli_self_upd.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -994,7 +994,7 @@ async fn install_with_components_and_targets() {
994994
cx.config
995995
.expect_stdout_ok(
996996
&["rustup", "target", "list"],
997-
&format!("{} (installed)", CROSS_ARCH1),
997+
&format!("{CROSS_ARCH1} (installed)"),
998998
)
999999
.await;
10001000
cx.config

0 commit comments

Comments
 (0)