Add tests for command line lint control

This commit is contained in:
inquisitivecrystal 2021-07-08 21:35:26 -07:00
parent 2f2db99432
commit 10cb380766
6 changed files with 72 additions and 0 deletions

View File

@ -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

View File

@ -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

View File

@ -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() {}

View File

@ -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

View File

@ -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() {}

View File

@ -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`.