@@ -747,7 +747,7 @@ impl Target {
747747 /// Maximum integer size in bits that this target can perform atomic
748748 /// operations on.
749749 pub fn max_atomic_width ( & self ) -> u64 {
750- self . options . max_atomic_width . unwrap_or ( self . target_pointer_width . parse ( ) . unwrap ( ) )
750+ self . options . max_atomic_width . unwrap_or_else ( || self . target_pointer_width . parse ( ) . unwrap ( ) )
751751 }
752752
753753 pub fn is_abi_supported ( & self , abi : Abi ) -> bool {
@@ -777,7 +777,7 @@ impl Target {
777777 let get_opt_field = |name : & str , default : & str | {
778778 obj. find ( name) . and_then ( |s| s. as_string ( ) )
779779 . map ( |s| s. to_string ( ) )
780- . unwrap_or ( default. to_string ( ) )
780+ . unwrap_or_else ( || default. to_string ( ) )
781781 } ;
782782
783783 let mut base = Target {
@@ -1007,7 +1007,6 @@ impl Target {
10071007 /// filesystem access and JSON decoding.
10081008 pub fn search ( target_triple : & TargetTriple ) -> Result < Target , String > {
10091009 use std:: env;
1010- use std:: ffi:: OsString ;
10111010 use std:: fs;
10121011 use serialize:: json;
10131012
@@ -1018,8 +1017,8 @@ impl Target {
10181017 Target :: from_json ( obj)
10191018 }
10201019
1021- match target_triple {
1022- & TargetTriple :: TargetTriple ( ref target_triple) => {
1020+ match * target_triple {
1021+ TargetTriple :: TargetTriple ( ref target_triple) => {
10231022 // check if triple is in list of supported targets
10241023 if let Ok ( t) = load_specific ( target_triple) {
10251024 return Ok ( t)
@@ -1032,8 +1031,7 @@ impl Target {
10321031 PathBuf :: from ( target)
10331032 } ;
10341033
1035- let target_path = env:: var_os ( "RUST_TARGET_PATH" )
1036- . unwrap_or ( OsString :: new ( ) ) ;
1034+ let target_path = env:: var_os ( "RUST_TARGET_PATH" ) . unwrap_or_default ( ) ;
10371035
10381036 // FIXME 16351: add a sane default search path?
10391037
@@ -1045,7 +1043,7 @@ impl Target {
10451043 }
10461044 Err ( format ! ( "Could not find specification for target {:?}" , target_triple) )
10471045 }
1048- & TargetTriple :: TargetPath ( ref target_path) => {
1046+ TargetTriple :: TargetPath ( ref target_path) => {
10491047 if target_path. is_file ( ) {
10501048 return load_file ( & target_path) ;
10511049 }
@@ -1190,7 +1188,7 @@ impl ToJson for Target {
11901188
11911189 if default. abi_blacklist != self . options . abi_blacklist {
11921190 d. insert ( "abi-blacklist" . to_string ( ) , self . options . abi_blacklist . iter ( )
1193- . map ( Abi :: name) . map ( | name| name . to_json ( ) )
1191+ . map ( | & name| Abi :: name ( name) . to_json ( ) )
11941192 . collect :: < Vec < _ > > ( ) . to_json ( ) ) ;
11951193 }
11961194
@@ -1229,9 +1227,9 @@ impl TargetTriple {
12291227 ///
12301228 /// If this target is a path, the file name (without extension) is returned.
12311229 pub fn triple ( & self ) -> & str {
1232- match self {
1233- & TargetTriple :: TargetTriple ( ref triple) => triple,
1234- & TargetTriple :: TargetPath ( ref path) => {
1230+ match * self {
1231+ TargetTriple :: TargetTriple ( ref triple) => triple,
1232+ TargetTriple :: TargetPath ( ref path) => {
12351233 path. file_stem ( ) . expect ( "target path must not be empty" ) . to_str ( )
12361234 . expect ( "target path must be valid unicode" )
12371235 }
@@ -1247,7 +1245,7 @@ impl TargetTriple {
12471245 use std:: collections:: hash_map:: DefaultHasher ;
12481246
12491247 let triple = self . triple ( ) ;
1250- if let & TargetTriple :: TargetPath ( ref path) = self {
1248+ if let TargetTriple :: TargetPath ( ref path) = * self {
12511249 let mut hasher = DefaultHasher :: new ( ) ;
12521250 path. hash ( & mut hasher) ;
12531251 let hash = hasher. finish ( ) ;
0 commit comments