diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2024-06-25 18:02:58 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-06-25 18:02:58 +0200 |
| commit | 2724aeaaeb127a8073e39461caacbe21a128ce7b (patch) | |
| tree | 4f8765a6fa568cc9f487f6e3c6238d2859e1293a /tests/ui/lint/dead-code | |
| parent | d929a42a664c026167800801b26d734db925314f (diff) | |
| parent | a264bff9d557e9fc468c9fefeabc0c09d4eeea6f (diff) | |
| download | rust-2724aeaaeb127a8073e39461caacbe21a128ce7b.tar.gz rust-2724aeaaeb127a8073e39461caacbe21a128ce7b.zip | |
Rollup merge of #126618 - mu001999-contrib:dead/enhance, r=pnkfelix
Mark assoc tys live only if the corresponding trait is live r? ````@pnkfelix````
Diffstat (limited to 'tests/ui/lint/dead-code')
| -rw-r--r-- | tests/ui/lint/dead-code/unused-trait-with-assoc-ty.rs | 11 | ||||
| -rw-r--r-- | tests/ui/lint/dead-code/unused-trait-with-assoc-ty.stderr | 20 |
2 files changed, 31 insertions, 0 deletions
diff --git a/tests/ui/lint/dead-code/unused-trait-with-assoc-ty.rs b/tests/ui/lint/dead-code/unused-trait-with-assoc-ty.rs new file mode 100644 index 00000000000..e8116d83ebf --- /dev/null +++ b/tests/ui/lint/dead-code/unused-trait-with-assoc-ty.rs @@ -0,0 +1,11 @@ +#![deny(dead_code)] + +struct T1; //~ ERROR struct `T1` is never constructed + +trait Foo { type Unused; } //~ ERROR trait `Foo` is never used +impl Foo for T1 { type Unused = Self; } + +pub trait Bar { type Used; } +impl Bar for T1 { type Used = Self; } + +fn main() {} diff --git a/tests/ui/lint/dead-code/unused-trait-with-assoc-ty.stderr b/tests/ui/lint/dead-code/unused-trait-with-assoc-ty.stderr new file mode 100644 index 00000000000..ab73c640634 --- /dev/null +++ b/tests/ui/lint/dead-code/unused-trait-with-assoc-ty.stderr @@ -0,0 +1,20 @@ +error: struct `T1` is never constructed + --> $DIR/unused-trait-with-assoc-ty.rs:3:8 + | +LL | struct T1; + | ^^ + | +note: the lint level is defined here + --> $DIR/unused-trait-with-assoc-ty.rs:1:9 + | +LL | #![deny(dead_code)] + | ^^^^^^^^^ + +error: trait `Foo` is never used + --> $DIR/unused-trait-with-assoc-ty.rs:5:7 + | +LL | trait Foo { type Unused; } + | ^^^ + +error: aborting due to 2 previous errors + |
