1111//! A helper module to probe the Windows Registry when looking for
1212//! windows-specific tools.
1313
14+ #![ allow( clippy:: upper_case_acronyms) ]
15+
1416use std:: process:: Command ;
1517
1618use crate :: Tool ;
@@ -71,11 +73,11 @@ pub fn find_tool(target: &str, tool: &str) -> Option<Tool> {
7173 // environment variables like `LIB`, `INCLUDE`, and `PATH` to ensure that
7274 // the tool is actually usable.
7375
74- return impl_:: find_msvc_environment ( tool, target)
76+ impl_:: find_msvc_environment ( tool, target)
7577 . or_else ( || impl_:: find_msvc_15plus ( tool, target) )
7678 . or_else ( || impl_:: find_msvc_14 ( tool, target) )
7779 . 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) )
7981}
8082
8183/// A version of Visual Studio
@@ -182,7 +184,7 @@ mod impl_ {
182184 impl MsvcTool {
183185 fn new ( tool : PathBuf ) -> MsvcTool {
184186 MsvcTool {
185- tool : tool ,
187+ tool,
186188 libs : Vec :: new ( ) ,
187189 path : Vec :: new ( ) ,
188190 include : Vec :: new ( ) ,
@@ -196,7 +198,7 @@ mod impl_ {
196198 path,
197199 include,
198200 } = self ;
199- let mut tool = Tool :: with_family ( tool. into ( ) , MSVC_FAMILY ) ;
201+ let mut tool = Tool :: with_family ( tool, MSVC_FAMILY ) ;
200202 add_env ( & mut tool, "LIB" , libs) ;
201203 add_env ( & mut tool, "PATH" , path) ;
202204 add_env ( & mut tool, "INCLUDE" , include) ;
@@ -210,7 +212,7 @@ mod impl_ {
210212 fn is_vscmd_target ( target : & str ) -> Option < bool > {
211213 let vscmd_arch = env:: var ( "VSCMD_ARG_TGT_ARCH" ) . ok ( ) ?;
212214 // Convert the Rust target arch to its VS arch equivalent.
213- let arch = match target. split ( "-" ) . next ( ) {
215+ let arch = match target. split ( '-' ) . next ( ) {
214216 Some ( "x86_64" ) => "x64" ,
215217 Some ( "aarch64" ) => "arm64" ,
216218 Some ( "i686" ) | Some ( "i586" ) => "x86" ,
@@ -242,7 +244,7 @@ mod impl_ {
242244 . map ( |p| p. join ( tool) )
243245 . find ( |p| p. exists ( ) )
244246 } )
245- . map ( |path| Tool :: with_family ( path. into ( ) , MSVC_FAMILY ) )
247+ . map ( |path| Tool :: with_family ( path, MSVC_FAMILY ) )
246248 }
247249 }
248250
@@ -394,7 +396,7 @@ mod impl_ {
394396 . into_iter ( )
395397 . filter_map ( |instance| instance. installation_path ( ) )
396398 . map ( |path| path. join ( tool) )
397- . find ( |ref path| path. is_file ( ) ) ,
399+ . find ( |path| path. is_file ( ) ) ,
398400 None => None ,
399401 } ;
400402
@@ -467,18 +469,15 @@ mod impl_ {
467469 let path = instance_path. join ( r"VC\Tools\MSVC" ) . join ( version) ;
468470 // This is the path to the toolchain for a particular target, running
469471 // 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) ;
474473 // But! we also need PATH to contain the target directory for the host
475474 // architecture, because it contains dlls like mspdb140.dll compiled for
476475 // the host architecture.
477476 let host_dylib_path = path
478477 . 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) ;
482481 let include_path = path. join ( "include" ) ;
483482 Some ( ( path, bin_path, host_dylib_path, lib_path, include_path) )
484483 }
@@ -632,7 +631,7 @@ mod impl_ {
632631 path. join ( "bin" ) . join ( host) ,
633632 )
634633 } )
635- . filter ( |& ( ref path, _) | path. is_file ( ) )
634+ . filter ( |( path, _) | path. is_file ( ) )
636635 . map ( |( path, host) | {
637636 let mut tool = MsvcTool :: new ( path) ;
638637 tool. path . push ( host) ;
@@ -840,7 +839,7 @@ mod impl_ {
840839 for subkey in key. iter ( ) . filter_map ( |k| k. ok ( ) ) {
841840 let val = subkey
842841 . 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 ( ) ) ;
844843 let val = match val {
845844 Some ( s) => s,
846845 None => continue ,
@@ -883,7 +882,7 @@ mod impl_ {
883882 }
884883
885884 pub fn find_devenv ( target : & str ) -> Option < Tool > {
886- find_devenv_vs15 ( & target)
885+ find_devenv_vs15 ( target)
887886 }
888887
889888 fn find_devenv_vs15 ( target : & str ) -> Option < Tool > {
@@ -894,7 +893,7 @@ mod impl_ {
894893 pub fn find_msbuild ( target : & str ) -> Option < Tool > {
895894 // VS 15 (2017) changed how to locate msbuild
896895 if let Some ( r) = find_msbuild_vs17 ( target) {
897- return Some ( r) ;
896+ Some ( r)
898897 } else if let Some ( r) = find_msbuild_vs16 ( target) {
899898 return Some ( r) ;
900899 } else if let Some ( r) = find_msbuild_vs15 ( target) {
0 commit comments