@@ -239,7 +239,8 @@ macro_rules! options {
239
239
$init: expr,
240
240
$parse: ident,
241
241
[ $dep_tracking_marker: ident] ,
242
- $desc: expr)
242
+ $desc: expr
243
+ $( , deprecated_do_nothing: $dnn: literal ) ?)
243
244
) ,* , ) =>
244
245
(
245
246
#[ derive( Clone ) ]
@@ -280,7 +281,8 @@ macro_rules! options {
280
281
}
281
282
282
283
pub const $stat: OptionDescrs <$struct_name> =
283
- & [ $( ( stringify!( $opt) , $optmod:: $opt, desc:: $parse, $desc) ) ,* ] ;
284
+ & [ $( OptionDesc { name: stringify!( $opt) , setter: $optmod:: $opt,
285
+ type_desc: desc:: $parse, desc: $desc, is_deprecated_and_do_nothing: false $( || $dnn ) ? } ) ,* ] ;
284
286
285
287
mod $optmod {
286
288
$(
@@ -315,7 +317,27 @@ macro_rules! redirect_field {
315
317
}
316
318
317
319
type OptionSetter < O > = fn ( & mut O , v : Option < & str > ) -> bool ;
318
- type OptionDescrs < O > = & ' static [ ( & ' static str , OptionSetter < O > , & ' static str , & ' static str ) ] ;
320
+ type OptionDescrs < O > = & ' static [ OptionDesc < O > ] ;
321
+
322
+ pub struct OptionDesc < O > {
323
+ name : & ' static str ,
324
+ setter : OptionSetter < O > ,
325
+ // description for return value/type from mod desc
326
+ type_desc : & ' static str ,
327
+ // description for option from options table
328
+ desc : & ' static str ,
329
+ is_deprecated_and_do_nothing : bool ,
330
+ }
331
+
332
+ impl < O > OptionDesc < O > {
333
+ pub fn name ( & self ) -> & ' static str {
334
+ self . name
335
+ }
336
+
337
+ pub fn desc ( & self ) -> & ' static str {
338
+ self . desc
339
+ }
340
+ }
319
341
320
342
#[ allow( rustc:: untranslatable_diagnostic) ] // FIXME: make this translatable
321
343
fn build_options < O : Default > (
@@ -333,8 +355,13 @@ fn build_options<O: Default>(
333
355
} ;
334
356
335
357
let option_to_lookup = key. replace ( '-' , "_" ) ;
336
- match descrs. iter ( ) . find ( |( name, ..) | * name == option_to_lookup) {
337
- Some ( ( _, setter, type_desc, _) ) => {
358
+ match descrs. iter ( ) . find ( |opt_desc| opt_desc. name == option_to_lookup) {
359
+ Some ( OptionDesc { name : _, setter, type_desc, desc, is_deprecated_and_do_nothing } ) => {
360
+ if * is_deprecated_and_do_nothing {
361
+ // deprecation works for prefixed options only
362
+ assert ! ( !prefix. is_empty( ) ) ;
363
+ early_dcx. early_warn ( format ! ( "`-{prefix} {key}`: {desc}" ) ) ;
364
+ }
338
365
if !setter ( & mut op, value) {
339
366
match value {
340
367
None => early_dcx. early_fatal (
@@ -1546,7 +1573,8 @@ options! {
1546
1573
// tidy-alphabetical-start
1547
1574
#[ rustc_lint_opt_deny_field_access( "documented to do nothing" ) ]
1548
1575
ar: String = ( String :: new( ) , parse_string, [ UNTRACKED ] ,
1549
- "this option is deprecated and does nothing" ) ,
1576
+ "this option is deprecated and does nothing" ,
1577
+ deprecated_do_nothing: true ) ,
1550
1578
#[ rustc_lint_opt_deny_field_access( "use `Session::code_model` instead of this field" ) ]
1551
1579
code_model: Option <CodeModel > = ( None , parse_code_model, [ TRACKED ] ,
1552
1580
"choose the code model to use (`rustc --print code-models` for details)" ) ,
@@ -1578,9 +1606,10 @@ options! {
1578
1606
incremental: Option <String > = ( None , parse_opt_string, [ UNTRACKED ] ,
1579
1607
"enable incremental compilation" ) ,
1580
1608
#[ rustc_lint_opt_deny_field_access( "documented to do nothing" ) ]
1581
- inline_threshold: Option <u32 > = ( None , parse_opt_number, [ TRACKED ] ,
1609
+ inline_threshold: Option <u32 > = ( None , parse_opt_number, [ UNTRACKED ] ,
1582
1610
"this option is deprecated and does nothing \
1583
- (consider using `-Cllvm-args=--inline-threshold=...`)") ,
1611
+ (consider using `-Cllvm-args=--inline-threshold=...`)",
1612
+ deprecated_do_nothing: true ) ,
1584
1613
#[ rustc_lint_opt_deny_field_access( "use `Session::instrument_coverage` instead of this field" ) ]
1585
1614
instrument_coverage: InstrumentCoverage = ( InstrumentCoverage :: No , parse_instrument_coverage, [ TRACKED ] ,
1586
1615
"instrument the generated code to support LLVM source-based code coverage reports \
@@ -1616,7 +1645,8 @@ options! {
1616
1645
"disable the use of the redzone" ) ,
1617
1646
#[ rustc_lint_opt_deny_field_access( "documented to do nothing" ) ]
1618
1647
no_stack_check: bool = ( false , parse_no_value, [ UNTRACKED ] ,
1619
- "this option is deprecated and does nothing" ) ,
1648
+ "this option is deprecated and does nothing" ,
1649
+ deprecated_do_nothing: true ) ,
1620
1650
no_vectorize_loops: bool = ( false , parse_no_value, [ TRACKED ] ,
1621
1651
"disable loop vectorization optimization passes" ) ,
1622
1652
no_vectorize_slp: bool = ( false , parse_no_value, [ TRACKED ] ,
0 commit comments