@@ -239,7 +239,8 @@ macro_rules! options {
239239 $init: expr,
240240 $parse: ident,
241241 [ $dep_tracking_marker: ident] ,
242- $desc: expr)
242+ $desc: expr
243+ $( , deprecated_do_nothing: $dnn: literal ) ?)
243244 ) ,* , ) =>
244245(
245246 #[ derive( Clone ) ]
@@ -280,7 +281,8 @@ macro_rules! options {
280281 }
281282
282283 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 ) ? } ) ,* ] ;
284286
285287 mod $optmod {
286288 $(
@@ -315,7 +317,27 @@ macro_rules! redirect_field {
315317}
316318
317319type 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+ }
319341
320342#[ allow( rustc:: untranslatable_diagnostic) ] // FIXME: make this translatable
321343fn build_options < O : Default > (
@@ -333,8 +355,13 @@ fn build_options<O: Default>(
333355 } ;
334356
335357 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+ }
338365 if !setter ( & mut op, value) {
339366 match value {
340367 None => early_dcx. early_fatal (
@@ -1546,7 +1573,8 @@ options! {
15461573 // tidy-alphabetical-start
15471574 #[ rustc_lint_opt_deny_field_access( "documented to do nothing" ) ]
15481575 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 ) ,
15501578 #[ rustc_lint_opt_deny_field_access( "use `Session::code_model` instead of this field" ) ]
15511579 code_model: Option <CodeModel > = ( None , parse_code_model, [ TRACKED ] ,
15521580 "choose the code model to use (`rustc --print code-models` for details)" ) ,
@@ -1578,9 +1606,10 @@ options! {
15781606 incremental: Option <String > = ( None , parse_opt_string, [ UNTRACKED ] ,
15791607 "enable incremental compilation" ) ,
15801608 #[ 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 ] ,
15821610 "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 ) ,
15841613 #[ rustc_lint_opt_deny_field_access( "use `Session::instrument_coverage` instead of this field" ) ]
15851614 instrument_coverage: InstrumentCoverage = ( InstrumentCoverage :: No , parse_instrument_coverage, [ TRACKED ] ,
15861615 "instrument the generated code to support LLVM source-based code coverage reports \
@@ -1616,7 +1645,8 @@ options! {
16161645 "disable the use of the redzone" ) ,
16171646 #[ rustc_lint_opt_deny_field_access( "documented to do nothing" ) ]
16181647 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 ) ,
16201650 no_vectorize_loops: bool = ( false , parse_no_value, [ TRACKED ] ,
16211651 "disable loop vectorization optimization passes" ) ,
16221652 no_vectorize_slp: bool = ( false , parse_no_value, [ TRACKED ] ,
0 commit comments