Skip to content

Commit 0796d14

Browse files
committed
Inline single-caller maybe_trace_rustup()
1 parent 55a80fb commit 0796d14

File tree

1 file changed

+15
-16
lines changed

1 file changed

+15
-16
lines changed

src/bin/rustup-init.rs

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
1414
#![recursion_limit = "1024"]
1515

16+
use std::process::ExitCode;
17+
1618
use anyhow::{anyhow, Context, Result};
1719
use cfg_if::cfg_if;
1820
// Public macros require availability of the internal symbols
@@ -30,35 +32,32 @@ use rustup::currentprocess::Process;
3032
use rustup::env_var::RUST_RECURSION_COUNT_MAX;
3133
use rustup::errors::RustupError;
3234
use rustup::is_proxyable_tools;
33-
use rustup::utils::utils::{self, ExitCode};
35+
use rustup::utils::utils;
3436

3537
#[tokio::main]
36-
async fn main() {
38+
async fn main() -> Result<ExitCode> {
3739
#[cfg(windows)]
3840
pre_rustup_main_init();
3941

4042
let process = Process::os();
41-
match maybe_trace_rustup(&process).await {
42-
Err(e) => {
43-
common::report_error(&e, &process);
44-
std::process::exit(1);
45-
}
46-
Ok(utils::ExitCode(c)) => std::process::exit(c),
47-
}
48-
}
49-
50-
async fn maybe_trace_rustup(process: &Process) -> Result<utils::ExitCode> {
5143
#[cfg(feature = "otel")]
5244
opentelemetry::global::set_text_map_propagator(
5345
opentelemetry_sdk::propagation::TraceContextPropagator::new(),
5446
);
55-
let subscriber = rustup::cli::log::tracing_subscriber(process);
47+
let subscriber = rustup::cli::log::tracing_subscriber(&process);
5648
tracing::subscriber::set_global_default(subscriber)?;
57-
let result = run_rustup(process).await;
49+
let result = run_rustup(&process).await;
5850
// We're tracing, so block until all spans are exported.
5951
#[cfg(feature = "otel")]
6052
opentelemetry::global::shutdown_tracer_provider();
61-
result
53+
54+
match result {
55+
Err(e) => {
56+
common::report_error(&e, &process);
57+
std::process::exit(1)
58+
}
59+
Ok(utils::ExitCode(c)) => std::process::exit(c),
60+
}
6261
}
6362

6463
#[cfg_attr(feature = "otel", tracing::instrument)]
@@ -110,7 +109,7 @@ async fn run_rustup_inner(process: &Process) -> Result<utils::ExitCode> {
110109
is_proxyable_tools(n)?;
111110
proxy_mode::main(n, current_dir, process)
112111
.await
113-
.map(ExitCode::from)
112+
.map(utils::ExitCode::from)
114113
}
115114
None => {
116115
// Weird case. No arg0, or it's unparsable.

0 commit comments

Comments
 (0)