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