@@ -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,10 +53,10 @@ 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( not( feature = "otel" ) ) ]
58
58
{
59
- run_rustup ( ) . await
59
+ run_rustup ( process ) . await
60
60
}
61
61
#[ cfg( feature = "otel" ) ]
62
62
{
@@ -89,61 +89,63 @@ async fn maybe_trace_rustup() -> Result<utils::ExitCode> {
89
89
let telemetry = tracing_opentelemetry:: layer ( ) . with_tracer ( tracer) ;
90
90
let subscriber = Registry :: default ( ) . with ( env_filter) . with ( telemetry) ;
91
91
tracing:: subscriber:: set_global_default ( subscriber) ?;
92
- let result = run_rustup ( ) . await ;
92
+ let result = run_rustup ( process ) . await ;
93
93
// We're tracing, so block until all spans are exported.
94
94
opentelemetry:: global:: shutdown_tracer_provider ( ) ;
95
95
result
96
96
}
97
97
}
98
98
99
99
#[ cfg_attr( feature = "otel" , tracing:: instrument) ]
100
- async fn run_rustup ( ) -> Result < utils:: ExitCode > {
101
- if let Ok ( dir) = process ( ) . var ( "RUSTUP_TRACE_DIR" ) {
100
+ async fn run_rustup ( process : & Process ) -> Result < utils:: ExitCode > {
101
+ if let Ok ( dir) = process. var ( "RUSTUP_TRACE_DIR" ) {
102
102
open_trace_file ! ( dir) ?;
103
103
}
104
- let result = run_rustup_inner ( ) . await ;
105
- if process ( ) . var ( "RUSTUP_TRACE_DIR" ) . is_ok ( ) {
104
+ let result = run_rustup_inner ( process ) . await ;
105
+ if process. var ( "RUSTUP_TRACE_DIR" ) . is_ok ( ) {
106
106
close_trace_file ! ( ) ;
107
107
}
108
108
result
109
109
}
110
110
111
111
#[ cfg_attr( feature = "otel" , tracing:: instrument( err) ) ]
112
- async fn run_rustup_inner ( ) -> Result < utils:: ExitCode > {
112
+ async fn run_rustup_inner ( process : & Process ) -> Result < utils:: ExitCode > {
113
113
// Guard against infinite proxy recursion. This mostly happens due to
114
114
// bugs in rustup.
115
115
do_recursion_guard ( ) ?;
116
116
117
117
// Before we do anything else, ensure we know where we are and who we
118
118
// are because otherwise we cannot proceed usefully.
119
- let current_dir = process ( )
119
+ let current_dir = process
120
120
. current_dir ( )
121
121
. context ( RustupError :: LocatingWorkingDir ) ?;
122
122
utils:: current_exe ( ) ?;
123
123
124
- match process ( ) . name ( ) . as_deref ( ) {
125
- Some ( "rustup" ) => rustup_mode:: main ( current_dir) . await ,
124
+ match process. name ( ) . as_deref ( ) {
125
+ Some ( "rustup" ) => rustup_mode:: main ( current_dir, process ) . await ,
126
126
Some ( n) if n. starts_with ( "rustup-setup" ) || n. starts_with ( "rustup-init" ) => {
127
127
// NB: The above check is only for the prefix of the file
128
128
// name. Browsers rename duplicates to
129
129
// e.g. rustup-setup(2), and this allows all variations
130
130
// to work.
131
- setup_mode:: main ( current_dir) . await
131
+ setup_mode:: main ( current_dir, process ) . await
132
132
}
133
133
Some ( n) if n. starts_with ( "rustup-gc-" ) => {
134
134
// This is the final uninstallation stage on windows where
135
135
// rustup deletes its own exe
136
136
cfg_if ! {
137
137
if #[ cfg( windows) ] {
138
- self_update:: complete_windows_uninstall( )
138
+ self_update:: complete_windows_uninstall( process )
139
139
} else {
140
140
unreachable!( "Attempted to use Windows-specific code on a non-Windows platform. Aborting." )
141
141
}
142
142
}
143
143
}
144
144
Some ( n) => {
145
145
is_proxyable_tools ( n) ?;
146
- proxy_mode:: main ( n, current_dir) . await . map ( ExitCode :: from)
146
+ proxy_mode:: main ( n, current_dir, process)
147
+ . await
148
+ . map ( ExitCode :: from)
147
149
}
148
150
None => {
149
151
// Weird case. No arg0, or it's unparsable.
0 commit comments