Error when warnings lint group is used with force-warn

This commit is contained in:
Ryan Levick 2021-08-18 11:53:59 +02:00
parent 0d2fd70dab
commit d70056e30c
4 changed files with 25 additions and 2 deletions

View File

@ -1,4 +1,4 @@
An unknown lint was used on the command line.
An unknown or invalid lint was used on the command line.
Erroneous code example:

View File

@ -332,7 +332,16 @@ impl LintStore {
crate_attrs: &[ast::Attribute],
) {
let (tool_name, lint_name_only) = parse_lint_and_tool_name(lint_name);
if lint_name_only == crate::WARNINGS.name_lower() && level == Level::ForceWarn {
return struct_span_err!(
sess,
DUMMY_SP,
E0602,
"`{}` lint group is not supported with ´--force-warn´",
crate::WARNINGS.name_lower()
)
.emit();
}
let db = match self.check_lint_name(sess, lint_name_only, tool_name, crate_attrs) {
CheckLintNameResult::Ok(_) => None,
CheckLintNameResult::Warning(ref msg, _) => Some(sess.struct_warn(msg)),

View File

@ -0,0 +1,5 @@
// --force-warn warnings is an error
// compile-flags: --force-warn warnings -Zunstable-options
// error-pattern: `warnings` lint group is not supported
fn main() {}

View File

@ -0,0 +1,9 @@
error[E0602]: `warnings` lint group is not supported with ´--force-warn´
error[E0602]: `warnings` lint group is not supported with ´--force-warn´
error[E0602]: `warnings` lint group is not supported with ´--force-warn´
error: aborting due to 3 previous errors
For more information about this error, try `rustc --explain E0602`.