add test for duplicate warning on used deprecated unit structs

Co-authored-by: Waffle Lapkin <waffle.lapkin@gmail.com>
This commit is contained in:
Jana Dönszelmann 2025-10-22 16:54:07 +02:00
parent df984edf44
commit c6a8c46b6c
No known key found for this signature in database
2 changed files with 154 additions and 0 deletions

View file

@ -0,0 +1,50 @@
#![deny(deprecated)]
#![allow(unused_imports)]
#[deprecated]
pub mod a {
pub struct Foo;
pub struct Bar();
pub struct Baz {}
pub enum Enum {
VFoo,
VBar(),
VBaz {},
}
}
use a::Foo;
//~^ ERROR use of deprecated struct `a::Foo`
//~| ERROR use of deprecated unit struct `a::Foo`
use a::Bar;
//~^ ERROR use of deprecated struct `a::Bar`
//~| ERROR use of deprecated tuple struct `a::Bar`
use a::Baz;
//~^ ERROR use of deprecated struct `a::Baz`
use a::Enum::VFoo;
//~^ ERROR use of deprecated variant `a::Enum::VFoo`
//~| ERROR use of deprecated unit variant `a::Enum::VFoo`
use a::Enum::VBar;
//~^ ERROR use of deprecated variant `a::Enum::VBar`
//~| ERROR use of deprecated tuple variant `a::Enum::VBar`
use a::Enum::VBaz;
//~^ ERROR use of deprecated variant `a::Enum::VBaz`
fn main() {
a::Foo;
//~^ ERROR use of deprecated unit struct `a::Foo`
a::Bar();
//~^ ERROR use of deprecated tuple struct `a::Bar`
a::Baz {};
//~^ ERROR use of deprecated struct `a::Baz`
a::Enum::VFoo;
//~^ ERROR use of deprecated unit variant `a::Enum::VFoo`
a::Enum::VBar();
//~^ ERROR use of deprecated tuple variant `a::Enum::VBar`
a::Enum::VBaz{};
//~^ ERROR use of deprecated variant `a::Enum::VBaz`
}

View file

@ -0,0 +1,104 @@
error: use of deprecated struct `a::Foo`
--> $DIR/unit_and_tuple_struct.rs:18:8
|
LL | use a::Foo;
| ^^^
|
note: the lint level is defined here
--> $DIR/unit_and_tuple_struct.rs:1:9
|
LL | #![deny(deprecated)]
| ^^^^^^^^^^
error: use of deprecated unit struct `a::Foo`
--> $DIR/unit_and_tuple_struct.rs:18:8
|
LL | use a::Foo;
| ^^^
error: use of deprecated struct `a::Bar`
--> $DIR/unit_and_tuple_struct.rs:21:8
|
LL | use a::Bar;
| ^^^
error: use of deprecated tuple struct `a::Bar`
--> $DIR/unit_and_tuple_struct.rs:21:8
|
LL | use a::Bar;
| ^^^
error: use of deprecated struct `a::Baz`
--> $DIR/unit_and_tuple_struct.rs:24:8
|
LL | use a::Baz;
| ^^^
error: use of deprecated variant `a::Enum::VFoo`
--> $DIR/unit_and_tuple_struct.rs:27:14
|
LL | use a::Enum::VFoo;
| ^^^^
error: use of deprecated unit variant `a::Enum::VFoo`
--> $DIR/unit_and_tuple_struct.rs:27:14
|
LL | use a::Enum::VFoo;
| ^^^^
error: use of deprecated variant `a::Enum::VBar`
--> $DIR/unit_and_tuple_struct.rs:30:14
|
LL | use a::Enum::VBar;
| ^^^^
error: use of deprecated tuple variant `a::Enum::VBar`
--> $DIR/unit_and_tuple_struct.rs:30:14
|
LL | use a::Enum::VBar;
| ^^^^
error: use of deprecated variant `a::Enum::VBaz`
--> $DIR/unit_and_tuple_struct.rs:33:14
|
LL | use a::Enum::VBaz;
| ^^^^
error: use of deprecated unit struct `a::Foo`
--> $DIR/unit_and_tuple_struct.rs:37:6
|
LL | a::Foo;
| ^^^
error: use of deprecated tuple struct `a::Bar`
--> $DIR/unit_and_tuple_struct.rs:39:6
|
LL | a::Bar();
| ^^^
error: use of deprecated struct `a::Baz`
--> $DIR/unit_and_tuple_struct.rs:41:6
|
LL | a::Baz {};
| ^^^
error: use of deprecated unit variant `a::Enum::VFoo`
--> $DIR/unit_and_tuple_struct.rs:44:12
|
LL | a::Enum::VFoo;
| ^^^^
error: use of deprecated tuple variant `a::Enum::VBar`
--> $DIR/unit_and_tuple_struct.rs:46:12
|
LL | a::Enum::VBar();
| ^^^^
error: use of deprecated variant `a::Enum::VBaz`
--> $DIR/unit_and_tuple_struct.rs:48:12
|
LL | a::Enum::VBaz{};
| ^^^^
error: aborting due to 16 previous errors