@@ -136,6 +136,38 @@ impl<'a> InstallOpts<'a> {
136
136
137
137
Ok ( ( ) )
138
138
}
139
+
140
+ fn validate ( & self ) -> Result < ( ) > {
141
+ common:: warn_if_host_is_emulated ( ) ;
142
+
143
+ // Verify that the installation options are vaguely sane
144
+ ( || {
145
+ let host_triple = self
146
+ . default_host_triple
147
+ . as_ref ( )
148
+ . map ( dist:: TargetTriple :: new)
149
+ . unwrap_or_else ( TargetTriple :: from_host_or_build) ;
150
+ let partial_channel = match & self . default_toolchain {
151
+ None | Some ( MaybeOfficialToolchainName :: None ) => {
152
+ ResolvableToolchainName :: try_from ( "stable" ) ?
153
+ }
154
+ Some ( MaybeOfficialToolchainName :: Some ( s) ) => s. into ( ) ,
155
+ } ;
156
+ let resolved = partial_channel. resolve ( & host_triple) ?;
157
+ debug ! ( "Successfully resolved installation toolchain as: {resolved}" ) ;
158
+ Ok ( ( ) )
159
+ } ) ( )
160
+ . map_err ( |e : Box < dyn std:: error:: Error > | {
161
+ anyhow ! (
162
+ "Pre-checks for host and toolchain failed: {}\n \
163
+ If you are unsure of suitable values, the 'stable' toolchain is the default.\n \
164
+ Valid host triples look something like: {}",
165
+ e,
166
+ TargetTriple :: from_host_or_build( )
167
+ )
168
+ } ) ?;
169
+ Ok ( ( ) )
170
+ }
139
171
}
140
172
141
173
#[ cfg( feature = "no-self-update" ) ]
@@ -424,7 +456,7 @@ pub(crate) async fn install(
424
456
do_pre_install_sanity_checks ( no_prompt) ?;
425
457
}
426
458
427
- do_pre_install_options_sanity_checks ( & opts) ?;
459
+ opts. validate ( ) ?;
428
460
429
461
if !process ( )
430
462
. var_os ( "RUSTUP_INIT_SKIP_EXISTENCE_CHECKS" )
@@ -658,38 +690,6 @@ fn do_pre_install_sanity_checks(no_prompt: bool) -> Result<()> {
658
690
Ok ( ( ) )
659
691
}
660
692
661
- fn do_pre_install_options_sanity_checks ( opts : & InstallOpts < ' _ > ) -> Result < ( ) > {
662
- common:: warn_if_host_is_emulated ( ) ;
663
-
664
- // Verify that the installation options are vaguely sane
665
- ( || {
666
- let host_triple = opts
667
- . default_host_triple
668
- . as_ref ( )
669
- . map ( dist:: TargetTriple :: new)
670
- . unwrap_or_else ( TargetTriple :: from_host_or_build) ;
671
- let partial_channel = match & opts. default_toolchain {
672
- None | Some ( MaybeOfficialToolchainName :: None ) => {
673
- ResolvableToolchainName :: try_from ( "stable" ) ?
674
- }
675
- Some ( MaybeOfficialToolchainName :: Some ( s) ) => s. into ( ) ,
676
- } ;
677
- let resolved = partial_channel. resolve ( & host_triple) ?;
678
- debug ! ( "Successfully resolved installation toolchain as: {resolved}" ) ;
679
- Ok ( ( ) )
680
- } ) ( )
681
- . map_err ( |e : Box < dyn std:: error:: Error > | {
682
- anyhow ! (
683
- "Pre-checks for host and toolchain failed: {}\n \
684
- If you are unsure of suitable values, the 'stable' toolchain is the default.\n \
685
- Valid host triples look something like: {}",
686
- e,
687
- TargetTriple :: from_host_or_build( )
688
- )
689
- } ) ?;
690
- Ok ( ( ) )
691
- }
692
-
693
693
fn pre_install_msg ( no_modify_path : bool ) -> Result < String > {
694
694
let cargo_home = utils:: cargo_home ( ) ?;
695
695
let cargo_home_bin = cargo_home. join ( "bin" ) ;
0 commit comments