@@ -137,9 +137,7 @@ pub mod target_features {
137137 codegen_backend : & dyn CodegenBackend ) {
138138 let tf = Symbol :: intern ( "target_feature" ) ;
139139
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) ) ) ) ;
143141
144142 if sess. crt_static_feature ( ) {
145143 cfg. insert ( ( tf, Some ( Symbol :: intern ( "crt-static" ) ) ) ) ;
@@ -997,7 +995,7 @@ impl RustcDefaultCalls {
997995 input : & Input )
998996 -> Compilation {
999997 let r = matches. opt_strs ( "Z" ) ;
1000- if r. contains ( & ( "ls" . to_string ( ) ) ) {
998+ if r. iter ( ) . any ( |s| * s == "ls" ) {
1001999 match input {
10021000 & Input :: File ( ref ifile) => {
10031001 let path = & ( * ifile) ;
@@ -1085,8 +1083,7 @@ impl RustcDefaultCalls {
10851083 let allow_unstable_cfg = UnstableFeatures :: from_environment ( )
10861084 . is_nightly_build ( ) ;
10871085
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) | {
10901087 let gated_cfg = GatedCfg :: gate ( & ast:: MetaItem {
10911088 ident : ast:: Path :: from_ident ( ast:: Ident :: with_empty_ctxt ( name) ) ,
10921089 node : ast:: MetaItemKind :: Word ,
@@ -1105,16 +1102,16 @@ impl RustcDefaultCalls {
11051102 let value = value. as_ref ( ) . map ( |s| s. as_ref ( ) ) ;
11061103 if name != "target_feature" || value != Some ( "crt-static" ) {
11071104 if !allow_unstable_cfg && gated_cfg. is_some ( ) {
1108- continue ;
1105+ return None
11091106 }
11101107 }
11111108
1112- cfgs . push ( if let Some ( value) = value {
1113- format ! ( "{}=\" {}\" " , name, value)
1109+ if let Some ( value) = value {
1110+ Some ( format ! ( "{}=\" {}\" " , name, value) )
11141111 } else {
1115- name. to_string ( )
1116- } ) ;
1117- }
1112+ Some ( name. to_string ( ) )
1113+ }
1114+ } ) . collect :: < Vec < String > > ( ) ;
11181115
11191116 cfgs. sort ( ) ;
11201117 for cfg in cfgs {
@@ -1177,7 +1174,7 @@ fn usage(verbose: bool, include_unstable_options: bool) {
11771174 for option in groups. iter ( ) . filter ( |x| include_unstable_options || x. is_stable ( ) ) {
11781175 ( option. apply ) ( & mut options) ;
11791176 }
1180- let message = "Usage: rustc [OPTIONS] INPUT" . to_string ( ) ;
1177+ let message = "Usage: rustc [OPTIONS] INPUT" ;
11811178 let nightly_help = if nightly_options:: is_nightly_build ( ) {
11821179 "\n -Z help Print internal options for debugging rustc"
11831180 } else {
@@ -1192,7 +1189,7 @@ fn usage(verbose: bool, include_unstable_options: bool) {
11921189 -C help Print codegen options
11931190 -W help \
11941191 Print 'lint' options and default settings{}{}\n ",
1195- options. usage( & message) ,
1192+ options. usage( message) ,
11961193 nightly_help,
11971194 verbose_help) ;
11981195}
@@ -1463,7 +1460,7 @@ pub fn handle_options(args: &[String]) -> Option<getopts::Matches> {
14631460 "the --no-stack-check flag is deprecated and does nothing" ) ;
14641461 }
14651462
1466- if cg_flags. contains ( & "passes=list" . to_string ( ) ) {
1463+ if cg_flags. iter ( ) . any ( |x| * x == "passes=list" ) {
14671464 get_codegen_sysroot ( "llvm" ) ( ) . print_passes ( ) ;
14681465 return None ;
14691466 }
0 commit comments