From 10cb38076645ad113617ad868beab08f3bc2c280 Mon Sep 17 00:00:00 2001 From: inquisitivecrystal <22333129+inquisitivecrystal@users.noreply.github.com> Date: Thu, 8 Jul 2021 21:35:26 -0700 Subject: [PATCH] Add tests for command line lint control --- .../lint/cli-lint-override.forbid_warn.stderr | 11 +++++++++++ .../cli-lint-override.force_warn_deny.stderr | 11 +++++++++++ src/test/ui/lint/cli-lint-override.rs | 17 +++++++++++++++++ .../ui/lint/cli-lint-override.warn_deny.stderr | 11 +++++++++++ src/test/ui/lint/cli-unknown-force-warn.rs | 7 +++++++ src/test/ui/lint/cli-unknown-force-warn.stderr | 15 +++++++++++++++ 6 files changed, 72 insertions(+) create mode 100644 src/test/ui/lint/cli-lint-override.forbid_warn.stderr create mode 100644 src/test/ui/lint/cli-lint-override.force_warn_deny.stderr create mode 100644 src/test/ui/lint/cli-lint-override.rs create mode 100644 src/test/ui/lint/cli-lint-override.warn_deny.stderr create mode 100644 src/test/ui/lint/cli-unknown-force-warn.rs create mode 100644 src/test/ui/lint/cli-unknown-force-warn.stderr diff --git a/src/test/ui/lint/cli-lint-override.forbid_warn.stderr b/src/test/ui/lint/cli-lint-override.forbid_warn.stderr new file mode 100644 index 00000000000..ff4dc4abc74 --- /dev/null +++ b/src/test/ui/lint/cli-lint-override.forbid_warn.stderr @@ -0,0 +1,11 @@ +error: extern declarations without an explicit ABI are deprecated + --> $DIR/cli-lint-override.rs:12:1 + | +LL | extern fn foo() {} + | ^^^^^^^^^^^^^^^ ABI should be specified here + | + = note: requested on the command line with `-F missing-abi` + = help: the default ABI is C + +error: aborting due to previous error + diff --git a/src/test/ui/lint/cli-lint-override.force_warn_deny.stderr b/src/test/ui/lint/cli-lint-override.force_warn_deny.stderr new file mode 100644 index 00000000000..50c58ea6e15 --- /dev/null +++ b/src/test/ui/lint/cli-lint-override.force_warn_deny.stderr @@ -0,0 +1,11 @@ +warning: extern declarations without an explicit ABI are deprecated + --> $DIR/cli-lint-override.rs:12:1 + | +LL | extern fn foo() {} + | ^^^^^^^^^^^^^^^ ABI should be specified here + | + = note: requested on the command line with `--force-warns missing-abi` + = help: the default ABI is C + +warning: 1 warning emitted + diff --git a/src/test/ui/lint/cli-lint-override.rs b/src/test/ui/lint/cli-lint-override.rs new file mode 100644 index 00000000000..6814c15e656 --- /dev/null +++ b/src/test/ui/lint/cli-lint-override.rs @@ -0,0 +1,17 @@ +// Tests that subsequent lints specified via the command line override +// each other, except for ForceWarn and Forbid, which cannot be overriden. +// +// revisions: warn_deny forbid_warn force_warn_deny +// +//[warn_deny] compile-flags: --warn missing_abi --deny missing_abi +//[forbid_warn] compile-flags: --warn missing_abi --forbid missing_abi +//[force_warn_deny] compile-flags: -Z unstable-options --force-warns missing_abi --allow missing_abi +//[force_warn_deny] check-pass + + +extern fn foo() {} +//[warn_deny]~^ ERROR extern declarations without an explicit ABI are deprecated +//[forbid_warn]~^^ ERROR extern declarations without an explicit ABI are deprecated +//[force_warn_deny]~^^^ WARN extern declarations without an explicit ABI are deprecated + +fn main() {} diff --git a/src/test/ui/lint/cli-lint-override.warn_deny.stderr b/src/test/ui/lint/cli-lint-override.warn_deny.stderr new file mode 100644 index 00000000000..2d869adfd37 --- /dev/null +++ b/src/test/ui/lint/cli-lint-override.warn_deny.stderr @@ -0,0 +1,11 @@ +error: extern declarations without an explicit ABI are deprecated + --> $DIR/cli-lint-override.rs:12:1 + | +LL | extern fn foo() {} + | ^^^^^^^^^^^^^^^ ABI should be specified here + | + = note: requested on the command line with `-D missing-abi` + = help: the default ABI is C + +error: aborting due to previous error + diff --git a/src/test/ui/lint/cli-unknown-force-warn.rs b/src/test/ui/lint/cli-unknown-force-warn.rs new file mode 100644 index 00000000000..201161296ba --- /dev/null +++ b/src/test/ui/lint/cli-unknown-force-warn.rs @@ -0,0 +1,7 @@ +// Checks that rustc correctly errors when passed an invalid lint with +// `--force-warns`. This is a regression test for issue #86958. +// +// compile-flags: -Z unstable-options --force-warns foo-qux +// error-pattern: unknown lint: `foo_qux` + +fn main() {} diff --git a/src/test/ui/lint/cli-unknown-force-warn.stderr b/src/test/ui/lint/cli-unknown-force-warn.stderr new file mode 100644 index 00000000000..3a9aebb996c --- /dev/null +++ b/src/test/ui/lint/cli-unknown-force-warn.stderr @@ -0,0 +1,15 @@ +error[E0602]: unknown lint: `foo_qux` + | + = note: requested on the command line with `--force-warns foo_qux` + +error[E0602]: unknown lint: `foo_qux` + | + = note: requested on the command line with `--force-warns foo_qux` + +error[E0602]: unknown lint: `foo_qux` + | + = note: requested on the command line with `--force-warns foo_qux` + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0602`.