@@ -142,14 +142,13 @@ pub fn find_vs_version() -> Result<VsVers, String> {
142
142
} else if impl_:: has_msbuild_version ( "12.0" ) {
143
143
Ok ( VsVers :: Vs12 )
144
144
} else {
145
- Err ( format ! (
146
- "\n \n \
145
+ Err ( "\n \n \
147
146
couldn't determine visual studio generator\n \
148
147
if VisualStudio is installed, however, consider \
149
148
running the appropriate vcvars script before building \
150
149
this crate\n \
151
150
"
152
- ) )
151
+ . to_string ( ) )
153
152
}
154
153
}
155
154
}
@@ -296,10 +295,8 @@ mod impl_ {
296
295
/// Attempt to find the tool using environment variables set by vcvars.
297
296
pub ( super ) fn find_msvc_environment ( tool : & str , target : TargetArch < ' _ > ) -> Option < Tool > {
298
297
// Early return if the environment doesn't contain a VC install.
299
- if env:: var_os ( "VCINSTALLDIR" ) . is_none ( ) {
300
- return None ;
301
- }
302
- let vs_install_dir = env:: var_os ( "VSINSTALLDIR" ) ?. into ( ) ;
298
+ env:: var_os ( "VCINSTALLDIR" ) ?;
299
+ let vs_install_dir: PathBuf = env:: var_os ( "VSINSTALLDIR" ) ?. into ( ) ;
303
300
304
301
// If the vscmd target differs from the requested target then
305
302
// attempt to get the tool using the VS install directory.
@@ -334,9 +331,9 @@ mod impl_ {
334
331
} ;
335
332
Box :: new ( instances. into_iter ( ) . filter_map ( move |instance| {
336
333
let installation_name = instance. installation_name ( ) ?;
337
- if installation_name. starts_with ( & format ! ( "VisualStudio/{}." , version) ) {
338
- Some ( instance . installation_path ( ) ? )
339
- } else if installation_name . starts_with ( & format ! ( "VisualStudioPreview/{}." , version ) ) {
334
+ if installation_name. starts_with ( & format ! ( "VisualStudio/{}." , version) )
335
+ || installation_name . starts_with ( & format ! ( "VisualStudioPreview/{}." , version ) )
336
+ {
340
337
Some ( instance. installation_path ( ) ?)
341
338
} else {
342
339
None
@@ -417,7 +414,7 @@ mod impl_ {
417
414
} ;
418
415
419
416
let vswhere_output = Command :: new ( vswhere_path)
420
- . args ( & [
417
+ . args ( [
421
418
"-latest" ,
422
419
"-products" ,
423
420
"*" ,
@@ -500,7 +497,7 @@ mod impl_ {
500
497
fn tool_from_vs15plus_instance (
501
498
tool : & str ,
502
499
target : TargetArch < ' _ > ,
503
- instance_path : & PathBuf ,
500
+ instance_path : & Path ,
504
501
) -> Option < Tool > {
505
502
let ( root_path, bin_path, host_dylib_path, lib_path, alt_lib_path, include_path) =
506
503
vs15plus_vc_paths ( target, instance_path) ?;
@@ -706,7 +703,7 @@ mod impl_ {
706
703
}
707
704
708
705
fn add_env ( tool : & mut Tool , env : & str , paths : Vec < PathBuf > ) {
709
- let prev = env:: var_os ( env) . unwrap_or ( OsString :: new ( ) ) ;
706
+ let prev = env:: var_os ( env) . unwrap_or_default ( ) ;
710
707
let prev = env:: split_paths ( & prev) ;
711
708
let new = paths. into_iter ( ) . chain ( prev) ;
712
709
tool. env
@@ -809,8 +806,7 @@ mod impl_ {
809
806
let dir = dirs
810
807
. into_iter ( )
811
808
. rev ( )
812
- . filter ( |dir| dir. join ( "um" ) . join ( "x64" ) . join ( "kernel32.lib" ) . is_file ( ) )
813
- . next ( ) ?;
809
+ . find ( |dir| dir. join ( "um" ) . join ( "x64" ) . join ( "kernel32.lib" ) . is_file ( ) ) ?;
814
810
let version = dir. components ( ) . last ( ) . unwrap ( ) ;
815
811
let version = version. as_os_str ( ) . to_str ( ) . unwrap ( ) . to_string ( ) ;
816
812
Some ( ( root. into ( ) , version) )
@@ -922,7 +918,7 @@ mod impl_ {
922
918
for subkey in key. iter ( ) . filter_map ( |k| k. ok ( ) ) {
923
919
let val = subkey
924
920
. to_str ( )
925
- . and_then ( |s| s. trim_start_matches ( "v" ) . replace ( '.' , "" ) . parse ( ) . ok ( ) ) ;
921
+ . and_then ( |s| s. trim_start_matches ( 'v' ) . replace ( '.' , "" ) . parse ( ) . ok ( ) ) ;
926
922
let val = match val {
927
923
Some ( s) => s,
928
924
None => continue ,
0 commit comments