@@ -6,32 +6,32 @@ use std::path::{Path, PathBuf};
6
6
use std:: process:: ExitStatus ;
7
7
use std:: str:: FromStr ;
8
8
9
- use anyhow:: { anyhow , Context , Error , Result } ;
10
- use clap:: { builder :: PossibleValue , Args , CommandFactory , Parser , Subcommand , ValueEnum } ;
9
+ use anyhow:: { Context , Error , Result , anyhow } ;
10
+ use clap:: { Args , CommandFactory , Parser , Subcommand , ValueEnum , builder :: PossibleValue } ;
11
11
use clap_complete:: Shell ;
12
12
use itertools:: Itertools ;
13
13
use tracing:: { info, trace, warn} ;
14
- use tracing_subscriber:: { reload :: Handle , EnvFilter , Registry } ;
14
+ use tracing_subscriber:: { EnvFilter , Registry , reload :: Handle } ;
15
15
16
16
use crate :: {
17
17
cli:: {
18
- common:: { self , update_console_filter , PackageUpdate } ,
18
+ common:: { self , PackageUpdate , update_console_filter } ,
19
19
errors:: CLIError ,
20
20
help:: * ,
21
- self_update:: { self , check_rustup_update , SelfUpdateMode } ,
21
+ self_update:: { self , SelfUpdateMode , check_rustup_update } ,
22
22
topical_doc,
23
23
} ,
24
24
command,
25
25
config:: { ActiveReason , Cfg } ,
26
26
dist:: {
27
- manifest:: { Component , ComponentStatus } ,
28
27
PartialToolchainDesc , Profile , TargetTriple ,
28
+ manifest:: { Component , ComponentStatus } ,
29
29
} ,
30
30
errors:: RustupError ,
31
31
install:: { InstallMethod , UpdateStatus } ,
32
32
process:: {
33
- terminalsource:: { self , ColorableTerminal } ,
34
33
Process ,
34
+ terminalsource:: { self , ColorableTerminal } ,
35
35
} ,
36
36
toolchain:: {
37
37
CustomToolchainName , DistributableToolchain , LocalToolchainName ,
@@ -41,8 +41,7 @@ use crate::{
41
41
utils:: { self , ExitCode } ,
42
42
} ;
43
43
44
- const TOOLCHAIN_OVERRIDE_ERROR : & str =
45
- "To override the toolchain using the 'rustup +toolchain' syntax, \
44
+ const TOOLCHAIN_OVERRIDE_ERROR : & str = "To override the toolchain using the 'rustup +toolchain' syntax, \
46
45
make sure to prefix the toolchain override with a '+'";
47
46
48
47
fn handle_epipe ( res : Result < utils:: ExitCode > ) -> Result < utils:: ExitCode > {
@@ -90,12 +89,17 @@ struct Rustup {
90
89
}
91
90
92
91
fn plus_toolchain_value_parser ( s : & str ) -> clap:: error:: Result < ResolvableToolchainName > {
93
- use clap:: { error:: ErrorKind , Error } ;
92
+ use clap:: { Error , error:: ErrorKind } ;
94
93
if let Some ( stripped) = s. strip_prefix ( '+' ) {
95
94
ResolvableToolchainName :: try_from ( stripped)
96
95
. map_err ( |e| Error :: raw ( ErrorKind :: InvalidValue , e) )
97
96
} else {
98
- Err ( Error :: raw ( ErrorKind :: InvalidSubcommand , format ! ( "\" {s}\" is not a valid subcommand, so it was interpreted as a toolchain name, but it is also invalid. {TOOLCHAIN_OVERRIDE_ERROR}" ) ) )
97
+ Err ( Error :: raw (
98
+ ErrorKind :: InvalidSubcommand ,
99
+ format ! (
100
+ "\" {s}\" is not a valid subcommand, so it was interpreted as a toolchain name, but it is also invalid. {TOOLCHAIN_OVERRIDE_ERROR}"
101
+ ) ,
102
+ ) )
99
103
}
100
104
}
101
105
@@ -1191,7 +1195,9 @@ async fn target_remove(
1191
1195
let target = TargetTriple :: new ( target) ;
1192
1196
let default_target = cfg. get_default_host_triple ( ) ?;
1193
1197
if target == default_target {
1194
- warn ! ( "removing the default host target; proc-macros and build scripts might no longer build" ) ;
1198
+ warn ! (
1199
+ "removing the default host target; proc-macros and build scripts might no longer build"
1200
+ ) ;
1195
1201
}
1196
1202
// Whether we have at most 1 component target that is not `None` (wildcard).
1197
1203
let has_at_most_one_target = distributable
@@ -1316,13 +1322,17 @@ fn toolchain_remove(cfg: &mut Cfg<'_>, opts: UninstallOpts) -> Result<utils::Exi
1316
1322
. as_ref ( )
1317
1323
. is_some_and ( |n| n == & toolchain_name)
1318
1324
{
1319
- warn ! ( "removing the active toolchain; a toolchain override will be required for running Rust tools" ) ;
1325
+ warn ! (
1326
+ "removing the active toolchain; a toolchain override will be required for running Rust tools"
1327
+ ) ;
1320
1328
}
1321
1329
if default_toolchain
1322
1330
. as_ref ( )
1323
1331
. is_some_and ( |n| n == & toolchain_name)
1324
1332
{
1325
- warn ! ( "removing the default toolchain; proc-macros and build scripts might no longer build" ) ;
1333
+ warn ! (
1334
+ "removing the default toolchain; proc-macros and build scripts might no longer build"
1335
+ ) ;
1326
1336
}
1327
1337
1328
1338
Toolchain :: ensure_removed ( cfg, ( & toolchain_name) . into ( ) ) ?;
@@ -1433,28 +1443,77 @@ macro_rules! docs_data {
1433
1443
docs_data ! [
1434
1444
// flags can be used to open specific documents, e.g. `rustup doc --nomicon`
1435
1445
// tuple elements: document name used as flag, help message, document index path
1436
- ( alloc, "The Rust core allocation and collections library" , "alloc/index.html" ) ,
1437
- ( book, "The Rust Programming Language book" , "book/index.html" ) ,
1446
+ (
1447
+ alloc,
1448
+ "The Rust core allocation and collections library" ,
1449
+ "alloc/index.html"
1450
+ ) ,
1451
+ (
1452
+ book,
1453
+ "The Rust Programming Language book" ,
1454
+ "book/index.html"
1455
+ ) ,
1438
1456
( cargo, "The Cargo Book" , "cargo/index.html" ) ,
1439
1457
( clippy, "The Clippy Documentation" , "clippy/index.html" ) ,
1440
1458
( core, "The Rust Core Library" , "core/index.html" ) ,
1441
- ( edition_guide, "The Rust Edition Guide" , "edition-guide/index.html" ) ,
1442
- ( embedded_book, "The Embedded Rust Book" , "embedded-book/index.html" ) ,
1443
- ( error_codes, "The Rust Error Codes Index" , "error_codes/index.html" ) ,
1444
-
1445
- ( nomicon, "The Dark Arts of Advanced and Unsafe Rust Programming" , "nomicon/index.html" ) ,
1446
-
1459
+ (
1460
+ edition_guide,
1461
+ "The Rust Edition Guide" ,
1462
+ "edition-guide/index.html"
1463
+ ) ,
1464
+ (
1465
+ embedded_book,
1466
+ "The Embedded Rust Book" ,
1467
+ "embedded-book/index.html"
1468
+ ) ,
1469
+ (
1470
+ error_codes,
1471
+ "The Rust Error Codes Index" ,
1472
+ "error_codes/index.html"
1473
+ ) ,
1474
+ (
1475
+ nomicon,
1476
+ "The Dark Arts of Advanced and Unsafe Rust Programming" ,
1477
+ "nomicon/index.html"
1478
+ ) ,
1447
1479
#[ arg( long = "proc_macro" ) ]
1448
- ( proc_macro, "A support library for macro authors when defining new macros" , "proc_macro/index.html" ) ,
1449
-
1480
+ (
1481
+ proc_macro,
1482
+ "A support library for macro authors when defining new macros" ,
1483
+ "proc_macro/index.html"
1484
+ ) ,
1450
1485
( reference, "The Rust Reference" , "reference/index.html" ) ,
1451
- ( rust_by_example, "A collection of runnable examples that illustrate various Rust concepts and standard libraries" , "rust-by-example/index.html" ) ,
1452
- ( rustc, "The compiler for the Rust programming language" , "rustc/index.html" ) ,
1453
- ( rustdoc, "Documentation generator for Rust projects" , "rustdoc/index.html" ) ,
1486
+ (
1487
+ rust_by_example,
1488
+ "A collection of runnable examples that illustrate various Rust concepts and standard libraries" ,
1489
+ "rust-by-example/index.html"
1490
+ ) ,
1491
+ (
1492
+ rustc,
1493
+ "The compiler for the Rust programming language" ,
1494
+ "rustc/index.html"
1495
+ ) ,
1496
+ (
1497
+ rustdoc,
1498
+ "Documentation generator for Rust projects" ,
1499
+ "rustdoc/index.html"
1500
+ ) ,
1454
1501
( std, "Standard library API documentation" , "std/index.html" ) ,
1455
- ( style_guide, "The Rust Style Guide" , "style-guide/index.html" ) ,
1456
- ( test, "Support code for rustc's built in unit-test and micro-benchmarking framework" , "test/index.html" ) ,
1457
- ( unstable_book, "The Unstable Book" , "unstable-book/index.html" ) ,
1502
+ (
1503
+ style_guide,
1504
+ "The Rust Style Guide" ,
1505
+ "style-guide/index.html"
1506
+ ) ,
1507
+ (
1508
+ test,
1509
+ "Support code for rustc's built in unit-test and micro-benchmarking framework" ,
1510
+ "test/index.html"
1511
+ ) ,
1512
+ (
1513
+ unstable_book,
1514
+ "The Unstable Book" ,
1515
+ "unstable-book/index.html"
1516
+ ) ,
1458
1517
] ;
1459
1518
1460
1519
impl DocPage {
@@ -1594,7 +1653,10 @@ fn set_auto_self_update(
1594
1653
. as_ref ( )
1595
1654
. and_then ( |a| a. to_str ( ) )
1596
1655
. ok_or ( CLIError :: NoExeName ) ?;
1597
- warn ! ( "{} is built with the no-self-update feature: setting auto-self-update will not have any effect." , arg0) ;
1656
+ warn ! (
1657
+ "{} is built with the no-self-update feature: setting auto-self-update will not have any effect." ,
1658
+ arg0
1659
+ ) ;
1598
1660
}
1599
1661
cfg. set_auto_self_update ( auto_self_update_mode) ?;
1600
1662
Ok ( utils:: ExitCode ( 0 ) )
@@ -1655,7 +1717,7 @@ fn output_completion_script(
1655
1717
"{} does not currently support completions for {}" ,
1656
1718
command,
1657
1719
shell
1658
- ) )
1720
+ ) ) ;
1659
1721
}
1660
1722
} ;
1661
1723
0 commit comments