add deprecated and do nothing flag to options table

inline_threshold mark deprecated

no-stack-check

print deprecation message for -Car too

inline_threshold deprecated and do nothing: make in untracked

make OptionDesc struct from tuple
This commit is contained in:
klensy 2025-01-05 15:32:20 +03:00
parent 7270e73b62
commit 37f26311eb
12 changed files with 78 additions and 34 deletions

View file

@ -52,8 +52,8 @@ use rustc_metadata::locator;
use rustc_middle::ty::TyCtxt;
use rustc_parse::{new_parser_from_file, new_parser_from_source_str, unwrap_or_emit_fatal};
use rustc_session::config::{
CG_OPTIONS, ErrorOutputType, Input, OutFileName, OutputType, UnstableOptions, Z_OPTIONS,
nightly_options,
CG_OPTIONS, ErrorOutputType, Input, OptionDesc, OutFileName, OutputType, UnstableOptions,
Z_OPTIONS, nightly_options,
};
use rustc_session::getopts::{self, Matches};
use rustc_session::lint::{Lint, LintId};
@ -1124,14 +1124,6 @@ pub fn describe_flag_categories(early_dcx: &EarlyDiagCtxt, matches: &Matches) ->
return true;
}
if cg_flags.iter().any(|x| *x == "no-stack-check") {
early_dcx.early_warn("the `-Cno-stack-check` flag is deprecated and does nothing");
}
if cg_flags.iter().any(|x| x.starts_with("inline-threshold")) {
early_dcx.early_warn("the `-Cinline-threshold` flag is deprecated and does nothing (consider using `-Cllvm-args=--inline-threshold=...`)");
}
if cg_flags.iter().any(|x| *x == "passes=list") {
let backend_name = debug_flags.iter().find_map(|x| x.strip_prefix("codegen-backend="));
@ -1156,18 +1148,16 @@ fn describe_codegen_flags() {
print_flag_list("-C", config::CG_OPTIONS);
}
fn print_flag_list<T>(
cmdline_opt: &str,
flag_list: &[(&'static str, T, &'static str, &'static str)],
) {
let max_len = flag_list.iter().map(|&(name, _, _, _)| name.chars().count()).max().unwrap_or(0);
fn print_flag_list<T>(cmdline_opt: &str, flag_list: &[OptionDesc<T>]) {
let max_len =
flag_list.iter().map(|opt_desc| opt_desc.name().chars().count()).max().unwrap_or(0);
for &(name, _, _, desc) in flag_list {
for opt_desc in flag_list {
safe_println!(
" {} {:>width$}=val -- {}",
cmdline_opt,
name.replace('_', "-"),
desc,
opt_desc.name().replace('_', "-"),
opt_desc.desc(),
width = max_len
);
}
@ -1221,8 +1211,8 @@ pub fn handle_options(early_dcx: &EarlyDiagCtxt, args: &[String]) -> Option<geto
let msg: Option<String> = match e {
getopts::Fail::UnrecognizedOption(ref opt) => CG_OPTIONS
.iter()
.map(|&(name, ..)| ('C', name))
.chain(Z_OPTIONS.iter().map(|&(name, ..)| ('Z', name)))
.map(|opt_desc| ('C', opt_desc.name()))
.chain(Z_OPTIONS.iter().map(|opt_desc| ('Z', opt_desc.name())))
.find(|&(_, name)| *opt == name.replace('_', "-"))
.map(|(flag, _)| format!("{e}. Did you mean `-{flag} {opt}`?")),
getopts::Fail::ArgumentMissing(ref opt) => {