Make --force-warns
a normal lint level option
This commit is contained in:
parent
77d155973c
commit
2f2db99432
4 changed files with 19 additions and 47 deletions
|
@ -26,8 +26,6 @@ use rustc_span::symbol::{sym, Symbol};
|
|||
use rustc_span::{source_map::MultiSpan, Span, DUMMY_SP};
|
||||
use tracing::debug;
|
||||
|
||||
use std::cmp;
|
||||
|
||||
fn lint_levels(tcx: TyCtxt<'_>, (): ()) -> LintLevelMap {
|
||||
let store = unerased_lint_store(tcx);
|
||||
let crate_attrs = tcx.hir().attrs(CRATE_HIR_ID);
|
||||
|
@ -91,12 +89,6 @@ impl<'s> LintLevelsBuilder<'s> {
|
|||
for &(ref lint_name, level) in &sess.opts.lint_opts {
|
||||
store.check_lint_name_cmdline(sess, &lint_name, level, self.crate_attrs);
|
||||
let orig_level = level;
|
||||
|
||||
// If the cap is less than this specified level, e.g., if we've got
|
||||
// `--cap-lints allow` but we've also got `-D foo` then we ignore
|
||||
// this specification as the lint cap will set it to allow anyway.
|
||||
let level = cmp::min(level, self.sets.lint_cap);
|
||||
|
||||
let lint_flag_val = Symbol::intern(lint_name);
|
||||
|
||||
let ids = match store.find_lints(&lint_name) {
|
||||
|
@ -104,23 +96,17 @@ impl<'s> LintLevelsBuilder<'s> {
|
|||
Err(_) => continue, // errors handled in check_lint_name_cmdline above
|
||||
};
|
||||
for id in ids {
|
||||
// ForceWarn and Forbid cannot be overriden
|
||||
if let Some((Level::ForceWarn | Level::Forbid, _)) = specs.get(&id) {
|
||||
continue;
|
||||
}
|
||||
|
||||
self.check_gated_lint(id, DUMMY_SP);
|
||||
let src = LintLevelSource::CommandLine(lint_flag_val, orig_level);
|
||||
specs.insert(id, (level, src));
|
||||
}
|
||||
}
|
||||
|
||||
for lint_name in &sess.opts.force_warns {
|
||||
store.check_lint_name_cmdline(sess, lint_name, Level::ForceWarn, self.crate_attrs);
|
||||
let lints = store
|
||||
.find_lints(lint_name)
|
||||
.unwrap_or_else(|_| bug!("A valid lint failed to produce a lint ids"));
|
||||
for id in lints {
|
||||
let src = LintLevelSource::CommandLine(Symbol::intern(lint_name), Level::ForceWarn);
|
||||
specs.insert(id, (Level::ForceWarn, src));
|
||||
}
|
||||
}
|
||||
|
||||
self.cur = self.sets.list.push(LintSet { specs, parent: COMMAND_LINE });
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue