Skip to content

Commit 10cb380

Browse files
Add tests for command line lint control
1 parent 2f2db99 commit 10cb380

6 files changed

+72
-0
lines changed
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
error: extern declarations without an explicit ABI are deprecated
2+
--> $DIR/cli-lint-override.rs:12:1
3+
|
4+
LL | extern fn foo() {}
5+
| ^^^^^^^^^^^^^^^ ABI should be specified here
6+
|
7+
= note: requested on the command line with `-F missing-abi`
8+
= help: the default ABI is C
9+
10+
error: aborting due to previous error
11+
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
warning: extern declarations without an explicit ABI are deprecated
2+
--> $DIR/cli-lint-override.rs:12:1
3+
|
4+
LL | extern fn foo() {}
5+
| ^^^^^^^^^^^^^^^ ABI should be specified here
6+
|
7+
= note: requested on the command line with `--force-warns missing-abi`
8+
= help: the default ABI is C
9+
10+
warning: 1 warning emitted
11+

Diff for: src/test/ui/lint/cli-lint-override.rs

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Tests that subsequent lints specified via the command line override
2+
// each other, except for ForceWarn and Forbid, which cannot be overriden.
3+
//
4+
// revisions: warn_deny forbid_warn force_warn_deny
5+
//
6+
//[warn_deny] compile-flags: --warn missing_abi --deny missing_abi
7+
//[forbid_warn] compile-flags: --warn missing_abi --forbid missing_abi
8+
//[force_warn_deny] compile-flags: -Z unstable-options --force-warns missing_abi --allow missing_abi
9+
//[force_warn_deny] check-pass
10+
11+
12+
extern fn foo() {}
13+
//[warn_deny]~^ ERROR extern declarations without an explicit ABI are deprecated
14+
//[forbid_warn]~^^ ERROR extern declarations without an explicit ABI are deprecated
15+
//[force_warn_deny]~^^^ WARN extern declarations without an explicit ABI are deprecated
16+
17+
fn main() {}

Diff for: src/test/ui/lint/cli-lint-override.warn_deny.stderr

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
error: extern declarations without an explicit ABI are deprecated
2+
--> $DIR/cli-lint-override.rs:12:1
3+
|
4+
LL | extern fn foo() {}
5+
| ^^^^^^^^^^^^^^^ ABI should be specified here
6+
|
7+
= note: requested on the command line with `-D missing-abi`
8+
= help: the default ABI is C
9+
10+
error: aborting due to previous error
11+

Diff for: src/test/ui/lint/cli-unknown-force-warn.rs

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// Checks that rustc correctly errors when passed an invalid lint with
2+
// `--force-warns`. This is a regression test for issue #86958.
3+
//
4+
// compile-flags: -Z unstable-options --force-warns foo-qux
5+
// error-pattern: unknown lint: `foo_qux`
6+
7+
fn main() {}

Diff for: src/test/ui/lint/cli-unknown-force-warn.stderr

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
error[E0602]: unknown lint: `foo_qux`
2+
|
3+
= note: requested on the command line with `--force-warns foo_qux`
4+
5+
error[E0602]: unknown lint: `foo_qux`
6+
|
7+
= note: requested on the command line with `--force-warns foo_qux`
8+
9+
error[E0602]: unknown lint: `foo_qux`
10+
|
11+
= note: requested on the command line with `--force-warns foo_qux`
12+
13+
error: aborting due to 3 previous errors
14+
15+
For more information about this error, try `rustc --explain E0602`.

0 commit comments

Comments
 (0)