about summary refs log tree commit diff
diff options
context:
space:
mode:
authorRyan Levick <me@ryanlevick.com>2021-08-18 11:53:59 +0200
committerRyan Levick <me@ryanlevick.com>2021-08-18 11:53:59 +0200
commitd70056e30c9253f42eb12f1030b4977a2a6bc688 (patch)
treef4ba893e1525539675ec42c48a709bd464c1dd3f
parent0d2fd70dab06a833374f52db33332d4b2ad2566f (diff)
downloadrust-d70056e30c9253f42eb12f1030b4977a2a6bc688.tar.gz
rust-d70056e30c9253f42eb12f1030b4977a2a6bc688.zip
Error when warnings lint group is used with force-warn
-rw-r--r--compiler/rustc_error_codes/src/error_codes/E0602.md2
-rw-r--r--compiler/rustc_lint/src/context.rs11
-rw-r--r--src/test/ui/lint/force-warn/warnings-lint-group.rs5
-rw-r--r--src/test/ui/lint/force-warn/warnings-lint-group.stderr9
4 files changed, 25 insertions, 2 deletions
diff --git a/compiler/rustc_error_codes/src/error_codes/E0602.md b/compiler/rustc_error_codes/src/error_codes/E0602.md
index dcaf251a96b..7980b704cae 100644
--- a/compiler/rustc_error_codes/src/error_codes/E0602.md
+++ b/compiler/rustc_error_codes/src/error_codes/E0602.md
@@ -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:
 
diff --git a/compiler/rustc_lint/src/context.rs b/compiler/rustc_lint/src/context.rs
index 47c6e904cd7..c2a46e997df 100644
--- a/compiler/rustc_lint/src/context.rs
+++ b/compiler/rustc_lint/src/context.rs
@@ -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)),
diff --git a/src/test/ui/lint/force-warn/warnings-lint-group.rs b/src/test/ui/lint/force-warn/warnings-lint-group.rs
new file mode 100644
index 00000000000..fa25a1f8a84
--- /dev/null
+++ b/src/test/ui/lint/force-warn/warnings-lint-group.rs
@@ -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() {}
diff --git a/src/test/ui/lint/force-warn/warnings-lint-group.stderr b/src/test/ui/lint/force-warn/warnings-lint-group.stderr
new file mode 100644
index 00000000000..03f5788b527
--- /dev/null
+++ b/src/test/ui/lint/force-warn/warnings-lint-group.stderr
@@ -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`.