@@ -181,27 +181,22 @@ macro_rules! options {
181
181
let value = iter. next( ) ;
182
182
let option_to_lookup = key. replace( "-" , "_" ) ;
183
183
let mut found = false ;
184
- for & ( candidate, setter, opt_type_desc , _) in $stat {
184
+ for & ( candidate, setter, type_desc , _) in $stat {
185
185
if option_to_lookup != candidate { continue }
186
186
if !setter( & mut op, value) {
187
- match ( value, opt_type_desc) {
188
- ( Some ( ..) , None ) => {
189
- early_error( error_format, & format!( "{} option `{}` takes no \
190
- value", $outputname, key) )
191
- }
192
- ( None , Some ( type_desc) ) => {
187
+ match value {
188
+ None => {
193
189
early_error( error_format, & format!( "{0} option `{1}` requires \
194
190
{2} ({3} {1}=<value>)",
195
191
$outputname, key,
196
192
type_desc, $prefix) )
197
193
}
198
- ( Some ( value) , Some ( type_desc ) ) => {
194
+ Some ( value) => {
199
195
early_error( error_format, & format!( "incorrect value `{}` for {} \
200
196
option `{}` - {} was expected",
201
197
value, $outputname,
202
198
key, type_desc) )
203
199
}
204
- ( None , None ) => panic!( )
205
200
}
206
201
}
207
202
found = true ;
@@ -231,60 +226,44 @@ macro_rules! options {
231
226
}
232
227
233
228
pub type $setter_name = fn ( & mut $struct_name, v: Option <& str >) -> bool ;
234
- pub const $stat: & [ ( & str , $setter_name, Option < & str > , & str ) ] =
229
+ pub const $stat: & [ ( & str , $setter_name, & str , & str ) ] =
235
230
& [ $( ( stringify!( $opt) , $mod_set:: $opt, $mod_desc:: $parse, $desc) ) ,* ] ;
236
231
237
232
#[ allow( non_upper_case_globals, dead_code) ]
238
233
mod $mod_desc {
239
- pub const parse_bool: Option <& str > = Some ( "one of: `y`, `yes`, `on`, `n`, `no`, or `off`" ) ;
240
- pub const parse_opt_bool: Option <& str > = parse_bool;
241
- pub const parse_string: Option <& str > = Some ( "a string" ) ;
242
- pub const parse_opt_string: Option <& str > = parse_string;
243
- pub const parse_string_push: Option <& str > = parse_string;
244
- pub const parse_opt_pathbuf: Option <& str > = Some ( "a path" ) ;
245
- pub const parse_pathbuf_push: Option <& str > = parse_opt_pathbuf;
246
- pub const parse_list: Option <& str > = Some ( "a space-separated list of strings" ) ;
247
- pub const parse_opt_list: Option <& str > = parse_list;
248
- pub const parse_opt_comma_list: Option <& str > = Some ( "a comma-separated list of strings" ) ;
249
- pub const parse_uint: Option <& str > = Some ( "a number" ) ;
250
- pub const parse_opt_uint: Option <& str > = parse_uint;
251
- pub const parse_threads: Option <& str > = parse_uint;
252
- pub const parse_passes: Option <& str > =
253
- Some ( "a space-separated list of passes, or `all`" ) ;
254
- pub const parse_panic_strategy: Option <& str > =
255
- Some ( "either `unwind` or `abort`" ) ;
256
- pub const parse_relro_level: Option <& str > =
257
- Some ( "one of: `full`, `partial`, or `off`" ) ;
258
- pub const parse_sanitizer: Option <& str > =
259
- Some ( "one of: `address`, `leak`, `memory` or `thread`" ) ;
260
- pub const parse_sanitizer_list: Option <& str > =
261
- Some ( "comma separated list of sanitizers" ) ;
262
- pub const parse_sanitizer_memory_track_origins: Option <& str > =
263
- Some ( "0, 1, or 2" ) ;
264
- pub const parse_cfguard: Option <& str > =
265
- Some ( "either `disabled`, `nochecks`, or `checks`" ) ;
266
- pub const parse_linker_flavor: Option <& str > =
267
- Some ( :: rustc_target:: spec:: LinkerFlavor :: one_of( ) ) ;
268
- pub const parse_optimization_fuel: Option <& str > =
269
- Some ( "crate=integer" ) ;
270
- pub const parse_unpretty: Option <& str > =
271
- Some ( "`string` or `string=string`" ) ;
272
- pub const parse_treat_err_as_bug: Option <& str > =
273
- Some ( "either no value or a number bigger than 0" ) ;
274
- pub const parse_lto: Option <& str > =
275
- Some ( "either a boolean (`yes`, `no`, `on`, `off`, etc), `thin`, \
276
- `fat`, or omitted") ;
277
- pub const parse_linker_plugin_lto: Option <& str > =
278
- Some ( "either a boolean (`yes`, `no`, `on`, `off`, etc), \
279
- or the path to the linker plugin") ;
280
- pub const parse_switch_with_opt_path: Option <& str > =
281
- Some ( "an optional path to the profiling data output directory" ) ;
282
- pub const parse_merge_functions: Option <& str > =
283
- Some ( "one of: `disabled`, `trampolines`, or `aliases`" ) ;
284
- pub const parse_symbol_mangling_version: Option <& str > =
285
- Some ( "either `legacy` or `v0` (RFC 2603)" ) ;
286
- pub const parse_src_file_hash: Option <& str > =
287
- Some ( "either `md5`, or `sha1`" ) ;
234
+ pub const parse_bool: & str = "one of: `y`, `yes`, `on`, `n`, `no`, or `off`" ;
235
+ pub const parse_opt_bool: & str = parse_bool;
236
+ pub const parse_string: & str = "a string" ;
237
+ pub const parse_opt_string: & str = parse_string;
238
+ pub const parse_string_push: & str = parse_string;
239
+ pub const parse_opt_pathbuf: & str = "a path" ;
240
+ pub const parse_pathbuf_push: & str = parse_opt_pathbuf;
241
+ pub const parse_list: & str = "a space-separated list of strings" ;
242
+ pub const parse_opt_list: & str = parse_list;
243
+ pub const parse_opt_comma_list: & str = "a comma-separated list of strings" ;
244
+ pub const parse_uint: & str = "a number" ;
245
+ pub const parse_opt_uint: & str = parse_uint;
246
+ pub const parse_threads: & str = parse_uint;
247
+ pub const parse_passes: & str = "a space-separated list of passes, or `all`" ;
248
+ pub const parse_panic_strategy: & str = "either `unwind` or `abort`" ;
249
+ pub const parse_relro_level: & str = "one of: `full`, `partial`, or `off`" ;
250
+ pub const parse_sanitizer: & str = "one of: `address`, `leak`, `memory` or `thread`" ;
251
+ pub const parse_sanitizer_list: & str = "comma separated list of sanitizers" ;
252
+ pub const parse_sanitizer_memory_track_origins: & str = "0, 1, or 2" ;
253
+ pub const parse_cfguard: & str = "either `disabled`, `nochecks`, or `checks`" ;
254
+ pub const parse_linker_flavor: & str = :: rustc_target:: spec:: LinkerFlavor :: one_of( ) ;
255
+ pub const parse_optimization_fuel: & str = "crate=integer" ;
256
+ pub const parse_unpretty: & str = "`string` or `string=string`" ;
257
+ pub const parse_treat_err_as_bug: & str = "either no value or a number bigger than 0" ;
258
+ pub const parse_lto: & str =
259
+ "either a boolean (`yes`, `no`, `on`, `off`, etc), `thin`, `fat`, or omitted" ;
260
+ pub const parse_linker_plugin_lto: & str =
261
+ "either a boolean (`yes`, `no`, `on`, `off`, etc), or the path to the linker plugin" ;
262
+ pub const parse_switch_with_opt_path: & str =
263
+ "an optional path to the profiling data output directory" ;
264
+ pub const parse_merge_functions: & str = "one of: `disabled`, `trampolines`, or `aliases`" ;
265
+ pub const parse_symbol_mangling_version: & str = "either `legacy` or `v0` (RFC 2603)" ;
266
+ pub const parse_src_file_hash: & str = "either `md5` or `sha1`" ;
288
267
}
289
268
290
269
#[ allow( dead_code) ]
0 commit comments