11
11
//! A helper module to probe the Windows Registry when looking for
12
12
//! windows-specific tools.
13
13
14
+ #![ allow( clippy:: upper_case_acronyms) ]
15
+
14
16
use std:: process:: Command ;
15
17
16
18
use crate :: Tool ;
@@ -71,11 +73,11 @@ pub fn find_tool(target: &str, tool: &str) -> Option<Tool> {
71
73
// environment variables like `LIB`, `INCLUDE`, and `PATH` to ensure that
72
74
// the tool is actually usable.
73
75
74
- return impl_:: find_msvc_environment ( tool, target)
76
+ impl_:: find_msvc_environment ( tool, target)
75
77
. or_else ( || impl_:: find_msvc_15plus ( tool, target) )
76
78
. or_else ( || impl_:: find_msvc_14 ( tool, target) )
77
79
. or_else ( || impl_:: find_msvc_12 ( tool, target) )
78
- . or_else ( || impl_:: find_msvc_11 ( tool, target) ) ;
80
+ . or_else ( || impl_:: find_msvc_11 ( tool, target) )
79
81
}
80
82
81
83
/// A version of Visual Studio
@@ -182,7 +184,7 @@ mod impl_ {
182
184
impl MsvcTool {
183
185
fn new ( tool : PathBuf ) -> MsvcTool {
184
186
MsvcTool {
185
- tool : tool ,
187
+ tool,
186
188
libs : Vec :: new ( ) ,
187
189
path : Vec :: new ( ) ,
188
190
include : Vec :: new ( ) ,
@@ -196,7 +198,7 @@ mod impl_ {
196
198
path,
197
199
include,
198
200
} = self ;
199
- let mut tool = Tool :: with_family ( tool. into ( ) , MSVC_FAMILY ) ;
201
+ let mut tool = Tool :: with_family ( tool, MSVC_FAMILY ) ;
200
202
add_env ( & mut tool, "LIB" , libs) ;
201
203
add_env ( & mut tool, "PATH" , path) ;
202
204
add_env ( & mut tool, "INCLUDE" , include) ;
@@ -210,7 +212,7 @@ mod impl_ {
210
212
fn is_vscmd_target ( target : & str ) -> Option < bool > {
211
213
let vscmd_arch = env:: var ( "VSCMD_ARG_TGT_ARCH" ) . ok ( ) ?;
212
214
// Convert the Rust target arch to its VS arch equivalent.
213
- let arch = match target. split ( "-" ) . next ( ) {
215
+ let arch = match target. split ( '-' ) . next ( ) {
214
216
Some ( "x86_64" ) => "x64" ,
215
217
Some ( "aarch64" ) => "arm64" ,
216
218
Some ( "i686" ) | Some ( "i586" ) => "x86" ,
@@ -242,7 +244,7 @@ mod impl_ {
242
244
. map ( |p| p. join ( tool) )
243
245
. find ( |p| p. exists ( ) )
244
246
} )
245
- . map ( |path| Tool :: with_family ( path. into ( ) , MSVC_FAMILY ) )
247
+ . map ( |path| Tool :: with_family ( path, MSVC_FAMILY ) )
246
248
}
247
249
}
248
250
@@ -394,7 +396,7 @@ mod impl_ {
394
396
. into_iter ( )
395
397
. filter_map ( |instance| instance. installation_path ( ) )
396
398
. map ( |path| path. join ( tool) )
397
- . find ( |ref path| path. is_file ( ) ) ,
399
+ . find ( |path| path. is_file ( ) ) ,
398
400
None => None ,
399
401
} ;
400
402
@@ -467,18 +469,15 @@ mod impl_ {
467
469
let path = instance_path. join ( r"VC\Tools\MSVC" ) . join ( version) ;
468
470
// This is the path to the toolchain for a particular target, running
469
471
// on a given host
470
- let bin_path = path
471
- . join ( "bin" )
472
- . join ( & format ! ( "Host{}" , host) )
473
- . join ( & target) ;
472
+ let bin_path = path. join ( "bin" ) . join ( format ! ( "Host{}" , host) ) . join ( target) ;
474
473
// But! we also need PATH to contain the target directory for the host
475
474
// architecture, because it contains dlls like mspdb140.dll compiled for
476
475
// the host architecture.
477
476
let host_dylib_path = path
478
477
. join ( "bin" )
479
- . join ( & format ! ( "Host{}" , host) )
480
- . join ( & host. to_lowercase ( ) ) ;
481
- let lib_path = path. join ( "lib" ) . join ( & target) ;
478
+ . join ( format ! ( "Host{}" , host) )
479
+ . join ( host. to_lowercase ( ) ) ;
480
+ let lib_path = path. join ( "lib" ) . join ( target) ;
482
481
let include_path = path. join ( "include" ) ;
483
482
Some ( ( path, bin_path, host_dylib_path, lib_path, include_path) )
484
483
}
@@ -632,7 +631,7 @@ mod impl_ {
632
631
path. join ( "bin" ) . join ( host) ,
633
632
)
634
633
} )
635
- . filter ( |& ( ref path, _) | path. is_file ( ) )
634
+ . filter ( |( path, _) | path. is_file ( ) )
636
635
. map ( |( path, host) | {
637
636
let mut tool = MsvcTool :: new ( path) ;
638
637
tool. path . push ( host) ;
@@ -840,7 +839,7 @@ mod impl_ {
840
839
for subkey in key. iter ( ) . filter_map ( |k| k. ok ( ) ) {
841
840
let val = subkey
842
841
. to_str ( )
843
- . and_then ( |s| s. trim_left_matches ( "v" ) . replace ( "." , "" ) . parse ( ) . ok ( ) ) ;
842
+ . and_then ( |s| s. trim_left_matches ( "v" ) . replace ( '.' , "" ) . parse ( ) . ok ( ) ) ;
844
843
let val = match val {
845
844
Some ( s) => s,
846
845
None => continue ,
@@ -883,7 +882,7 @@ mod impl_ {
883
882
}
884
883
885
884
pub fn find_devenv ( target : & str ) -> Option < Tool > {
886
- find_devenv_vs15 ( & target)
885
+ find_devenv_vs15 ( target)
887
886
}
888
887
889
888
fn find_devenv_vs15 ( target : & str ) -> Option < Tool > {
@@ -894,7 +893,7 @@ mod impl_ {
894
893
pub fn find_msbuild ( target : & str ) -> Option < Tool > {
895
894
// VS 15 (2017) changed how to locate msbuild
896
895
if let Some ( r) = find_msbuild_vs17 ( target) {
897
- return Some ( r) ;
896
+ Some ( r)
898
897
} else if let Some ( r) = find_msbuild_vs16 ( target) {
899
898
return Some ( r) ;
900
899
} else if let Some ( r) = find_msbuild_vs15 ( target) {
0 commit comments