Force warn on lint groups as well
This commit is contained in:
parent
4675690ac4
commit
3b206b7a70
19 changed files with 114 additions and 26 deletions
|
@ -334,8 +334,14 @@ impl LintStore {
|
|||
}
|
||||
}
|
||||
|
||||
/// Checks the validity of lint names derived from the command line
|
||||
pub fn check_lint_name_cmdline(&self, sess: &Session, lint_name: &str, level: Level) {
|
||||
/// Checks the validity of lint names derived from the command line. Returns
|
||||
/// true if the lint is valid, false otherwise.
|
||||
pub fn check_lint_name_cmdline(
|
||||
&self,
|
||||
sess: &Session,
|
||||
lint_name: &str,
|
||||
level: Option<Level>,
|
||||
) -> bool {
|
||||
let db = match self.check_lint_name(lint_name, None) {
|
||||
CheckLintNameResult::Ok(_) => None,
|
||||
CheckLintNameResult::Warning(ref msg, _) => Some(sess.struct_warn(msg)),
|
||||
|
@ -361,18 +367,23 @@ impl LintStore {
|
|||
};
|
||||
|
||||
if let Some(mut db) = db {
|
||||
let msg = format!(
|
||||
"requested on the command line with `{} {}`",
|
||||
match level {
|
||||
Level::Allow => "-A",
|
||||
Level::Warn => "-W",
|
||||
Level::Deny => "-D",
|
||||
Level::Forbid => "-F",
|
||||
},
|
||||
lint_name
|
||||
);
|
||||
db.note(&msg);
|
||||
if let Some(level) = level {
|
||||
let msg = format!(
|
||||
"requested on the command line with `{} {}`",
|
||||
match level {
|
||||
Level::Allow => "-A",
|
||||
Level::Warn => "-W",
|
||||
Level::Deny => "-D",
|
||||
Level::Forbid => "-F",
|
||||
},
|
||||
lint_name
|
||||
);
|
||||
db.note(&msg);
|
||||
}
|
||||
db.emit();
|
||||
false
|
||||
} else {
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -88,7 +88,7 @@ impl<'s> LintLevelsBuilder<'s> {
|
|||
self.sets.lint_cap = sess.opts.lint_cap.unwrap_or(Level::Forbid);
|
||||
|
||||
for &(ref lint_name, level) in &sess.opts.lint_opts {
|
||||
store.check_lint_name_cmdline(sess, &lint_name, level);
|
||||
store.check_lint_name_cmdline(sess, &lint_name, Some(level));
|
||||
let orig_level = level;
|
||||
|
||||
// If the cap is less than this specified level, e.g., if we've got
|
||||
|
@ -110,8 +110,13 @@ impl<'s> LintLevelsBuilder<'s> {
|
|||
}
|
||||
|
||||
for lint_name in &sess.opts.force_warns {
|
||||
store.check_lint_name_cmdline(sess, &lint_name, Level::Allow); // FIXME level is wrong
|
||||
self.sets.force_warns.insert(lint_name.to_uppercase());
|
||||
let valid = store.check_lint_name_cmdline(sess, lint_name, None);
|
||||
if valid {
|
||||
let lints = store
|
||||
.find_lints(lint_name)
|
||||
.unwrap_or_else(|_| bug!("A valid lint failed to produce a lint ids"));
|
||||
self.sets.force_warns.extend(&lints);
|
||||
}
|
||||
}
|
||||
|
||||
self.sets.list.push(LintSet::CommandLine { specs });
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue