-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Detect unused structs which derived Default
- Loading branch information
Showing
5 changed files
with
43 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#![deny(dead_code)] | ||
|
||
#[derive(Default)] | ||
struct T; //~ ERROR struct `T` is never constructed | ||
|
||
#[derive(Default)] | ||
struct Used; | ||
|
||
fn main() { | ||
let _x: Used = Default::default(); | ||
} |
15 changes: 15 additions & 0 deletions
15
tests/ui/lint/dead-code/unused-struct-derive-default.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
error: struct `T` is never constructed | ||
--> $DIR/unused-struct-derive-default.rs:4:8 | ||
| | ||
LL | struct T; | ||
| ^ | ||
| | ||
= note: `T` has a derived impl for the trait `Default`, but this is intentionally ignored during dead code analysis | ||
note: the lint level is defined here | ||
--> $DIR/unused-struct-derive-default.rs:1:9 | ||
| | ||
LL | #![deny(dead_code)] | ||
| ^^^^^^^^^ | ||
|
||
error: aborting due to 1 previous error | ||
|