@@ -27,7 +27,7 @@ use rustup::cli::rustup_mode;
27
27
#[ cfg( windows) ]
28
28
use rustup:: cli:: self_update;
29
29
use rustup:: cli:: setup_mode;
30
- use rustup:: currentprocess:: { process , with_runtime, Process } ;
30
+ use rustup:: currentprocess:: { with_runtime, Process } ;
31
31
use rustup:: env_var:: RUST_RECURSION_COUNT_MAX ;
32
32
use rustup:: errors:: RustupError ;
33
33
use rustup:: is_proxyable_tools;
@@ -40,11 +40,11 @@ fn main() {
40
40
let process = Process :: os ( ) ;
41
41
let mut builder = Builder :: new_multi_thread ( ) ;
42
42
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 {
46
46
Err ( e) => {
47
- common:: report_error ( & e) ;
47
+ common:: report_error ( & e, & process ) ;
48
48
std:: process:: exit ( 1 ) ;
49
49
}
50
50
Ok ( utils:: ExitCode ( c) ) => std:: process:: exit ( c) ,
@@ -53,68 +53,70 @@ fn main() {
53
53
} ) ;
54
54
}
55
55
56
- async fn maybe_trace_rustup ( ) -> Result < utils:: ExitCode > {
56
+ async fn maybe_trace_rustup ( process : & Process ) -> Result < utils:: ExitCode > {
57
57
#[ cfg( feature = "otel" ) ]
58
58
opentelemetry:: global:: set_text_map_propagator (
59
59
opentelemetry_sdk:: propagation:: TraceContextPropagator :: new ( ) ,
60
60
) ;
61
- let subscriber = rustup:: cli:: log:: tracing_subscriber ( process ( ) ) ;
61
+ let subscriber = rustup:: cli:: log:: tracing_subscriber ( process) ;
62
62
tracing:: subscriber:: set_global_default ( subscriber) ?;
63
- let result = run_rustup ( ) . await ;
63
+ let result = run_rustup ( process ) . await ;
64
64
// We're tracing, so block until all spans are exported.
65
65
#[ cfg( feature = "otel" ) ]
66
66
opentelemetry:: global:: shutdown_tracer_provider ( ) ;
67
67
result
68
68
}
69
69
70
70
#[ 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" ) {
73
73
open_trace_file ! ( dir) ?;
74
74
}
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 ( ) {
77
77
close_trace_file ! ( ) ;
78
78
}
79
79
result
80
80
}
81
81
82
82
#[ 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 > {
84
84
// Guard against infinite proxy recursion. This mostly happens due to
85
85
// bugs in rustup.
86
- do_recursion_guard ( ) ?;
86
+ do_recursion_guard ( process ) ?;
87
87
88
88
// Before we do anything else, ensure we know where we are and who we
89
89
// are because otherwise we cannot proceed usefully.
90
- let current_dir = process ( )
90
+ let current_dir = process
91
91
. current_dir ( )
92
92
. context ( RustupError :: LocatingWorkingDir ) ?;
93
93
utils:: current_exe ( ) ?;
94
94
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 ,
97
97
Some ( n) if n. starts_with ( "rustup-setup" ) || n. starts_with ( "rustup-init" ) => {
98
98
// NB: The above check is only for the prefix of the file
99
99
// name. Browsers rename duplicates to
100
100
// e.g. rustup-setup(2), and this allows all variations
101
101
// to work.
102
- setup_mode:: main ( current_dir) . await
102
+ setup_mode:: main ( current_dir, process ) . await
103
103
}
104
104
Some ( n) if n. starts_with ( "rustup-gc-" ) => {
105
105
// This is the final uninstallation stage on windows where
106
106
// rustup deletes its own exe
107
107
cfg_if ! {
108
108
if #[ cfg( windows) ] {
109
- self_update:: complete_windows_uninstall( )
109
+ self_update:: complete_windows_uninstall( process )
110
110
} else {
111
111
unreachable!( "Attempted to use Windows-specific code on a non-Windows platform. Aborting." )
112
112
}
113
113
}
114
114
}
115
115
Some ( n) => {
116
116
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)
118
120
}
119
121
None => {
120
122
// Weird case. No arg0, or it's unparsable.
@@ -123,8 +125,8 @@ async fn run_rustup_inner() -> Result<utils::ExitCode> {
123
125
}
124
126
}
125
127
126
- fn do_recursion_guard ( ) -> Result < ( ) > {
127
- let recursion_count = process ( )
128
+ fn do_recursion_guard ( process : & Process ) -> Result < ( ) > {
129
+ let recursion_count = process
128
130
. var ( "RUST_RECURSION_COUNT" )
129
131
. ok ( )
130
132
. and_then ( |s| s. parse ( ) . ok ( ) )
0 commit comments