@@ -611,7 +611,7 @@ macro_rules! options {
611611 $parse: ident,
612612 [ $dep_tracking_marker: ident $( $tmod: ident ) ?] ,
613613 $desc: expr
614- $( , is_deprecated_and_do_nothing : $dnn : literal ) ?)
614+ $( , removed : $removed : ident ) ?)
615615 ) ,* , ) =>
616616(
617617 #[ derive( Clone ) ]
@@ -667,7 +667,7 @@ macro_rules! options {
667667
668668 pub const $stat: OptionDescrs <$struct_name> =
669669 & [ $( OptionDesc { name: stringify!( $opt) , setter: $optmod:: $opt,
670- type_desc: desc:: $parse, desc: $desc, is_deprecated_and_do_nothing : false $( || $dnn ) ?,
670+ type_desc: desc:: $parse, desc: $desc, removed : None $( . or ( Some ( RemovedOption :: $removed ) ) ) ?,
671671 tmod: tmod_enum_opt!( $struct_name, $tmod_enum_name, $opt, $( $tmod) ,* ) } ) ,* ] ;
672672
673673 mod $optmod {
@@ -705,14 +705,20 @@ macro_rules! redirect_field {
705705type OptionSetter < O > = fn ( & mut O , v : Option < & str > ) -> bool ;
706706type OptionDescrs < O > = & ' static [ OptionDesc < O > ] ;
707707
708+ /// Indicates whether a removed option should warn or error.
709+ enum RemovedOption {
710+ Warn ,
711+ Err ,
712+ }
713+
708714pub struct OptionDesc < O > {
709715 name : & ' static str ,
710716 setter : OptionSetter < O > ,
711717 // description for return value/type from mod desc
712718 type_desc : & ' static str ,
713719 // description for option from options table
714720 desc : & ' static str ,
715- is_deprecated_and_do_nothing : bool ,
721+ removed : Option < RemovedOption > ,
716722 tmod : Option < OptionsTargetModifiers > ,
717723}
718724
@@ -743,18 +749,18 @@ fn build_options<O: Default>(
743749
744750 let option_to_lookup = key. replace ( '-' , "_" ) ;
745751 match descrs. iter ( ) . find ( |opt_desc| opt_desc. name == option_to_lookup) {
746- Some ( OptionDesc {
747- name : _,
748- setter,
749- type_desc,
750- desc,
751- is_deprecated_and_do_nothing,
752- tmod,
753- } ) => {
754- if * is_deprecated_and_do_nothing {
752+ Some ( OptionDesc { name : _, setter, type_desc, desc, removed, tmod } ) => {
753+ if let Some ( removed) = removed {
755754 // deprecation works for prefixed options only
756755 assert ! ( !prefix. is_empty( ) ) ;
757- early_dcx. early_warn ( format ! ( "`-{prefix} {key}`: {desc}" ) ) ;
756+ match removed {
757+ RemovedOption :: Warn => {
758+ early_dcx. early_warn ( format ! ( "`-{prefix} {key}`: {desc}" ) )
759+ }
760+ RemovedOption :: Err => {
761+ early_dcx. early_fatal ( format ! ( "`-{prefix} {key}`: {desc}" ) )
762+ }
763+ }
758764 }
759765 if !setter ( & mut op, value) {
760766 match value {
@@ -783,6 +789,7 @@ fn build_options<O: Default>(
783789
784790#[ allow( non_upper_case_globals) ]
785791mod desc {
792+ pub ( crate ) const parse_ignore: & str = "<ignored>" ; // should not be user-visible
786793 pub ( crate ) const parse_no_value: & str = "no value" ;
787794 pub ( crate ) const parse_bool: & str =
788795 "one of: `y`, `yes`, `on`, `true`, `n`, `no`, `off` or `false`" ;
@@ -889,6 +896,12 @@ pub mod parse {
889896 pub ( crate ) use super :: * ;
890897 pub ( crate ) const MAX_THREADS_CAP : usize = 256 ;
891898
899+ /// Ignore the value. Used for removed options where we don't actually want to store
900+ /// anything in the session.
901+ pub ( crate ) fn parse_ignore ( _slot : & mut ( ) , _v : Option < & str > ) -> bool {
902+ true
903+ }
904+
892905 /// This is for boolean options that don't take a value, and are true simply
893906 /// by existing on the command-line.
894907 ///
@@ -2059,7 +2072,7 @@ options! {
20592072 #[ rustc_lint_opt_deny_field_access( "documented to do nothing" ) ]
20602073 ar: String = ( String :: new( ) , parse_string, [ UNTRACKED ] ,
20612074 "this option is deprecated and does nothing" ,
2062- is_deprecated_and_do_nothing : true ) ,
2075+ removed : Warn ) ,
20632076 #[ rustc_lint_opt_deny_field_access( "use `Session::code_model` instead of this field" ) ]
20642077 code_model: Option <CodeModel > = ( None , parse_code_model, [ TRACKED ] ,
20652078 "choose the code model to use (`rustc --print code-models` for details)" ) ,
@@ -2098,7 +2111,7 @@ options! {
20982111 inline_threshold: Option <u32 > = ( None , parse_opt_number, [ UNTRACKED ] ,
20992112 "this option is deprecated and does nothing \
21002113 (consider using `-Cllvm-args=--inline-threshold=...`)",
2101- is_deprecated_and_do_nothing : true ) ,
2114+ removed : Warn ) ,
21022115 #[ rustc_lint_opt_deny_field_access( "use `Session::instrument_coverage` instead of this field" ) ]
21032116 instrument_coverage: InstrumentCoverage = ( InstrumentCoverage :: No , parse_instrument_coverage, [ TRACKED ] ,
21042117 "instrument the generated code to support LLVM source-based code coverage reports \
@@ -2139,7 +2152,7 @@ options! {
21392152 #[ rustc_lint_opt_deny_field_access( "documented to do nothing" ) ]
21402153 no_stack_check: bool = ( false , parse_no_value, [ UNTRACKED ] ,
21412154 "this option is deprecated and does nothing" ,
2142- is_deprecated_and_do_nothing : true ) ,
2155+ removed : Warn ) ,
21432156 no_vectorize_loops: bool = ( false , parse_no_value, [ TRACKED ] ,
21442157 "disable loop vectorization optimization passes" ) ,
21452158 no_vectorize_slp: bool = ( false , parse_no_value, [ TRACKED ] ,
@@ -2173,8 +2186,11 @@ options! {
21732186 "set rpath values in libs/exes (default: no)" ) ,
21742187 save_temps: bool = ( false , parse_bool, [ UNTRACKED ] ,
21752188 "save all temporary output files during compilation (default: no)" ) ,
2176- soft_float: bool = ( false , parse_bool, [ TRACKED ] ,
2177- "deprecated option: use soft float ABI (*eabihf targets only) (default: no)" ) ,
2189+ #[ rustc_lint_opt_deny_field_access( "documented to do nothing" ) ]
2190+ soft_float: ( ) = ( ( ) , parse_ignore, [ UNTRACKED ] ,
2191+ "this option has been removed \
2192+ (use a corresponding *eabi target instead)",
2193+ removed: Err ) ,
21782194 #[ rustc_lint_opt_deny_field_access( "use `Session::split_debuginfo` instead of this field" ) ]
21792195 split_debuginfo: Option <SplitDebuginfo > = ( None , parse_split_debuginfo, [ TRACKED ] ,
21802196 "how to handle split-debuginfo, a platform-specific option" ) ,
0 commit comments