about summary refs log tree commit diff
diff options
context:
space:
mode:
authorWeihang Lo <me@weihanglo.tw>2023-08-30 14:19:53 +0100
committerWeihang Lo <me@weihanglo.tw>2023-08-30 15:10:35 +0100
commitecff1c012e9e78a0a85ece64a0823ef69fc56363 (patch)
tree1191c9523eaf22cc12da7e4a1f5d22f3b09f8649
parent61efe9d2981b87ec7f2800d62f98c594de151713 (diff)
downloadrust-ecff1c012e9e78a0a85ece64a0823ef69fc56363.tar.gz
rust-ecff1c012e9e78a0a85ece64a0823ef69fc56363.zip
test(ui/lint): demonstrate the current cmdline lint behavior
This demonstrates the current behavior of adding lint form the command
line. generally the lint levels are ignored as the current implementation
unconditionally emit errors for those lints.
-rw-r--r--tests/ui/lint/lint-removed-cmdline-deny.rs12
-rw-r--r--tests/ui/lint/lint-removed-cmdline-deny.stderr27
-rw-r--r--tests/ui/lint/lint-renamed-cmdline-deny.rs8
-rw-r--r--tests/ui/lint/lint-renamed-cmdline-deny.stderr27
-rw-r--r--tests/ui/lint/lint-unknown-lint-cmdline-allow.rs3
-rw-r--r--tests/ui/lint/lint-unknown-lint-cmdline-allow.stderr21
-rw-r--r--tests/ui/lint/lint-unknown-lint-cmdline-deny.rs8
-rw-r--r--tests/ui/lint/lint-unknown-lint-cmdline-deny.stderr21
8 files changed, 127 insertions, 0 deletions
diff --git a/tests/ui/lint/lint-removed-cmdline-deny.rs b/tests/ui/lint/lint-removed-cmdline-deny.rs
new file mode 100644
index 00000000000..82dce61869b
--- /dev/null
+++ b/tests/ui/lint/lint-removed-cmdline-deny.rs
@@ -0,0 +1,12 @@
+// The raw_pointer_derived lint warns about its removal
+// cc #30346
+
+// compile-flags:-D renamed-and-removed-lints -D raw_pointer_derive
+
+// error-pattern:lint `raw_pointer_derive` has been removed
+// error-pattern:requested on the command line with `-D raw_pointer_derive`
+
+#![warn(unused)]
+
+#[deny(warnings)]
+fn main() { let unused = (); }
diff --git a/tests/ui/lint/lint-removed-cmdline-deny.stderr b/tests/ui/lint/lint-removed-cmdline-deny.stderr
new file mode 100644
index 00000000000..61bf9890d49
--- /dev/null
+++ b/tests/ui/lint/lint-removed-cmdline-deny.stderr
@@ -0,0 +1,27 @@
+warning: lint `raw_pointer_derive` has been removed: using derive with raw pointers is ok
+   |
+   = note: requested on the command line with `-D raw_pointer_derive`
+
+warning: lint `raw_pointer_derive` has been removed: using derive with raw pointers is ok
+   |
+   = note: requested on the command line with `-D raw_pointer_derive`
+
+warning: lint `raw_pointer_derive` has been removed: using derive with raw pointers is ok
+   |
+   = note: requested on the command line with `-D raw_pointer_derive`
+
+error: unused variable: `unused`
+  --> $DIR/lint-removed-cmdline-deny.rs:12:17
+   |
+LL | fn main() { let unused = (); }
+   |                 ^^^^^^ help: if this is intentional, prefix it with an underscore: `_unused`
+   |
+note: the lint level is defined here
+  --> $DIR/lint-removed-cmdline-deny.rs:11:8
+   |
+LL | #[deny(warnings)]
+   |        ^^^^^^^^
+   = note: `#[deny(unused_variables)]` implied by `#[deny(warnings)]`
+
+error: aborting due to previous error; 3 warnings emitted
+
diff --git a/tests/ui/lint/lint-renamed-cmdline-deny.rs b/tests/ui/lint/lint-renamed-cmdline-deny.rs
new file mode 100644
index 00000000000..f313ffd4254
--- /dev/null
+++ b/tests/ui/lint/lint-renamed-cmdline-deny.rs
@@ -0,0 +1,8 @@
+// compile-flags:-D renamed-and-removed-lints -D bare_trait_object
+
+// error-pattern:lint `bare_trait_object` has been renamed to `bare_trait_objects`
+// error-pattern:requested on the command line with `-D bare_trait_object`
+// error-pattern:unused
+
+#[deny(unused)]
+fn main() { let unused = (); }
diff --git a/tests/ui/lint/lint-renamed-cmdline-deny.stderr b/tests/ui/lint/lint-renamed-cmdline-deny.stderr
new file mode 100644
index 00000000000..2b360e5f3d8
--- /dev/null
+++ b/tests/ui/lint/lint-renamed-cmdline-deny.stderr
@@ -0,0 +1,27 @@
+warning: lint `bare_trait_object` has been renamed to `bare_trait_objects`
+   |
+   = note: requested on the command line with `-D bare_trait_object`
+
+warning: lint `bare_trait_object` has been renamed to `bare_trait_objects`
+   |
+   = note: requested on the command line with `-D bare_trait_object`
+
+warning: lint `bare_trait_object` has been renamed to `bare_trait_objects`
+   |
+   = note: requested on the command line with `-D bare_trait_object`
+
+error: unused variable: `unused`
+  --> $DIR/lint-renamed-cmdline-deny.rs:8:17
+   |
+LL | fn main() { let unused = (); }
+   |                 ^^^^^^ help: if this is intentional, prefix it with an underscore: `_unused`
+   |
+note: the lint level is defined here
+  --> $DIR/lint-renamed-cmdline-deny.rs:7:8
+   |
+LL | #[deny(unused)]
+   |        ^^^^^^
+   = note: `#[deny(unused_variables)]` implied by `#[deny(unused)]`
+
+error: aborting due to previous error; 3 warnings emitted
+
diff --git a/tests/ui/lint/lint-unknown-lint-cmdline-allow.rs b/tests/ui/lint/lint-unknown-lint-cmdline-allow.rs
new file mode 100644
index 00000000000..7549d076710
--- /dev/null
+++ b/tests/ui/lint/lint-unknown-lint-cmdline-allow.rs
@@ -0,0 +1,3 @@
+// compile-flags:-A unknown-lints -D bogus -D dead_cod
+
+fn main() { }
diff --git a/tests/ui/lint/lint-unknown-lint-cmdline-allow.stderr b/tests/ui/lint/lint-unknown-lint-cmdline-allow.stderr
new file mode 100644
index 00000000000..3855d552792
--- /dev/null
+++ b/tests/ui/lint/lint-unknown-lint-cmdline-allow.stderr
@@ -0,0 +1,21 @@
+error[E0602]: unknown lint: `bogus`
+   |
+   = note: requested on the command line with `-D bogus`
+
+error[E0602]: unknown lint: `dead_cod`
+   |
+   = help: did you mean: `dead_code`
+   = note: requested on the command line with `-D dead_cod`
+
+error[E0602]: unknown lint: `bogus`
+   |
+   = note: requested on the command line with `-D bogus`
+
+error[E0602]: unknown lint: `dead_cod`
+   |
+   = help: did you mean: `dead_code`
+   = note: requested on the command line with `-D dead_cod`
+
+error: aborting due to 4 previous errors
+
+For more information about this error, try `rustc --explain E0602`.
diff --git a/tests/ui/lint/lint-unknown-lint-cmdline-deny.rs b/tests/ui/lint/lint-unknown-lint-cmdline-deny.rs
new file mode 100644
index 00000000000..461984239a8
--- /dev/null
+++ b/tests/ui/lint/lint-unknown-lint-cmdline-deny.rs
@@ -0,0 +1,8 @@
+// compile-flags:-D unknown-lints -D bogus -D dead_cod
+
+// error-pattern:unknown lint: `bogus`
+// error-pattern:requested on the command line with `-D bogus`
+// error-pattern:requested on the command line with `-D dead_cod`
+// error-pattern:did you mean: `dead_code`
+
+fn main() { }
diff --git a/tests/ui/lint/lint-unknown-lint-cmdline-deny.stderr b/tests/ui/lint/lint-unknown-lint-cmdline-deny.stderr
new file mode 100644
index 00000000000..3855d552792
--- /dev/null
+++ b/tests/ui/lint/lint-unknown-lint-cmdline-deny.stderr
@@ -0,0 +1,21 @@
+error[E0602]: unknown lint: `bogus`
+   |
+   = note: requested on the command line with `-D bogus`
+
+error[E0602]: unknown lint: `dead_cod`
+   |
+   = help: did you mean: `dead_code`
+   = note: requested on the command line with `-D dead_cod`
+
+error[E0602]: unknown lint: `bogus`
+   |
+   = note: requested on the command line with `-D bogus`
+
+error[E0602]: unknown lint: `dead_cod`
+   |
+   = help: did you mean: `dead_code`
+   = note: requested on the command line with `-D dead_cod`
+
+error: aborting due to 4 previous errors
+
+For more information about this error, try `rustc --explain E0602`.