@@ -27,7 +27,7 @@ use rustup::cli::rustup_mode;
2727#[ cfg( windows) ]
2828use rustup:: cli:: self_update;
2929use rustup:: cli:: setup_mode;
30- use rustup:: currentprocess:: { process , with_runtime, Process } ;
30+ use rustup:: currentprocess:: { with_runtime, Process } ;
3131use rustup:: env_var:: RUST_RECURSION_COUNT_MAX ;
3232use rustup:: errors:: RustupError ;
3333use rustup:: is_proxyable_tools;
@@ -40,11 +40,11 @@ fn main() {
4040 let process = Process :: os ( ) ;
4141 let mut builder = Builder :: new_multi_thread ( ) ;
4242 builder. enable_all ( ) ;
43- with_runtime ( process, builder, {
44- async {
45- match maybe_trace_rustup ( ) . await {
43+ with_runtime ( process. clone ( ) , builder, {
44+ async move {
45+ match maybe_trace_rustup ( & process ) . await {
4646 Err ( e) => {
47- common:: report_error ( & e) ;
47+ common:: report_error ( & e, & process ) ;
4848 std:: process:: exit ( 1 ) ;
4949 }
5050 Ok ( utils:: ExitCode ( c) ) => std:: process:: exit ( c) ,
@@ -53,68 +53,70 @@ fn main() {
5353 } ) ;
5454}
5555
56- async fn maybe_trace_rustup ( ) -> Result < utils:: ExitCode > {
56+ async fn maybe_trace_rustup ( process : & Process ) -> Result < utils:: ExitCode > {
5757 #[ cfg( feature = "otel" ) ]
5858 opentelemetry:: global:: set_text_map_propagator (
5959 opentelemetry_sdk:: propagation:: TraceContextPropagator :: new ( ) ,
6060 ) ;
61- let subscriber = rustup:: cli:: log:: tracing_subscriber ( process ( ) ) ;
61+ let subscriber = rustup:: cli:: log:: tracing_subscriber ( process) ;
6262 tracing:: subscriber:: set_global_default ( subscriber) ?;
63- let result = run_rustup ( ) . await ;
63+ let result = run_rustup ( process ) . await ;
6464 // We're tracing, so block until all spans are exported.
6565 #[ cfg( feature = "otel" ) ]
6666 opentelemetry:: global:: shutdown_tracer_provider ( ) ;
6767 result
6868}
6969
7070#[ cfg_attr( feature = "otel" , tracing:: instrument) ]
71- async fn run_rustup ( ) -> Result < utils:: ExitCode > {
72- if let Ok ( dir) = process ( ) . var ( "RUSTUP_TRACE_DIR" ) {
71+ async fn run_rustup ( process : & Process ) -> Result < utils:: ExitCode > {
72+ if let Ok ( dir) = process. var ( "RUSTUP_TRACE_DIR" ) {
7373 open_trace_file ! ( dir) ?;
7474 }
75- let result = run_rustup_inner ( ) . await ;
76- if process ( ) . var ( "RUSTUP_TRACE_DIR" ) . is_ok ( ) {
75+ let result = run_rustup_inner ( process ) . await ;
76+ if process. var ( "RUSTUP_TRACE_DIR" ) . is_ok ( ) {
7777 close_trace_file ! ( ) ;
7878 }
7979 result
8080}
8181
8282#[ cfg_attr( feature = "otel" , tracing:: instrument( err) ) ]
83- async fn run_rustup_inner ( ) -> Result < utils:: ExitCode > {
83+ async fn run_rustup_inner ( process : & Process ) -> Result < utils:: ExitCode > {
8484 // Guard against infinite proxy recursion. This mostly happens due to
8585 // bugs in rustup.
86- do_recursion_guard ( ) ?;
86+ do_recursion_guard ( process ) ?;
8787
8888 // Before we do anything else, ensure we know where we are and who we
8989 // are because otherwise we cannot proceed usefully.
90- let current_dir = process ( )
90+ let current_dir = process
9191 . current_dir ( )
9292 . context ( RustupError :: LocatingWorkingDir ) ?;
9393 utils:: current_exe ( ) ?;
9494
95- match process ( ) . name ( ) . as_deref ( ) {
96- Some ( "rustup" ) => rustup_mode:: main ( current_dir) . await ,
95+ match process. name ( ) . as_deref ( ) {
96+ Some ( "rustup" ) => rustup_mode:: main ( current_dir, process ) . await ,
9797 Some ( n) if n. starts_with ( "rustup-setup" ) || n. starts_with ( "rustup-init" ) => {
9898 // NB: The above check is only for the prefix of the file
9999 // name. Browsers rename duplicates to
100100 // e.g. rustup-setup(2), and this allows all variations
101101 // to work.
102- setup_mode:: main ( current_dir) . await
102+ setup_mode:: main ( current_dir, process ) . await
103103 }
104104 Some ( n) if n. starts_with ( "rustup-gc-" ) => {
105105 // This is the final uninstallation stage on windows where
106106 // rustup deletes its own exe
107107 cfg_if ! {
108108 if #[ cfg( windows) ] {
109- self_update:: complete_windows_uninstall( )
109+ self_update:: complete_windows_uninstall( process )
110110 } else {
111111 unreachable!( "Attempted to use Windows-specific code on a non-Windows platform. Aborting." )
112112 }
113113 }
114114 }
115115 Some ( n) => {
116116 is_proxyable_tools ( n) ?;
117- proxy_mode:: main ( n, current_dir) . await . map ( ExitCode :: from)
117+ proxy_mode:: main ( n, current_dir, process)
118+ . await
119+ . map ( ExitCode :: from)
118120 }
119121 None => {
120122 // Weird case. No arg0, or it's unparsable.
@@ -123,8 +125,8 @@ async fn run_rustup_inner() -> Result<utils::ExitCode> {
123125 }
124126}
125127
126- fn do_recursion_guard ( ) -> Result < ( ) > {
127- let recursion_count = process ( )
128+ fn do_recursion_guard ( process : & Process ) -> Result < ( ) > {
129+ let recursion_count = process
128130 . var ( "RUST_RECURSION_COUNT" )
129131 . ok ( )
130132 . and_then ( |s| s. parse ( ) . ok ( ) )
0 commit comments