@@ -42,23 +42,23 @@ enum InstalledPath<'a> {
42
42
}
43
43
44
44
/// A fully resolved reference to a toolchain which may or may not exist
45
- pub struct Toolchain < ' a > {
45
+ pub ( crate ) struct Toolchain < ' a > {
46
46
cfg : & ' a Cfg ,
47
47
name : String ,
48
48
path : PathBuf ,
49
49
dist_handler : Box < dyn Fn ( crate :: dist:: Notification < ' _ > ) + ' a > ,
50
50
}
51
51
52
52
/// Used by the `list_component` function
53
- pub struct ComponentStatus {
54
- pub component : Component ,
55
- pub name : String ,
56
- pub installed : bool ,
57
- pub available : bool ,
53
+ pub ( crate ) struct ComponentStatus {
54
+ pub ( crate ) component : Component ,
55
+ pub ( crate ) name : String ,
56
+ pub ( crate ) installed : bool ,
57
+ pub ( crate ) available : bool ,
58
58
}
59
59
60
60
#[ derive( Clone , Debug ) ]
61
- pub enum UpdateStatus {
61
+ pub ( crate ) enum UpdateStatus {
62
62
Installed ,
63
63
Updated ( String ) , // Stores the version of rustc *before* the update
64
64
Unchanged ,
@@ -110,7 +110,7 @@ impl<'a> Toolchain<'a> {
110
110
} )
111
111
}
112
112
113
- pub fn as_installed_common ( & ' a self ) -> Result < InstalledCommonToolchain < ' a > > {
113
+ pub ( crate ) fn as_installed_common ( & ' a self ) -> Result < InstalledCommonToolchain < ' a > > {
114
114
if !self . exists ( ) {
115
115
// Should be verify perhaps?
116
116
return Err ( RustupError :: ToolchainNotInstalled ( self . name . to_owned ( ) ) . into ( ) ) ;
@@ -130,10 +130,10 @@ impl<'a> Toolchain<'a> {
130
130
pub ( crate ) fn cfg ( & self ) -> & Cfg {
131
131
self . cfg
132
132
}
133
- pub fn name ( & self ) -> & str {
133
+ pub ( crate ) fn name ( & self ) -> & str {
134
134
& self . name
135
135
}
136
- pub fn path ( & self ) -> & Path {
136
+ pub ( crate ) fn path ( & self ) -> & Path {
137
137
& self . path
138
138
}
139
139
fn is_symlink ( & self ) -> bool {
@@ -145,7 +145,7 @@ impl<'a> Toolchain<'a> {
145
145
/// Is there a filesystem component with the name of the toolchain in the toolchains dir - valid install or not.
146
146
/// Used to determine whether this toolchain should be uninstallable.
147
147
/// Custom and Distributable. Installed and uninstalled. (perhaps onstalled only?)
148
- pub fn exists ( & self ) -> bool {
148
+ pub ( crate ) fn exists ( & self ) -> bool {
149
149
// HACK: linked toolchains are symlinks, and, contrary to what std docs
150
150
// lead me to believe `fs::metadata`, used by `is_directory` does not
151
151
// seem to follow symlinks on windows.
@@ -159,11 +159,11 @@ impl<'a> Toolchain<'a> {
159
159
/// Is there a valid usable toolchain with this name, either in the toolchains dir, or symlinked from it.
160
160
// Could in future check for rustc perhaps.
161
161
// Custom and Distributable. Installed only?
162
- pub fn verify ( & self ) -> Result < ( ) > {
162
+ pub ( crate ) fn verify ( & self ) -> Result < ( ) > {
163
163
utils:: assert_is_directory ( & self . path )
164
164
}
165
165
// Custom and Distributable. Installed only.
166
- pub fn remove ( & self ) -> Result < ( ) > {
166
+ pub ( crate ) fn remove ( & self ) -> Result < ( ) > {
167
167
if self . exists ( ) || self . is_symlink ( ) {
168
168
( self . cfg . notify_handler ) ( Notification :: UninstallingToolchain ( & self . name ) ) ;
169
169
} else {
@@ -186,7 +186,7 @@ impl<'a> Toolchain<'a> {
186
186
}
187
187
188
188
// Custom only
189
- pub fn is_custom ( & self ) -> bool {
189
+ pub ( crate ) fn is_custom ( & self ) -> bool {
190
190
Toolchain :: is_custom_name ( & self . name )
191
191
}
192
192
@@ -195,15 +195,15 @@ impl<'a> Toolchain<'a> {
195
195
}
196
196
197
197
// Distributable only
198
- pub fn is_tracking ( & self ) -> bool {
198
+ pub ( crate ) fn is_tracking ( & self ) -> bool {
199
199
ToolchainDesc :: from_str ( & self . name )
200
200
. ok ( )
201
201
. map ( |d| d. is_tracking ( ) )
202
202
== Some ( true )
203
203
}
204
204
205
205
// Custom and Distributable. Installed only.
206
- pub fn doc_path ( & self , relative : & str ) -> Result < PathBuf > {
206
+ pub ( crate ) fn doc_path ( & self , relative : & str ) -> Result < PathBuf > {
207
207
self . verify ( ) ?;
208
208
209
209
let parts = vec ! [ "share" , "doc" , "rust" , "html" ] ;
@@ -216,31 +216,31 @@ impl<'a> Toolchain<'a> {
216
216
Ok ( doc_dir)
217
217
}
218
218
// Custom and Distributable. Installed only.
219
- pub fn open_docs ( & self , relative : & str ) -> Result < ( ) > {
219
+ pub ( crate ) fn open_docs ( & self , relative : & str ) -> Result < ( ) > {
220
220
self . verify ( ) ?;
221
221
222
222
utils:: open_browser ( & self . doc_path ( relative) ?)
223
223
}
224
224
// Custom and Distributable. Installed only.
225
- pub fn make_default ( & self ) -> Result < ( ) > {
225
+ pub ( crate ) fn make_default ( & self ) -> Result < ( ) > {
226
226
self . cfg . set_default ( & self . name )
227
227
}
228
228
// Custom and Distributable. Installed only.
229
- pub fn make_override ( & self , path : & Path ) -> Result < ( ) > {
229
+ pub ( crate ) fn make_override ( & self , path : & Path ) -> Result < ( ) > {
230
230
self . cfg . settings_file . with_mut ( |s| {
231
231
s. add_override ( path, self . name . clone ( ) , self . cfg . notify_handler . as_ref ( ) ) ;
232
232
Ok ( ( ) )
233
233
} )
234
234
}
235
235
// Distributable and Custom. Installed only.
236
- pub fn binary_file ( & self , name : & str ) -> PathBuf {
236
+ pub ( crate ) fn binary_file ( & self , name : & str ) -> PathBuf {
237
237
let mut path = self . path . clone ( ) ;
238
238
path. push ( "bin" ) ;
239
239
path. push ( name. to_owned ( ) + env:: consts:: EXE_SUFFIX ) ;
240
240
path
241
241
}
242
242
// Distributable and Custom. Installed only.
243
- pub fn rustc_version ( & self ) -> String {
243
+ pub ( crate ) fn rustc_version ( & self ) -> String {
244
244
if let Ok ( installed) = self . as_installed_common ( ) {
245
245
let rustc_path = self . binary_file ( "rustc" ) ;
246
246
if utils:: is_file ( & rustc_path) {
@@ -318,10 +318,10 @@ fn install_msg(bin: &str, toolchain: &str, is_default: bool) -> String {
318
318
}
319
319
}
320
320
/// Newtype hosting functions that apply to both custom and distributable toolchains that are installed.
321
- pub struct InstalledCommonToolchain < ' a > ( & ' a Toolchain < ' a > ) ;
321
+ pub ( crate ) struct InstalledCommonToolchain < ' a > ( & ' a Toolchain < ' a > ) ;
322
322
323
323
impl < ' a > InstalledCommonToolchain < ' a > {
324
- pub fn create_command < T : AsRef < OsStr > > ( & self , binary : T ) -> Result < Command > {
324
+ pub ( crate ) fn create_command < T : AsRef < OsStr > > ( & self , binary : T ) -> Result < Command > {
325
325
// Create the path to this binary within the current toolchain sysroot
326
326
let binary = if let Some ( binary_str) = binary. as_ref ( ) . to_str ( ) {
327
327
if binary_str. to_lowercase ( ) . ends_with ( EXE_SUFFIX ) {
@@ -423,7 +423,7 @@ impl<'a> InstalledCommonToolchain<'a> {
423
423
// find the library in the install path.
424
424
// Setting DYLD_LIBRARY_PATH can easily have unintended
425
425
// consequences.
426
- pub const LOADER_PATH : & str = "DYLD_FALLBACK_LIBRARY_PATH" ;
426
+ pub ( crate ) const LOADER_PATH : & str = "DYLD_FALLBACK_LIBRARY_PATH" ;
427
427
}
428
428
if cfg ! ( target_os = "macos" )
429
429
&& process ( )
@@ -461,10 +461,10 @@ impl<'a> InstalledCommonToolchain<'a> {
461
461
}
462
462
463
463
/// Newtype to facilitate splitting out custom-toolchain specific code.
464
- pub struct CustomToolchain < ' a > ( & ' a Toolchain < ' a > ) ;
464
+ pub ( crate ) struct CustomToolchain < ' a > ( & ' a Toolchain < ' a > ) ;
465
465
466
466
impl < ' a > CustomToolchain < ' a > {
467
- pub fn new ( toolchain : & ' a Toolchain < ' a > ) -> Result < CustomToolchain < ' a > > {
467
+ pub ( crate ) fn new ( toolchain : & ' a Toolchain < ' a > ) -> Result < CustomToolchain < ' a > > {
468
468
if toolchain. is_custom ( ) {
469
469
Ok ( CustomToolchain ( toolchain) )
470
470
} else {
@@ -476,7 +476,7 @@ impl<'a> CustomToolchain<'a> {
476
476
}
477
477
478
478
// Not installed only.
479
- pub fn install_from_dir ( & self , src : & Path , link : bool ) -> Result < ( ) > {
479
+ pub ( crate ) fn install_from_dir ( & self , src : & Path , link : bool ) -> Result < ( ) > {
480
480
let mut pathbuf = PathBuf :: from ( src) ;
481
481
482
482
pathbuf. push ( "lib" ) ;
@@ -505,10 +505,10 @@ impl<'a> InstalledToolchain<'a> for CustomToolchain<'a> {
505
505
}
506
506
507
507
/// Newtype to facilitate splitting out distributable-toolchain specific code.
508
- pub struct DistributableToolchain < ' a > ( & ' a Toolchain < ' a > ) ;
508
+ pub ( crate ) struct DistributableToolchain < ' a > ( & ' a Toolchain < ' a > ) ;
509
509
510
510
impl < ' a > DistributableToolchain < ' a > {
511
- pub fn new ( toolchain : & ' a Toolchain < ' a > ) -> Result < DistributableToolchain < ' a > > {
511
+ pub ( crate ) fn new ( toolchain : & ' a Toolchain < ' a > ) -> Result < DistributableToolchain < ' a > > {
512
512
if toolchain. is_custom ( ) {
513
513
Err ( anyhow ! ( format!(
514
514
"{} is a custom toolchain" ,
@@ -521,7 +521,9 @@ impl<'a> DistributableToolchain<'a> {
521
521
522
522
/// Temporary helper until we further split this into a newtype for
523
523
/// InstalledDistributableToolchain - one where the type can protect component operations.
524
- pub fn new_for_components ( toolchain : & ' a Toolchain < ' a > ) -> Result < DistributableToolchain < ' a > > {
524
+ pub ( crate ) fn new_for_components (
525
+ toolchain : & ' a Toolchain < ' a > ,
526
+ ) -> Result < DistributableToolchain < ' a > > {
525
527
DistributableToolchain :: new ( toolchain) . context ( RustupError :: ComponentsUnsupported (
526
528
toolchain. name ( ) . to_string ( ) ,
527
529
) )
@@ -591,7 +593,7 @@ impl<'a> DistributableToolchain<'a> {
591
593
// Create a command as a fallback for another toolchain. This is used
592
594
// to give custom toolchains access to cargo
593
595
// Installed only.
594
- pub fn create_fallback_command < T : AsRef < OsStr > > (
596
+ pub ( crate ) fn create_fallback_command < T : AsRef < OsStr > > (
595
597
& self ,
596
598
binary : T ,
597
599
primary_toolchain : & Toolchain < ' _ > ,
@@ -764,7 +766,7 @@ impl<'a> DistributableToolchain<'a> {
764
766
}
765
767
766
768
// Installed or not installed.
767
- pub fn install_from_dist_if_not_installed ( & self ) -> Result < UpdateStatus > {
769
+ pub ( crate ) fn install_from_dist_if_not_installed ( & self ) -> Result < UpdateStatus > {
768
770
let update_hash = self . update_hash ( ) ?;
769
771
( self . 0 . cfg . notify_handler ) ( Notification :: LookingForToolchain ( & self . 0 . name ) ) ;
770
772
if !self . 0 . exists ( ) {
@@ -808,7 +810,7 @@ impl<'a> DistributableToolchain<'a> {
808
810
} ) )
809
811
}
810
812
811
- pub fn list_components ( & self ) -> Result < Vec < ComponentStatus > > {
813
+ pub ( crate ) fn list_components ( & self ) -> Result < Vec < ComponentStatus > > {
812
814
if let Some ( toolchain) = self . get_toolchain_desc_with_manifest ( ) ? {
813
815
toolchain. list_components ( )
814
816
} else {
@@ -864,7 +866,7 @@ impl<'a> DistributableToolchain<'a> {
864
866
}
865
867
866
868
// Installed only.
867
- pub fn show_dist_version ( & self ) -> Result < Option < String > > {
869
+ pub ( crate ) fn show_dist_version ( & self ) -> Result < Option < String > > {
868
870
let update_hash = self . update_hash ( ) ?;
869
871
870
872
match crate :: dist:: dist:: dl_v2_manifest (
@@ -878,20 +880,20 @@ impl<'a> DistributableToolchain<'a> {
878
880
}
879
881
880
882
// Installed only.
881
- pub fn show_version ( & self ) -> Result < Option < String > > {
883
+ pub ( crate ) fn show_version ( & self ) -> Result < Option < String > > {
882
884
match self . get_manifest ( ) ? {
883
885
Some ( manifest) => Ok ( Some ( manifest. get_rust_version ( ) ?. to_string ( ) ) ) ,
884
886
None => Ok ( None ) ,
885
887
}
886
888
}
887
889
888
890
// Installed only.
889
- fn update_hash ( & self ) -> Result < PathBuf > {
891
+ pub ( crate ) fn update_hash ( & self ) -> Result < PathBuf > {
890
892
self . 0 . cfg . get_hash_file ( & self . 0 . name , true )
891
893
}
892
894
893
895
// Installed only.
894
- pub fn guess_v1_manifest ( & self ) -> bool {
896
+ pub ( crate ) fn guess_v1_manifest ( & self ) -> bool {
895
897
let prefix = InstallPrefix :: from ( self . 0 . path ( ) . to_owned ( ) ) ;
896
898
// If all the v1 common components are present this is likely to be
897
899
// a v1 manifest install. The v1 components are not called the same
@@ -912,7 +914,7 @@ impl<'a> DistributableToolchain<'a> {
912
914
pub ( crate ) struct ToolchainDescWithManifest {
913
915
toolchain : ToolchainDesc ,
914
916
manifestation : Manifestation ,
915
- pub manifest : Manifest ,
917
+ pub ( crate ) manifest : Manifest ,
916
918
}
917
919
918
920
impl ToolchainDescWithManifest {
0 commit comments