Skip to content

Commit d70056e

Browse files
committed
Error when warnings lint group is used with force-warn
1 parent 0d2fd70 commit d70056e

File tree

4 files changed

+25
-2
lines changed

4 files changed

+25
-2
lines changed

compiler/rustc_error_codes/src/error_codes/E0602.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
An unknown lint was used on the command line.
1+
An unknown or invalid lint was used on the command line.
22

33
Erroneous code example:
44

compiler/rustc_lint/src/context.rs

+10-1
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,16 @@ impl LintStore {
332332
crate_attrs: &[ast::Attribute],
333333
) {
334334
let (tool_name, lint_name_only) = parse_lint_and_tool_name(lint_name);
335-
335+
if lint_name_only == crate::WARNINGS.name_lower() && level == Level::ForceWarn {
336+
return struct_span_err!(
337+
sess,
338+
DUMMY_SP,
339+
E0602,
340+
"`{}` lint group is not supported with ´--force-warn´",
341+
crate::WARNINGS.name_lower()
342+
)
343+
.emit();
344+
}
336345
let db = match self.check_lint_name(sess, lint_name_only, tool_name, crate_attrs) {
337346
CheckLintNameResult::Ok(_) => None,
338347
CheckLintNameResult::Warning(ref msg, _) => Some(sess.struct_warn(msg)),
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// --force-warn warnings is an error
2+
// compile-flags: --force-warn warnings -Zunstable-options
3+
// error-pattern: `warnings` lint group is not supported
4+
5+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
error[E0602]: `warnings` lint group is not supported with ´--force-warn´
2+
3+
error[E0602]: `warnings` lint group is not supported with ´--force-warn´
4+
5+
error[E0602]: `warnings` lint group is not supported with ´--force-warn´
6+
7+
error: aborting due to 3 previous errors
8+
9+
For more information about this error, try `rustc --explain E0602`.

0 commit comments

Comments
 (0)