Rollup merge of #62406 - Mark-Simulacrum:warnings-lint, r=RalfJung
Lint on invalid values passed to x.py --warnings This also introduces support for `--warnings allow` and fixes --warnings being overridden by the configuration file, config.toml. Fixes #62402 r? @RalfJung
This commit is contained in:
commit
cc453d9895
|
@ -405,7 +405,7 @@ impl Config {
|
||||||
config.incremental = flags.incremental;
|
config.incremental = flags.incremental;
|
||||||
config.dry_run = flags.dry_run;
|
config.dry_run = flags.dry_run;
|
||||||
config.keep_stage = flags.keep_stage;
|
config.keep_stage = flags.keep_stage;
|
||||||
if let Some(value) = flags.warnings {
|
if let Some(value) = flags.deny_warnings {
|
||||||
config.deny_warnings = value;
|
config.deny_warnings = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -571,7 +571,7 @@ impl Config {
|
||||||
config.rustc_default_linker = rust.default_linker.clone();
|
config.rustc_default_linker = rust.default_linker.clone();
|
||||||
config.musl_root = rust.musl_root.clone().map(PathBuf::from);
|
config.musl_root = rust.musl_root.clone().map(PathBuf::from);
|
||||||
config.save_toolstates = rust.save_toolstates.clone().map(PathBuf::from);
|
config.save_toolstates = rust.save_toolstates.clone().map(PathBuf::from);
|
||||||
set(&mut config.deny_warnings, rust.deny_warnings.or(flags.warnings));
|
set(&mut config.deny_warnings, flags.deny_warnings.or(rust.deny_warnings));
|
||||||
set(&mut config.backtrace_on_ice, rust.backtrace_on_ice);
|
set(&mut config.backtrace_on_ice, rust.backtrace_on_ice);
|
||||||
set(&mut config.rust_verify_llvm_ir, rust.verify_llvm_ir);
|
set(&mut config.rust_verify_llvm_ir, rust.verify_llvm_ir);
|
||||||
set(&mut config.rust_remap_debuginfo, rust.remap_debuginfo);
|
set(&mut config.rust_remap_debuginfo, rust.remap_debuginfo);
|
||||||
|
|
|
@ -33,8 +33,11 @@ pub struct Flags {
|
||||||
pub rustc_error_format: Option<String>,
|
pub rustc_error_format: Option<String>,
|
||||||
pub dry_run: bool,
|
pub dry_run: bool,
|
||||||
|
|
||||||
// true => deny
|
// This overrides the deny-warnings configuation option,
|
||||||
pub warnings: Option<bool>,
|
// which passes -Dwarnings to the compiler invocations.
|
||||||
|
//
|
||||||
|
// true => deny, false => allow
|
||||||
|
pub deny_warnings: Option<bool>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub enum Subcommand {
|
pub enum Subcommand {
|
||||||
|
@ -468,7 +471,7 @@ Arguments:
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|p| p.into())
|
.map(|p| p.into())
|
||||||
.collect::<Vec<_>>(),
|
.collect::<Vec<_>>(),
|
||||||
warnings: matches.opt_str("warnings").map(|v| v == "deny"),
|
deny_warnings: parse_deny_warnings(&matches),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -549,3 +552,18 @@ fn split(s: &[String]) -> Vec<String> {
|
||||||
.map(|s| s.to_string())
|
.map(|s| s.to_string())
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn parse_deny_warnings(matches: &getopts::Matches) -> Option<bool> {
|
||||||
|
match matches.opt_str("warnings").as_ref().map(|v| v.as_str()) {
|
||||||
|
Some("deny") => Some(true),
|
||||||
|
Some("allow") => Some(false),
|
||||||
|
Some(value) => {
|
||||||
|
eprintln!(
|
||||||
|
r#"invalid value for --warnings: {:?}, expected "allow" or "deny""#,
|
||||||
|
value,
|
||||||
|
);
|
||||||
|
process::exit(1);
|
||||||
|
},
|
||||||
|
None => None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue