@@ -137,9 +137,7 @@ pub mod target_features {
137
137
codegen_backend : & dyn CodegenBackend ) {
138
138
let tf = Symbol :: intern ( "target_feature" ) ;
139
139
140
- for feat in codegen_backend. target_features ( sess) {
141
- cfg. insert ( ( tf, Some ( feat) ) ) ;
142
- }
140
+ cfg. extend ( codegen_backend. target_features ( sess) . into_iter ( ) . map ( |feat| ( tf, Some ( feat) ) ) ) ;
143
141
144
142
if sess. crt_static_feature ( ) {
145
143
cfg. insert ( ( tf, Some ( Symbol :: intern ( "crt-static" ) ) ) ) ;
@@ -997,7 +995,7 @@ impl RustcDefaultCalls {
997
995
input : & Input )
998
996
-> Compilation {
999
997
let r = matches. opt_strs ( "Z" ) ;
1000
- if r. contains ( & ( "ls" . to_string ( ) ) ) {
998
+ if r. iter ( ) . any ( |s| * s == "ls" ) {
1001
999
match input {
1002
1000
& Input :: File ( ref ifile) => {
1003
1001
let path = & ( * ifile) ;
@@ -1085,8 +1083,7 @@ impl RustcDefaultCalls {
1085
1083
let allow_unstable_cfg = UnstableFeatures :: from_environment ( )
1086
1084
. is_nightly_build ( ) ;
1087
1085
1088
- let mut cfgs = Vec :: new ( ) ;
1089
- for & ( name, ref value) in sess. parse_sess . config . iter ( ) {
1086
+ let mut cfgs = sess. parse_sess . config . iter ( ) . filter_map ( |& ( name, ref value) | {
1090
1087
let gated_cfg = GatedCfg :: gate ( & ast:: MetaItem {
1091
1088
ident : ast:: Path :: from_ident ( ast:: Ident :: with_empty_ctxt ( name) ) ,
1092
1089
node : ast:: MetaItemKind :: Word ,
@@ -1105,16 +1102,16 @@ impl RustcDefaultCalls {
1105
1102
let value = value. as_ref ( ) . map ( |s| s. as_ref ( ) ) ;
1106
1103
if name != "target_feature" || value != Some ( "crt-static" ) {
1107
1104
if !allow_unstable_cfg && gated_cfg. is_some ( ) {
1108
- continue ;
1105
+ return None
1109
1106
}
1110
1107
}
1111
1108
1112
- cfgs . push ( if let Some ( value) = value {
1113
- format ! ( "{}=\" {}\" " , name, value)
1109
+ if let Some ( value) = value {
1110
+ Some ( format ! ( "{}=\" {}\" " , name, value) )
1114
1111
} else {
1115
- name. to_string ( )
1116
- } ) ;
1117
- }
1112
+ Some ( name. to_string ( ) )
1113
+ }
1114
+ } ) . collect :: < Vec < String > > ( ) ;
1118
1115
1119
1116
cfgs. sort ( ) ;
1120
1117
for cfg in cfgs {
@@ -1177,7 +1174,7 @@ fn usage(verbose: bool, include_unstable_options: bool) {
1177
1174
for option in groups. iter ( ) . filter ( |x| include_unstable_options || x. is_stable ( ) ) {
1178
1175
( option. apply ) ( & mut options) ;
1179
1176
}
1180
- let message = "Usage: rustc [OPTIONS] INPUT" . to_string ( ) ;
1177
+ let message = "Usage: rustc [OPTIONS] INPUT" ;
1181
1178
let nightly_help = if nightly_options:: is_nightly_build ( ) {
1182
1179
"\n -Z help Print internal options for debugging rustc"
1183
1180
} else {
@@ -1192,7 +1189,7 @@ fn usage(verbose: bool, include_unstable_options: bool) {
1192
1189
-C help Print codegen options
1193
1190
-W help \
1194
1191
Print 'lint' options and default settings{}{}\n ",
1195
- options. usage( & message) ,
1192
+ options. usage( message) ,
1196
1193
nightly_help,
1197
1194
verbose_help) ;
1198
1195
}
@@ -1463,7 +1460,7 @@ pub fn handle_options(args: &[String]) -> Option<getopts::Matches> {
1463
1460
"the --no-stack-check flag is deprecated and does nothing" ) ;
1464
1461
}
1465
1462
1466
- if cg_flags. contains ( & "passes=list" . to_string ( ) ) {
1463
+ if cg_flags. iter ( ) . any ( |x| * x == "passes=list" ) {
1467
1464
get_codegen_sysroot ( "llvm" ) ( ) . print_passes ( ) ;
1468
1465
return None ;
1469
1466
}
0 commit comments