13
13
14
14
#![ recursion_limit = "1024" ]
15
15
16
+ use std:: process:: ExitCode ;
17
+
16
18
use anyhow:: { anyhow, Context , Result } ;
17
19
use cfg_if:: cfg_if;
18
20
// Public macros require availability of the internal symbols
@@ -30,35 +32,32 @@ use rustup::currentprocess::Process;
30
32
use rustup:: env_var:: RUST_RECURSION_COUNT_MAX ;
31
33
use rustup:: errors:: RustupError ;
32
34
use rustup:: is_proxyable_tools;
33
- use rustup:: utils:: utils:: { self , ExitCode } ;
35
+ use rustup:: utils:: utils;
34
36
35
37
#[ tokio:: main]
36
- async fn main ( ) {
38
+ async fn main ( ) -> Result < ExitCode > {
37
39
#[ cfg( windows) ]
38
40
pre_rustup_main_init ( ) ;
39
41
40
42
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 > {
51
43
#[ cfg( feature = "otel" ) ]
52
44
opentelemetry:: global:: set_text_map_propagator (
53
45
opentelemetry_sdk:: propagation:: TraceContextPropagator :: new ( ) ,
54
46
) ;
55
- let subscriber = rustup:: cli:: log:: tracing_subscriber ( process) ;
47
+ let subscriber = rustup:: cli:: log:: tracing_subscriber ( & process) ;
56
48
tracing:: subscriber:: set_global_default ( subscriber) ?;
57
- let result = run_rustup ( process) . await ;
49
+ let result = run_rustup ( & process) . await ;
58
50
// We're tracing, so block until all spans are exported.
59
51
#[ cfg( feature = "otel" ) ]
60
52
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
+ }
62
61
}
63
62
64
63
#[ cfg_attr( feature = "otel" , tracing:: instrument) ]
@@ -110,7 +109,7 @@ async fn run_rustup_inner(process: &Process) -> Result<utils::ExitCode> {
110
109
is_proxyable_tools ( n) ?;
111
110
proxy_mode:: main ( n, current_dir, process)
112
111
. await
113
- . map ( ExitCode :: from)
112
+ . map ( utils :: ExitCode :: from)
114
113
}
115
114
None => {
116
115
// Weird case. No arg0, or it's unparsable.
0 commit comments