@@ -86,7 +86,7 @@ impl<T: Into<String>> From<T> for OverrideFile {
86
86
}
87
87
88
88
#[ derive( Debug ) ]
89
- pub enum OverrideReason {
89
+ pub ( crate ) enum OverrideReason {
90
90
Environment ,
91
91
CommandLine ,
92
92
OverrideDB ( PathBuf ) ,
@@ -170,7 +170,7 @@ pub enum PgpPublicKey {
170
170
171
171
impl PgpPublicKey {
172
172
/// Retrieve the key.
173
- pub fn key ( & self ) -> & SignedPublicKey {
173
+ pub ( crate ) fn key ( & self ) -> & SignedPublicKey {
174
174
match self {
175
175
Self :: Builtin => & * BUILTIN_PGP_KEY ,
176
176
Self :: FromEnvironment ( _, k) => k,
@@ -179,7 +179,7 @@ impl PgpPublicKey {
179
179
}
180
180
181
181
/// Display the key in detail for the user
182
- pub fn show_key ( & self ) -> Result < Vec < String > > {
182
+ pub ( crate ) fn show_key ( & self ) -> Result < Vec < String > > {
183
183
fn format_hex ( bytes : & [ u8 ] , separator : & str , every : usize ) -> Result < String > {
184
184
use std:: fmt:: Write ;
185
185
let mut ret = String :: new ( ) ;
@@ -226,7 +226,7 @@ impl Display for PgpPublicKey {
226
226
}
227
227
}
228
228
229
- pub const UNIX_FALLBACK_SETTINGS : & str = "/etc/rustup/settings.toml" ;
229
+ pub ( crate ) const UNIX_FALLBACK_SETTINGS : & str = "/etc/rustup/settings.toml" ;
230
230
231
231
pub struct Cfg {
232
232
profile_override : Option < dist:: Profile > ,
@@ -241,7 +241,6 @@ pub struct Cfg {
241
241
pub toolchain_override : Option < String > ,
242
242
pub env_override : Option < String > ,
243
243
pub dist_root_url : String ,
244
- pub dist_root_server : String ,
245
244
pub notify_handler : Arc < dyn Fn ( Notification < ' _ > ) > ,
246
245
}
247
246
@@ -330,7 +329,7 @@ impl Cfg {
330
329
dist_root_server. as_str ( ) ,
331
330
Box :: new ( move |n| ( notify_clone) ( n. into ( ) ) ) ,
332
331
) ;
333
- let dist_root = dist_root_server. clone ( ) + "/dist" ;
332
+ let dist_root = dist_root_server + "/dist" ;
334
333
335
334
let cfg = Self {
336
335
profile_override : None ,
@@ -346,7 +345,6 @@ impl Cfg {
346
345
toolchain_override : None ,
347
346
env_override,
348
347
dist_root_url : dist_root,
349
- dist_root_server,
350
348
} ;
351
349
352
350
// Run some basic checks against the constructed configuration
@@ -372,15 +370,15 @@ impl Cfg {
372
370
}
373
371
}
374
372
375
- pub fn get_pgp_keys ( & self ) -> & [ PgpPublicKey ] {
373
+ pub ( crate ) fn get_pgp_keys ( & self ) -> & [ PgpPublicKey ] {
376
374
& self . pgp_keys
377
375
}
378
376
379
377
pub ( crate ) fn set_profile_override ( & mut self , profile : dist:: Profile ) {
380
378
self . profile_override = Some ( profile) ;
381
379
}
382
380
383
- pub fn set_default ( & self , toolchain : & str ) -> Result < ( ) > {
381
+ pub ( crate ) fn set_default ( & self , toolchain : & str ) -> Result < ( ) > {
384
382
self . settings_file . with_mut ( |s| {
385
383
s. default_toolchain = Some ( toolchain. to_owned ( ) ) ;
386
384
Ok ( ( ) )
@@ -389,7 +387,7 @@ impl Cfg {
389
387
Ok ( ( ) )
390
388
}
391
389
392
- pub fn set_profile ( & mut self , profile : & str ) -> Result < ( ) > {
390
+ pub ( crate ) fn set_profile ( & mut self , profile : & str ) -> Result < ( ) > {
393
391
match Profile :: from_str ( profile) {
394
392
Ok ( p) => {
395
393
self . profile_override = None ;
@@ -404,7 +402,7 @@ impl Cfg {
404
402
}
405
403
}
406
404
407
- pub fn set_auto_self_update ( & mut self , mode : & str ) -> Result < ( ) > {
405
+ pub ( crate ) fn set_auto_self_update ( & mut self , mode : & str ) -> Result < ( ) > {
408
406
match SelfUpdateMode :: from_str ( mode) {
409
407
Ok ( update_mode) => {
410
408
self . settings_file . with_mut ( |s| {
@@ -418,7 +416,7 @@ impl Cfg {
418
416
}
419
417
}
420
418
421
- pub fn set_toolchain_override ( & mut self , toolchain_override : & str ) {
419
+ pub ( crate ) fn set_toolchain_override ( & mut self , toolchain_override : & str ) {
422
420
self . toolchain_override = Some ( toolchain_override. to_owned ( ) ) ;
423
421
}
424
422
@@ -442,7 +440,7 @@ impl Cfg {
442
440
} )
443
441
}
444
442
445
- pub fn get_self_update_mode ( & self ) -> Result < SelfUpdateMode > {
443
+ pub ( crate ) fn get_self_update_mode ( & self ) -> Result < SelfUpdateMode > {
446
444
self . settings_file . with ( |s| {
447
445
let mode = match & s. auto_self_update {
448
446
Some ( mode) => mode. clone ( ) ,
@@ -452,7 +450,7 @@ impl Cfg {
452
450
} )
453
451
}
454
452
455
- pub fn get_toolchain ( & self , name : & str , create_parent : bool ) -> Result < Toolchain < ' _ > > {
453
+ pub ( crate ) fn get_toolchain ( & self , name : & str , create_parent : bool ) -> Result < Toolchain < ' _ > > {
456
454
if create_parent {
457
455
utils:: ensure_dir_exists ( "toolchains" , & self . toolchains_dir , & |n| {
458
456
( self . notify_handler ) ( n)
@@ -462,7 +460,7 @@ impl Cfg {
462
460
Toolchain :: from ( self , name)
463
461
}
464
462
465
- pub fn get_hash_file ( & self , toolchain : & str , create_parent : bool ) -> Result < PathBuf > {
463
+ pub ( crate ) fn get_hash_file ( & self , toolchain : & str , create_parent : bool ) -> Result < PathBuf > {
466
464
if create_parent {
467
465
utils:: ensure_dir_exists (
468
466
"update-hash" ,
@@ -474,7 +472,7 @@ impl Cfg {
474
472
Ok ( self . update_hash_dir . join ( toolchain) )
475
473
}
476
474
477
- pub fn which_binary_by_toolchain (
475
+ pub ( crate ) fn which_binary_by_toolchain (
478
476
& self ,
479
477
toolchain : & str ,
480
478
binary : & str ,
@@ -487,12 +485,12 @@ impl Cfg {
487
485
}
488
486
}
489
487
490
- pub fn which_binary ( & self , path : & Path , binary : & str ) -> Result < Option < PathBuf > > {
488
+ pub ( crate ) fn which_binary ( & self , path : & Path , binary : & str ) -> Result < Option < PathBuf > > {
491
489
let ( toolchain, _) = self . find_or_install_override_toolchain_or_default ( path) ?;
492
490
Ok ( Some ( toolchain. binary_file ( binary) ) )
493
491
}
494
492
495
- pub fn upgrade_data ( & self ) -> Result < ( ) > {
493
+ pub ( crate ) fn upgrade_data ( & self ) -> Result < ( ) > {
496
494
let current_version = self . settings_file . with ( |s| Ok ( s. version . clone ( ) ) ) ?;
497
495
498
496
if current_version == DEFAULT_METADATA_VERSION {
@@ -532,7 +530,7 @@ impl Cfg {
532
530
}
533
531
}
534
532
535
- pub fn find_default ( & self ) -> Result < Option < Toolchain < ' _ > > > {
533
+ pub ( crate ) fn find_default ( & self ) -> Result < Option < Toolchain < ' _ > > > {
536
534
let opt_name = self . get_default ( ) ?;
537
535
538
536
if let Some ( name) = opt_name {
@@ -543,7 +541,10 @@ impl Cfg {
543
541
}
544
542
}
545
543
546
- pub fn find_override ( & self , path : & Path ) -> Result < Option < ( Toolchain < ' _ > , OverrideReason ) > > {
544
+ pub ( crate ) fn find_override (
545
+ & self ,
546
+ path : & Path ,
547
+ ) -> Result < Option < ( Toolchain < ' _ > , OverrideReason ) > > {
547
548
self . find_override_config ( path) . map ( |opt| {
548
549
opt. and_then ( |( override_cfg, reason) | {
549
550
override_cfg. toolchain . map ( |toolchain| ( toolchain, reason) )
@@ -722,7 +723,7 @@ impl Cfg {
722
723
}
723
724
}
724
725
725
- pub fn find_or_install_override_toolchain_or_default (
726
+ pub ( crate ) fn find_or_install_override_toolchain_or_default (
726
727
& self ,
727
728
path : & Path ,
728
729
) -> Result < ( Toolchain < ' _ > , Option < OverrideReason > ) > {
@@ -819,7 +820,7 @@ impl Cfg {
819
820
}
820
821
}
821
822
822
- pub fn get_default ( & self ) -> Result < Option < String > > {
823
+ pub ( crate ) fn get_default ( & self ) -> Result < Option < String > > {
823
824
let user_opt = self . settings_file . with ( |s| Ok ( s. default_toolchain . clone ( ) ) ) ;
824
825
if let Some ( fallback_settings) = & self . fallback_settings {
825
826
match user_opt {
@@ -830,7 +831,7 @@ impl Cfg {
830
831
user_opt
831
832
}
832
833
833
- pub fn list_toolchains ( & self ) -> Result < Vec < String > > {
834
+ pub ( crate ) fn list_toolchains ( & self ) -> Result < Vec < String > > {
834
835
if utils:: is_directory ( & self . toolchains_dir ) {
835
836
let mut toolchains: Vec < _ > = utils:: read_dir ( "toolchains" , & self . toolchains_dir ) ?
836
837
. filter_map ( io:: Result :: ok)
@@ -846,7 +847,7 @@ impl Cfg {
846
847
}
847
848
}
848
849
849
- pub fn list_channels ( & self ) -> Result < Vec < ( String , Result < Toolchain < ' _ > > ) > > {
850
+ pub ( crate ) fn list_channels ( & self ) -> Result < Vec < ( String , Result < Toolchain < ' _ > > ) > > {
850
851
let toolchains = self . list_toolchains ( ) ?;
851
852
852
853
// Convert the toolchain strings to Toolchain values
@@ -859,7 +860,7 @@ impl Cfg {
859
860
. collect ( ) )
860
861
}
861
862
862
- pub fn update_all_channels (
863
+ pub ( crate ) fn update_all_channels (
863
864
& self ,
864
865
force_update : bool ,
865
866
) -> Result < Vec < ( String , Result < UpdateStatus > ) > > {
@@ -883,7 +884,7 @@ impl Cfg {
883
884
Ok ( channels. collect ( ) )
884
885
}
885
886
886
- pub fn check_metadata_version ( & self ) -> Result < ( ) > {
887
+ pub ( crate ) fn check_metadata_version ( & self ) -> Result < ( ) > {
887
888
utils:: assert_is_directory ( & self . rustup_dir ) ?;
888
889
889
890
self . settings_file . with ( |s| {
@@ -898,14 +899,14 @@ impl Cfg {
898
899
} )
899
900
}
900
901
901
- pub fn toolchain_for_dir (
902
+ pub ( crate ) fn toolchain_for_dir (
902
903
& self ,
903
904
path : & Path ,
904
905
) -> Result < ( Toolchain < ' _ > , Option < OverrideReason > ) > {
905
906
self . find_or_install_override_toolchain_or_default ( path)
906
907
}
907
908
908
- pub fn create_command_for_dir ( & self , path : & Path , binary : & str ) -> Result < Command > {
909
+ pub ( crate ) fn create_command_for_dir ( & self , path : & Path , binary : & str ) -> Result < Command > {
909
910
let ( ref toolchain, _) = self . toolchain_for_dir ( path) ?;
910
911
911
912
if let Some ( cmd) = self . maybe_do_cargo_fallback ( toolchain, binary) ? {
@@ -918,7 +919,7 @@ impl Cfg {
918
919
}
919
920
}
920
921
921
- pub fn create_command_for_toolchain (
922
+ pub ( crate ) fn create_command_for_toolchain (
922
923
& self ,
923
924
toolchain : & str ,
924
925
install_if_missing : bool ,
@@ -974,7 +975,7 @@ impl Cfg {
974
975
Ok ( None )
975
976
}
976
977
977
- pub fn set_default_host_triple ( & self , host_triple : & str ) -> Result < ( ) > {
978
+ pub ( crate ) fn set_default_host_triple ( & self , host_triple : & str ) -> Result < ( ) > {
978
979
// Ensure that the provided host_triple is capable of resolving
979
980
// against the 'stable' toolchain. This provides early errors
980
981
// if the supplied triple is insufficient / bad.
@@ -997,7 +998,7 @@ impl Cfg {
997
998
. unwrap_or_else ( dist:: TargetTriple :: from_host_or_build) )
998
999
}
999
1000
1000
- pub fn resolve_toolchain ( & self , name : & str ) -> Result < String > {
1001
+ pub ( crate ) fn resolve_toolchain ( & self , name : & str ) -> Result < String > {
1001
1002
if let Ok ( desc) = dist:: PartialToolchainDesc :: from_str ( name) {
1002
1003
let host = self . get_default_host_triple ( ) ?;
1003
1004
Ok ( desc. resolve ( & host) ?. to_string ( ) )
0 commit comments