From ecff1c012e9e78a0a85ece64a0823ef69fc56363 Mon Sep 17 00:00:00 2001 From: Weihang Lo Date: Wed, 30 Aug 2023 14:19:53 +0100 Subject: [PATCH] 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. --- tests/ui/lint/lint-removed-cmdline-deny.rs | 12 +++++++++ .../ui/lint/lint-removed-cmdline-deny.stderr | 27 +++++++++++++++++++ tests/ui/lint/lint-renamed-cmdline-deny.rs | 8 ++++++ .../ui/lint/lint-renamed-cmdline-deny.stderr | 27 +++++++++++++++++++ .../lint/lint-unknown-lint-cmdline-allow.rs | 3 +++ .../lint-unknown-lint-cmdline-allow.stderr | 21 +++++++++++++++ .../ui/lint/lint-unknown-lint-cmdline-deny.rs | 8 ++++++ .../lint-unknown-lint-cmdline-deny.stderr | 21 +++++++++++++++ 8 files changed, 127 insertions(+) create mode 100644 tests/ui/lint/lint-removed-cmdline-deny.rs create mode 100644 tests/ui/lint/lint-removed-cmdline-deny.stderr create mode 100644 tests/ui/lint/lint-renamed-cmdline-deny.rs create mode 100644 tests/ui/lint/lint-renamed-cmdline-deny.stderr create mode 100644 tests/ui/lint/lint-unknown-lint-cmdline-allow.rs create mode 100644 tests/ui/lint/lint-unknown-lint-cmdline-allow.stderr create mode 100644 tests/ui/lint/lint-unknown-lint-cmdline-deny.rs create mode 100644 tests/ui/lint/lint-unknown-lint-cmdline-deny.stderr 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`.