Skip to content

style(edition): migrate the codebase to the 2024 Style Edition #4190

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions download/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -327,8 +327,8 @@ pub mod reqwest_be {
use std::sync::LazyLock;
use std::time::Duration;

use anyhow::{anyhow, Context, Result};
use reqwest::{header, Client, ClientBuilder, Proxy, Response};
use anyhow::{Context, Result, anyhow};
use reqwest::{Client, ClientBuilder, Proxy, Response, header};
#[cfg(feature = "reqwest-rustls-tls")]
use rustls::crypto::aws_lc_rs;
#[cfg(feature = "reqwest-rustls-tls")]
Expand Down
2 changes: 1 addition & 1 deletion download/tests/download-curl-resume.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#![cfg(feature = "curl-backend")]

use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Mutex;
use std::sync::atomic::{AtomicBool, Ordering};

use url::Url;

Expand Down
2 changes: 1 addition & 1 deletion download/tests/download-reqwest-resume.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#![cfg(any(feature = "reqwest-rustls-tls", feature = "reqwest-native-tls"))]

use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Mutex;
use std::sync::atomic::{AtomicBool, Ordering};

use url::Url;

Expand Down
2 changes: 1 addition & 1 deletion download/tests/read-proxy-env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
use std::env::{remove_var, set_var};
use std::error::Error;
use std::net::TcpListener;
use std::sync::atomic::{AtomicUsize, Ordering};
use std::sync::LazyLock;
use std::sync::atomic::{AtomicUsize, Ordering};
use std::thread;
use std::time::Duration;

Expand Down
4 changes: 2 additions & 2 deletions download/tests/support/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ use std::fs;
use std::io;
use std::net::SocketAddr;
use std::path::Path;
use std::sync::mpsc::{channel, Sender};
use std::sync::mpsc::{Sender, channel};
use std::thread;

use http_body_util::Full;
use hyper::Request;
use hyper::body::Bytes;
use hyper::server::conn::http1;
use hyper::service::service_fn;
use hyper::Request;
use tempfile::TempDir;

pub fn tmp_dir() -> TempDir {
Expand Down
1 change: 1 addition & 0 deletions rustfmt.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
style_edition = "2024"
6 changes: 3 additions & 3 deletions src/bin/rustup-init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@

use std::process::ExitCode;

use anyhow::{anyhow, Context, Result};
use anyhow::{Context, Result, anyhow};
use cfg_if::cfg_if;
// Public macros require availability of the internal symbols
use rs_tracing::{
close_trace_file, close_trace_file_internal, open_trace_file, trace_to_file_internal,
};
use tracing_subscriber::{reload::Handle, EnvFilter, Registry};
use tracing_subscriber::{EnvFilter, Registry, reload::Handle};

use rustup::cli::common;
use rustup::cli::proxy_mode;
Expand Down Expand Up @@ -145,7 +145,7 @@ fn do_recursion_guard(process: &Process) -> Result<()> {
#[cfg(windows)]
pub fn pre_rustup_main_init() {
use windows_sys::Win32::System::LibraryLoader::{
SetDefaultDllDirectories, LOAD_LIBRARY_SEARCH_SYSTEM32,
LOAD_LIBRARY_SEARCH_SYSTEM32, SetDefaultDllDirectories,
};
// Default to loading delay loaded DLLs from the system directory.
// For DLLs loaded at load time, this relies on the `delayload` linker flag.
Expand Down
12 changes: 7 additions & 5 deletions src/cli/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,22 @@ use std::path::{Path, PathBuf};
use std::sync::{Arc, LazyLock, Mutex};
use std::{cmp, env};

use anyhow::{anyhow, Context, Result};
use anyhow::{Context, Result, anyhow};
use git_testament::{git_testament, render_testament};
use tracing::{debug, error, info, trace, warn};
use tracing_subscriber::{reload::Handle, EnvFilter, Registry};
use tracing_subscriber::{EnvFilter, Registry, reload::Handle};

use super::self_update;
use crate::{
cli::download_tracker::DownloadTracker,
config::Cfg,
dist::{
manifest::ComponentStatus, notifications as dist_notifications, TargetTriple, ToolchainDesc,
TargetTriple, ToolchainDesc, manifest::ComponentStatus, notifications as dist_notifications,
},
errors::RustupError,
install::UpdateStatus,
notifications::Notification,
process::{terminalsource, Process},
process::{Process, terminalsource},
toolchain::{DistributableToolchain, LocalToolchainName, Toolchain, ToolchainName},
utils::{self, notifications as util_notifications, notify::NotificationLevel},
};
Expand Down Expand Up @@ -654,7 +654,9 @@ pub(crate) fn warn_if_host_is_emulated(process: &Process) {
"Rustup is not running natively. It's running under emulation of {}.",
TargetTriple::from_host_or_build(process)
);
warn!("For best compatibility and performance you should reinstall rustup for your native CPU.");
warn!(
"For best compatibility and performance you should reinstall rustup for your native CPU."
);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/cli/download_tracker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ use std::time::{Duration, Instant};

use crate::dist::Notification as In;
use crate::notifications::Notification;
use crate::process::{terminalsource, Process};
use crate::utils::units::{Size, Unit, UnitMode};
use crate::process::{Process, terminalsource};
use crate::utils::Notification as Un;
use crate::utils::units::{Size, Unit, UnitMode};

/// Keep track of this many past download amounts
const DOWNLOAD_TRACK_COUNT: usize = 5;
Expand Down
3 changes: 1 addition & 2 deletions src/cli/help.rs
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,7 @@ pub(crate) static COMPLETIONS_HELP: &str = r"Discussion:

$ rustup completions zsh cargo > ~/.zfunc/_cargo";

pub(crate) static OFFICIAL_TOOLCHAIN_ARG_HELP: &str =
"Toolchain name, such as 'stable', 'nightly', \
pub(crate) static OFFICIAL_TOOLCHAIN_ARG_HELP: &str = "Toolchain name, such as 'stable', 'nightly', \
or '1.8.0'. For more information see `rustup \
help toolchain`";
pub(crate) static RESOLVABLE_LOCAL_TOOLCHAIN_ARG_HELP: &str = "Toolchain name, such as 'stable', 'nightly', \
Expand Down
11 changes: 6 additions & 5 deletions src/cli/log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@ use std::{fmt, io::Write};
#[cfg(feature = "otel")]
use opentelemetry_sdk::trace::Tracer;
use termcolor::{Color, ColorSpec, WriteColor};
use tracing::{level_filters::LevelFilter, Event, Subscriber};
use tracing::{Event, Subscriber, level_filters::LevelFilter};
use tracing_subscriber::{
EnvFilter, Layer, Registry,
fmt::{
format::{self, FormatEvent, FormatFields},
FmtContext,
format::{self, FormatEvent, FormatFields},
},
layer::SubscriberExt,
registry::LookupSpan,
reload, EnvFilter, Layer, Registry,
reload,
};

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

use opentelemetry::{global, trace::TracerProvider as _, KeyValue};
use opentelemetry::{KeyValue, global, trace::TracerProvider as _};
use opentelemetry_otlp::WithExportConfig;
use opentelemetry_sdk::{
Resource,
runtime::Tokio,
trace::{Sampler, TracerProvider},
Resource,
};

let exporter = opentelemetry_otlp::SpanExporter::builder()
Expand Down
4 changes: 2 additions & 2 deletions src/cli/markdown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,8 @@ impl<'a> LineFormatter<'a> {
}
TagEnd::Strong => {}
TagEnd::Strikethrough => {}
TagEnd::Link { .. } => {}
TagEnd::Image { .. } => {} // shouldn't happen, handled in start
TagEnd::Link => {}
TagEnd::Image => {} // shouldn't happen, handled in start
TagEnd::FootnoteDefinition => {}
TagEnd::MetadataBlock(_) => {}
TagEnd::Superscript => {}
Expand Down
Loading