@@ -431,7 +431,7 @@ impl Config {
431431 None => {
432432 let mut t = getenv_unwrap ( "TARGET" ) ;
433433 if t. ends_with ( "-darwin" ) && self . uses_cxx11 {
434- t = t + "11"
434+ t += "11"
435435 }
436436 t
437437 }
@@ -507,14 +507,14 @@ impl Config {
507507 }
508508 let system_prefix = self
509509 . getenv_target_os ( "CMAKE_PREFIX_PATH" )
510- . unwrap_or ( OsString :: new ( ) ) ;
511- cmake_prefix_path. extend ( env:: split_paths ( & system_prefix) . map ( |s| s . to_owned ( ) ) ) ;
510+ . unwrap_or_default ( ) ;
511+ cmake_prefix_path. extend ( env:: split_paths ( & system_prefix) ) ;
512512 let cmake_prefix_path = env:: join_paths ( & cmake_prefix_path) . unwrap ( ) ;
513513
514514 // Build up the first cmake command to build the build system.
515515 let executable = self
516516 . getenv_target_os ( "CMAKE" )
517- . unwrap_or ( OsString :: from ( "cmake" ) ) ;
517+ . unwrap_or_else ( || OsString :: from ( "cmake" ) ) ;
518518 let mut cmd = Command :: new ( & executable) ;
519519
520520 if self . verbose_cmake {
@@ -582,13 +582,14 @@ impl Config {
582582 // If we're on MSVC we need to be sure to use the right generator or
583583 // otherwise we won't get 32/64 bit correct automatically.
584584 // This also guarantees that NMake generator isn't chosen implicitly.
585- let using_nmake_generator;
586- if generator. is_none ( ) {
587- cmd. arg ( "-G" ) . arg ( self . visual_studio_generator ( & target) ) ;
588- using_nmake_generator = false ;
589- } else {
590- using_nmake_generator = generator. as_ref ( ) . unwrap ( ) == "NMake Makefiles" ;
591- }
585+ let using_nmake_generator = {
586+ if generator. is_none ( ) {
587+ cmd. arg ( "-G" ) . arg ( self . visual_studio_generator ( & target) ) ;
588+ false
589+ } else {
590+ generator. as_ref ( ) . unwrap ( ) == "NMake Makefiles"
591+ }
592+ } ;
592593 if !is_ninja && !using_nmake_generator {
593594 if target. contains ( "x86_64" ) {
594595 if self . generator_toolset . is_none ( ) {
@@ -774,7 +775,10 @@ impl Config {
774775 }
775776
776777 // And build!
777- let target = self . cmake_target . clone ( ) . unwrap_or ( "install" . to_string ( ) ) ;
778+ let target = self
779+ . cmake_target
780+ . clone ( )
781+ . unwrap_or_else ( || "install" . to_string ( ) ) ;
778782 let mut cmd = Command :: new ( & executable) ;
779783 cmd. current_dir ( & build) ;
780784
@@ -823,7 +827,7 @@ impl Config {
823827 run ( & mut cmd, "cmake" ) ;
824828
825829 println ! ( "cargo:root={}" , dst. display( ) ) ;
826- return dst;
830+ dst
827831 }
828832
829833 fn getenv_os ( & mut self , v : & str ) -> Option < OsString > {
@@ -845,7 +849,7 @@ impl Config {
845849 . unwrap_or_else ( || getenv_unwrap ( "TARGET" ) ) ;
846850
847851 let kind = if host == target { "HOST" } else { "TARGET" } ;
848- let target_u = target. replace ( "-" , "_" ) ;
852+ let target_u = target. replace ( '-' , "_" ) ;
849853 self . getenv_os ( & format ! ( "{}_{}" , var_base, target) )
850854 . or_else ( || self . getenv_os ( & format ! ( "{}_{}" , var_base, target_u) ) )
851855 . or_else ( || self . getenv_os ( & format ! ( "{}_{}" , kind, var_base) ) )
@@ -894,7 +898,7 @@ impl Config {
894898 // CMake will apparently store canonicalized paths which normally
895899 // isn't relevant to us but we canonicalize it here to ensure
896900 // we're both checking the same thing.
897- let path = fs:: canonicalize ( & self . path ) . unwrap_or ( self . path . clone ( ) ) ;
901+ let path = fs:: canonicalize ( & self . path ) . unwrap_or_else ( |_| self . path . clone ( ) ) ;
898902 let mut f = match File :: open ( dir. join ( "CMakeCache.txt" ) ) {
899903 Ok ( f) => f,
900904 Err ( ..) => return ,
@@ -949,10 +953,10 @@ fn run(cmd: &mut Command, program: &str) {
949953}
950954
951955fn find_exe ( path : & Path ) -> PathBuf {
952- env:: split_paths ( & env:: var_os ( "PATH" ) . unwrap_or ( OsString :: new ( ) ) )
956+ env:: split_paths ( & env:: var_os ( "PATH" ) . unwrap_or_default ( ) )
953957 . map ( |p| p. join ( path) )
954958 . find ( |p| fs:: metadata ( p) . is_ok ( ) )
955- . unwrap_or ( path. to_owned ( ) )
959+ . unwrap_or_else ( || path. to_owned ( ) )
956960}
957961
958962fn getenv_unwrap ( v : & str ) -> String {
0 commit comments