@@ -747,7 +747,7 @@ impl Target {
747
747
/// Maximum integer size in bits that this target can perform atomic
748
748
/// operations on.
749
749
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 ( ) )
751
751
}
752
752
753
753
pub fn is_abi_supported ( & self , abi : Abi ) -> bool {
@@ -777,7 +777,7 @@ impl Target {
777
777
let get_opt_field = |name : & str , default : & str | {
778
778
obj. find ( name) . and_then ( |s| s. as_string ( ) )
779
779
. map ( |s| s. to_string ( ) )
780
- . unwrap_or ( default. to_string ( ) )
780
+ . unwrap_or_else ( || default. to_string ( ) )
781
781
} ;
782
782
783
783
let mut base = Target {
@@ -1007,7 +1007,6 @@ impl Target {
1007
1007
/// filesystem access and JSON decoding.
1008
1008
pub fn search ( target_triple : & TargetTriple ) -> Result < Target , String > {
1009
1009
use std:: env;
1010
- use std:: ffi:: OsString ;
1011
1010
use std:: fs;
1012
1011
use serialize:: json;
1013
1012
@@ -1018,8 +1017,8 @@ impl Target {
1018
1017
Target :: from_json ( obj)
1019
1018
}
1020
1019
1021
- match target_triple {
1022
- & TargetTriple :: TargetTriple ( ref target_triple) => {
1020
+ match * target_triple {
1021
+ TargetTriple :: TargetTriple ( ref target_triple) => {
1023
1022
// check if triple is in list of supported targets
1024
1023
if let Ok ( t) = load_specific ( target_triple) {
1025
1024
return Ok ( t)
@@ -1032,8 +1031,7 @@ impl Target {
1032
1031
PathBuf :: from ( target)
1033
1032
} ;
1034
1033
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 ( ) ;
1037
1035
1038
1036
// FIXME 16351: add a sane default search path?
1039
1037
@@ -1045,7 +1043,7 @@ impl Target {
1045
1043
}
1046
1044
Err ( format ! ( "Could not find specification for target {:?}" , target_triple) )
1047
1045
}
1048
- & TargetTriple :: TargetPath ( ref target_path) => {
1046
+ TargetTriple :: TargetPath ( ref target_path) => {
1049
1047
if target_path. is_file ( ) {
1050
1048
return load_file ( & target_path) ;
1051
1049
}
@@ -1190,7 +1188,7 @@ impl ToJson for Target {
1190
1188
1191
1189
if default. abi_blacklist != self . options . abi_blacklist {
1192
1190
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 ( ) )
1194
1192
. collect :: < Vec < _ > > ( ) . to_json ( ) ) ;
1195
1193
}
1196
1194
@@ -1229,9 +1227,9 @@ impl TargetTriple {
1229
1227
///
1230
1228
/// If this target is a path, the file name (without extension) is returned.
1231
1229
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) => {
1235
1233
path. file_stem ( ) . expect ( "target path must not be empty" ) . to_str ( )
1236
1234
. expect ( "target path must be valid unicode" )
1237
1235
}
@@ -1247,7 +1245,7 @@ impl TargetTriple {
1247
1245
use std:: collections:: hash_map:: DefaultHasher ;
1248
1246
1249
1247
let triple = self . triple ( ) ;
1250
- if let & TargetTriple :: TargetPath ( ref path) = self {
1248
+ if let TargetTriple :: TargetPath ( ref path) = * self {
1251
1249
let mut hasher = DefaultHasher :: new ( ) ;
1252
1250
path. hash ( & mut hasher) ;
1253
1251
let hash = hasher. finish ( ) ;
0 commit comments