Skip to content

Commit acd75d1

Browse files
committed
style: format sources with the 2024 Style Edition
1 parent a0efc08 commit acd75d1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+306
-204
lines changed

download/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -327,8 +327,8 @@ pub mod reqwest_be {
327327
use std::sync::LazyLock;
328328
use std::time::Duration;
329329

330-
use anyhow::{anyhow, Context, Result};
331-
use reqwest::{header, Client, ClientBuilder, Proxy, Response};
330+
use anyhow::{Context, Result, anyhow};
331+
use reqwest::{Client, ClientBuilder, Proxy, Response, header};
332332
#[cfg(feature = "reqwest-rustls-tls")]
333333
use rustls::crypto::aws_lc_rs;
334334
#[cfg(feature = "reqwest-rustls-tls")]

download/tests/download-curl-resume.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#![cfg(feature = "curl-backend")]
22

3-
use std::sync::atomic::{AtomicBool, Ordering};
43
use std::sync::Mutex;
4+
use std::sync::atomic::{AtomicBool, Ordering};
55

66
use url::Url;
77

download/tests/download-reqwest-resume.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#![cfg(any(feature = "reqwest-rustls-tls", feature = "reqwest-native-tls"))]
22

3-
use std::sync::atomic::{AtomicBool, Ordering};
43
use std::sync::Mutex;
4+
use std::sync::atomic::{AtomicBool, Ordering};
55

66
use url::Url;
77

download/tests/read-proxy-env.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
use std::env::{remove_var, set_var};
44
use std::error::Error;
55
use std::net::TcpListener;
6-
use std::sync::atomic::{AtomicUsize, Ordering};
76
use std::sync::LazyLock;
7+
use std::sync::atomic::{AtomicUsize, Ordering};
88
use std::thread;
99
use std::time::Duration;
1010

download/tests/support/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ use std::fs;
33
use std::io;
44
use std::net::SocketAddr;
55
use std::path::Path;
6-
use std::sync::mpsc::{channel, Sender};
6+
use std::sync::mpsc::{Sender, channel};
77
use std::thread;
88

99
use http_body_util::Full;
10+
use hyper::Request;
1011
use hyper::body::Bytes;
1112
use hyper::server::conn::http1;
1213
use hyper::service::service_fn;
13-
use hyper::Request;
1414
use tempfile::TempDir;
1515

1616
pub fn tmp_dir() -> TempDir {

rustfmt.toml

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
style_edition = "2024"

src/bin/rustup-init.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@
1515

1616
use std::process::ExitCode;
1717

18-
use anyhow::{anyhow, Context, Result};
18+
use anyhow::{Context, Result, anyhow};
1919
use cfg_if::cfg_if;
2020
// Public macros require availability of the internal symbols
2121
use rs_tracing::{
2222
close_trace_file, close_trace_file_internal, open_trace_file, trace_to_file_internal,
2323
};
24-
use tracing_subscriber::{reload::Handle, EnvFilter, Registry};
24+
use tracing_subscriber::{EnvFilter, Registry, reload::Handle};
2525

2626
use rustup::cli::common;
2727
use rustup::cli::proxy_mode;
@@ -145,7 +145,7 @@ fn do_recursion_guard(process: &Process) -> Result<()> {
145145
#[cfg(windows)]
146146
pub fn pre_rustup_main_init() {
147147
use windows_sys::Win32::System::LibraryLoader::{
148-
SetDefaultDllDirectories, LOAD_LIBRARY_SEARCH_SYSTEM32,
148+
LOAD_LIBRARY_SEARCH_SYSTEM32, SetDefaultDllDirectories,
149149
};
150150
// Default to loading delay loaded DLLs from the system directory.
151151
// For DLLs loaded at load time, this relies on the `delayload` linker flag.

src/cli/common.rs

+7-5
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,22 @@ use std::path::{Path, PathBuf};
1010
use std::sync::{Arc, LazyLock, Mutex};
1111
use std::{cmp, env};
1212

13-
use anyhow::{anyhow, Context, Result};
13+
use anyhow::{Context, Result, anyhow};
1414
use git_testament::{git_testament, render_testament};
1515
use tracing::{debug, error, info, trace, warn};
16-
use tracing_subscriber::{reload::Handle, EnvFilter, Registry};
16+
use tracing_subscriber::{EnvFilter, Registry, reload::Handle};
1717

1818
use super::self_update;
1919
use crate::{
2020
cli::download_tracker::DownloadTracker,
2121
config::Cfg,
2222
dist::{
23-
manifest::ComponentStatus, notifications as dist_notifications, TargetTriple, ToolchainDesc,
23+
TargetTriple, ToolchainDesc, manifest::ComponentStatus, notifications as dist_notifications,
2424
},
2525
errors::RustupError,
2626
install::UpdateStatus,
2727
notifications::Notification,
28-
process::{terminalsource, Process},
28+
process::{Process, terminalsource},
2929
toolchain::{DistributableToolchain, LocalToolchainName, Toolchain, ToolchainName},
3030
utils::{self, notifications as util_notifications, notify::NotificationLevel},
3131
};
@@ -654,7 +654,9 @@ pub(crate) fn warn_if_host_is_emulated(process: &Process) {
654654
"Rustup is not running natively. It's running under emulation of {}.",
655655
TargetTriple::from_host_or_build(process)
656656
);
657-
warn!("For best compatibility and performance you should reinstall rustup for your native CPU.");
657+
warn!(
658+
"For best compatibility and performance you should reinstall rustup for your native CPU."
659+
);
658660
}
659661
}
660662

src/cli/download_tracker.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ use std::time::{Duration, Instant};
55

66
use crate::dist::Notification as In;
77
use crate::notifications::Notification;
8-
use crate::process::{terminalsource, Process};
9-
use crate::utils::units::{Size, Unit, UnitMode};
8+
use crate::process::{Process, terminalsource};
109
use crate::utils::Notification as Un;
10+
use crate::utils::units::{Size, Unit, UnitMode};
1111

1212
/// Keep track of this many past download amounts
1313
const DOWNLOAD_TRACK_COUNT: usize = 5;

src/cli/help.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -278,8 +278,7 @@ pub(crate) static COMPLETIONS_HELP: &str = r"Discussion:
278278
279279
$ rustup completions zsh cargo > ~/.zfunc/_cargo";
280280

281-
pub(crate) static OFFICIAL_TOOLCHAIN_ARG_HELP: &str =
282-
"Toolchain name, such as 'stable', 'nightly', \
281+
pub(crate) static OFFICIAL_TOOLCHAIN_ARG_HELP: &str = "Toolchain name, such as 'stable', 'nightly', \
283282
or '1.8.0'. For more information see `rustup \
284283
help toolchain`";
285284
pub(crate) static RESOLVABLE_LOCAL_TOOLCHAIN_ARG_HELP: &str = "Toolchain name, such as 'stable', 'nightly', \

src/cli/log.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,16 @@ use std::{fmt, io::Write};
33
#[cfg(feature = "otel")]
44
use opentelemetry_sdk::trace::Tracer;
55
use termcolor::{Color, ColorSpec, WriteColor};
6-
use tracing::{level_filters::LevelFilter, Event, Subscriber};
6+
use tracing::{Event, Subscriber, level_filters::LevelFilter};
77
use tracing_subscriber::{
8+
EnvFilter, Layer, Registry,
89
fmt::{
9-
format::{self, FormatEvent, FormatFields},
1010
FmtContext,
11+
format::{self, FormatEvent, FormatFields},
1112
},
1213
layer::SubscriberExt,
1314
registry::LookupSpan,
14-
reload, EnvFilter, Layer, Registry,
15+
reload,
1516
};
1617

1718
use crate::{process::Process, utils::notify::NotificationLevel};
@@ -152,12 +153,12 @@ where
152153
fn telemetry_default_tracer() -> Tracer {
153154
use std::time::Duration;
154155

155-
use opentelemetry::{global, trace::TracerProvider as _, KeyValue};
156+
use opentelemetry::{KeyValue, global, trace::TracerProvider as _};
156157
use opentelemetry_otlp::WithExportConfig;
157158
use opentelemetry_sdk::{
159+
Resource,
158160
runtime::Tokio,
159161
trace::{Sampler, TracerProvider},
160-
Resource,
161162
};
162163

163164
let exporter = opentelemetry_otlp::SpanExporter::builder()

src/cli/rustup_mode.rs

+94-32
Original file line numberDiff line numberDiff line change
@@ -6,32 +6,32 @@ use std::path::{Path, PathBuf};
66
use std::process::ExitStatus;
77
use std::str::FromStr;
88

9-
use anyhow::{anyhow, Context, Error, Result};
10-
use clap::{builder::PossibleValue, Args, CommandFactory, Parser, Subcommand, ValueEnum};
9+
use anyhow::{Context, Error, Result, anyhow};
10+
use clap::{Args, CommandFactory, Parser, Subcommand, ValueEnum, builder::PossibleValue};
1111
use clap_complete::Shell;
1212
use itertools::Itertools;
1313
use tracing::{info, trace, warn};
14-
use tracing_subscriber::{reload::Handle, EnvFilter, Registry};
14+
use tracing_subscriber::{EnvFilter, Registry, reload::Handle};
1515

1616
use crate::{
1717
cli::{
18-
common::{self, update_console_filter, PackageUpdate},
18+
common::{self, PackageUpdate, update_console_filter},
1919
errors::CLIError,
2020
help::*,
21-
self_update::{self, check_rustup_update, SelfUpdateMode},
21+
self_update::{self, SelfUpdateMode, check_rustup_update},
2222
topical_doc,
2323
},
2424
command,
2525
config::{ActiveReason, Cfg},
2626
dist::{
27-
manifest::{Component, ComponentStatus},
2827
PartialToolchainDesc, Profile, TargetTriple,
28+
manifest::{Component, ComponentStatus},
2929
},
3030
errors::RustupError,
3131
install::{InstallMethod, UpdateStatus},
3232
process::{
33-
terminalsource::{self, ColorableTerminal},
3433
Process,
34+
terminalsource::{self, ColorableTerminal},
3535
},
3636
toolchain::{
3737
CustomToolchainName, DistributableToolchain, LocalToolchainName,
@@ -41,8 +41,7 @@ use crate::{
4141
utils::{self, ExitCode},
4242
};
4343

44-
const TOOLCHAIN_OVERRIDE_ERROR: &str =
45-
"To override the toolchain using the 'rustup +toolchain' syntax, \
44+
const TOOLCHAIN_OVERRIDE_ERROR: &str = "To override the toolchain using the 'rustup +toolchain' syntax, \
4645
make sure to prefix the toolchain override with a '+'";
4746

4847
fn handle_epipe(res: Result<utils::ExitCode>) -> Result<utils::ExitCode> {
@@ -90,12 +89,17 @@ struct Rustup {
9089
}
9190

9291
fn plus_toolchain_value_parser(s: &str) -> clap::error::Result<ResolvableToolchainName> {
93-
use clap::{error::ErrorKind, Error};
92+
use clap::{Error, error::ErrorKind};
9493
if let Some(stripped) = s.strip_prefix('+') {
9594
ResolvableToolchainName::try_from(stripped)
9695
.map_err(|e| Error::raw(ErrorKind::InvalidValue, e))
9796
} else {
98-
Err(Error::raw(ErrorKind::InvalidSubcommand, format!("\"{s}\" is not a valid subcommand, so it was interpreted as a toolchain name, but it is also invalid. {TOOLCHAIN_OVERRIDE_ERROR}")))
97+
Err(Error::raw(
98+
ErrorKind::InvalidSubcommand,
99+
format!(
100+
"\"{s}\" is not a valid subcommand, so it was interpreted as a toolchain name, but it is also invalid. {TOOLCHAIN_OVERRIDE_ERROR}"
101+
),
102+
))
99103
}
100104
}
101105

@@ -1191,7 +1195,9 @@ async fn target_remove(
11911195
let target = TargetTriple::new(target);
11921196
let default_target = cfg.get_default_host_triple()?;
11931197
if target == default_target {
1194-
warn!("removing the default host target; proc-macros and build scripts might no longer build");
1198+
warn!(
1199+
"removing the default host target; proc-macros and build scripts might no longer build"
1200+
);
11951201
}
11961202
// Whether we have at most 1 component target that is not `None` (wildcard).
11971203
let has_at_most_one_target = distributable
@@ -1316,13 +1322,17 @@ fn toolchain_remove(cfg: &mut Cfg<'_>, opts: UninstallOpts) -> Result<utils::Exi
13161322
.as_ref()
13171323
.is_some_and(|n| n == &toolchain_name)
13181324
{
1319-
warn!("removing the active toolchain; a toolchain override will be required for running Rust tools");
1325+
warn!(
1326+
"removing the active toolchain; a toolchain override will be required for running Rust tools"
1327+
);
13201328
}
13211329
if default_toolchain
13221330
.as_ref()
13231331
.is_some_and(|n| n == &toolchain_name)
13241332
{
1325-
warn!("removing the default toolchain; proc-macros and build scripts might no longer build");
1333+
warn!(
1334+
"removing the default toolchain; proc-macros and build scripts might no longer build"
1335+
);
13261336
}
13271337

13281338
Toolchain::ensure_removed(cfg, (&toolchain_name).into())?;
@@ -1433,28 +1443,77 @@ macro_rules! docs_data {
14331443
docs_data![
14341444
// flags can be used to open specific documents, e.g. `rustup doc --nomicon`
14351445
// tuple elements: document name used as flag, help message, document index path
1436-
(alloc, "The Rust core allocation and collections library", "alloc/index.html"),
1437-
(book, "The Rust Programming Language book", "book/index.html"),
1446+
(
1447+
alloc,
1448+
"The Rust core allocation and collections library",
1449+
"alloc/index.html"
1450+
),
1451+
(
1452+
book,
1453+
"The Rust Programming Language book",
1454+
"book/index.html"
1455+
),
14381456
(cargo, "The Cargo Book", "cargo/index.html"),
14391457
(clippy, "The Clippy Documentation", "clippy/index.html"),
14401458
(core, "The Rust Core Library", "core/index.html"),
1441-
(edition_guide, "The Rust Edition Guide", "edition-guide/index.html"),
1442-
(embedded_book, "The Embedded Rust Book", "embedded-book/index.html"),
1443-
(error_codes, "The Rust Error Codes Index", "error_codes/index.html"),
1444-
1445-
(nomicon, "The Dark Arts of Advanced and Unsafe Rust Programming", "nomicon/index.html"),
1446-
1459+
(
1460+
edition_guide,
1461+
"The Rust Edition Guide",
1462+
"edition-guide/index.html"
1463+
),
1464+
(
1465+
embedded_book,
1466+
"The Embedded Rust Book",
1467+
"embedded-book/index.html"
1468+
),
1469+
(
1470+
error_codes,
1471+
"The Rust Error Codes Index",
1472+
"error_codes/index.html"
1473+
),
1474+
(
1475+
nomicon,
1476+
"The Dark Arts of Advanced and Unsafe Rust Programming",
1477+
"nomicon/index.html"
1478+
),
14471479
#[arg(long = "proc_macro")]
1448-
(proc_macro, "A support library for macro authors when defining new macros", "proc_macro/index.html"),
1449-
1480+
(
1481+
proc_macro,
1482+
"A support library for macro authors when defining new macros",
1483+
"proc_macro/index.html"
1484+
),
14501485
(reference, "The Rust Reference", "reference/index.html"),
1451-
(rust_by_example, "A collection of runnable examples that illustrate various Rust concepts and standard libraries", "rust-by-example/index.html"),
1452-
(rustc, "The compiler for the Rust programming language", "rustc/index.html"),
1453-
(rustdoc, "Documentation generator for Rust projects", "rustdoc/index.html"),
1486+
(
1487+
rust_by_example,
1488+
"A collection of runnable examples that illustrate various Rust concepts and standard libraries",
1489+
"rust-by-example/index.html"
1490+
),
1491+
(
1492+
rustc,
1493+
"The compiler for the Rust programming language",
1494+
"rustc/index.html"
1495+
),
1496+
(
1497+
rustdoc,
1498+
"Documentation generator for Rust projects",
1499+
"rustdoc/index.html"
1500+
),
14541501
(std, "Standard library API documentation", "std/index.html"),
1455-
(style_guide, "The Rust Style Guide", "style-guide/index.html"),
1456-
(test, "Support code for rustc's built in unit-test and micro-benchmarking framework", "test/index.html"),
1457-
(unstable_book, "The Unstable Book", "unstable-book/index.html"),
1502+
(
1503+
style_guide,
1504+
"The Rust Style Guide",
1505+
"style-guide/index.html"
1506+
),
1507+
(
1508+
test,
1509+
"Support code for rustc's built in unit-test and micro-benchmarking framework",
1510+
"test/index.html"
1511+
),
1512+
(
1513+
unstable_book,
1514+
"The Unstable Book",
1515+
"unstable-book/index.html"
1516+
),
14581517
];
14591518

14601519
impl DocPage {
@@ -1594,7 +1653,10 @@ fn set_auto_self_update(
15941653
.as_ref()
15951654
.and_then(|a| a.to_str())
15961655
.ok_or(CLIError::NoExeName)?;
1597-
warn!("{} is built with the no-self-update feature: setting auto-self-update will not have any effect.",arg0);
1656+
warn!(
1657+
"{} is built with the no-self-update feature: setting auto-self-update will not have any effect.",
1658+
arg0
1659+
);
15981660
}
15991661
cfg.set_auto_self_update(auto_self_update_mode)?;
16001662
Ok(utils::ExitCode(0))
@@ -1655,7 +1717,7 @@ fn output_completion_script(
16551717
"{} does not currently support completions for {}",
16561718
command,
16571719
shell
1658-
))
1720+
));
16591721
}
16601722
};
16611723

0 commit comments

Comments
 (0)