Skip to content

Commit 2373599

Browse files
committed
Add tests for --json unused-externs
There were none at all. These test for original functionality, but this also adds a test that `-Dunused-crate-dependencies` causes a compilation failure, which currently fails (rust-lang#96068). This is fixed in subsequent changes.
1 parent 0981b98 commit 2373599

8 files changed

+58
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// Check for unused crate dep, no path
2+
3+
// edition:2018
4+
// aux-crate:bar=bar.rs
5+
6+
#![deny(unused_crate_dependencies)]
7+
//~^ ERROR external crate `bar` unused in
8+
9+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
error: external crate `bar` unused in `deny_attr`: remove the dependency or add `use bar as _;`
2+
--> $DIR/deny-attr.rs:6:1
3+
|
4+
LL | #![deny(unused_crate_dependencies)]
5+
| ^
6+
|
7+
note: the lint level is defined here
8+
--> $DIR/deny-attr.rs:6:9
9+
|
10+
LL | #![deny(unused_crate_dependencies)]
11+
| ^^^^^^^^^^^^^^^^^^^^^^^^^
12+
13+
error: aborting due to previous error
14+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// Check for unused crate dep, no path
2+
3+
// edition:2018
4+
// compile-flags: -Dunused-crate-dependencies -Zunstable-options --json unused-externs --error-format=json
5+
// aux-crate:bar=bar.rs
6+
7+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"lint_level":"deny","unused_extern_names":["bar"]}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// Check for unused crate dep, no path
2+
3+
// edition:2018
4+
// compile-flags: -Dunused-crate-dependencies
5+
// aux-crate:bar=bar.rs
6+
7+
fn main() {}
8+
//~^ ERROR external crate `bar` unused in
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
error: external crate `bar` unused in `deny_cmdline`: remove the dependency or add `use bar as _;`
2+
--> $DIR/deny-cmdline.rs:7:1
3+
|
4+
LL | fn main() {}
5+
| ^
6+
|
7+
= note: requested on the command line with `-D unused-crate-dependencies`
8+
9+
error: aborting due to previous error
10+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// Check for unused crate dep, no path
2+
3+
// edition:2018
4+
// check-pass
5+
// compile-flags: -Wunused-crate-dependencies -Zunstable-options --json unused-externs --error-format=json
6+
// aux-crate:bar=bar.rs
7+
8+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"lint_level":"warn","unused_extern_names":["bar"]}

0 commit comments

Comments
 (0)