Skip to content

Commit

Permalink
Add tests of deprecated error types
Browse files Browse the repository at this point in the history
    error: use of deprecated struct `test_deprecated::DeprecatedStruct`
      --> tests/test_lints.rs:44:16
       |
    44 |     pub struct DeprecatedStruct;
       |                ^^^^^^^^^^^^^^^^
       |
    note: the lint level is defined here
      --> tests/test_lints.rs:39:13
       |
    39 |     #![deny(deprecated)]
       |             ^^^^^^^^^^

    error: use of deprecated struct `test_deprecated::DeprecatedStruct`
      --> tests/test_lints.rs:44:16
       |
    44 |     pub struct DeprecatedStruct;
       |                ^^^^^^^^^^^^^^^^

    error: use of deprecated enum `test_deprecated::DeprecatedEnum`
      --> tests/test_lints.rs:55:14
       |
    55 |     pub enum DeprecatedEnum {
       |              ^^^^^^^^^^^^^^
  • Loading branch information
dtolnay committed Dec 7, 2024
1 parent 42b1460 commit 0ba7d01
Showing 1 changed file with 28 additions and 3 deletions.
31 changes: 28 additions & 3 deletions tests/test_lints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,37 @@ fn test_deprecated() {
#![deny(deprecated)]

#[derive(Error, Debug)]
pub enum MyError {
#[deprecated]
#[error("...")]
pub struct DeprecatedStruct;

#[derive(Error, Debug)]
#[error("{message} {}", .message)]
pub struct DeprecatedStructField {
#[deprecated]
message: String,
}

#[derive(Error, Debug)]
#[deprecated]
pub enum DeprecatedEnum {
#[error("...")]
Variant,
}

#[derive(Error, Debug)]
pub enum DeprecatedVariant {
#[deprecated]
#[error("...")]
Deprecated,
Variant,
}

#[allow(deprecated)]
let _ = MyError::Deprecated;
let _: DeprecatedStruct;
#[allow(deprecated)]
let _: DeprecatedStructField;
#[allow(deprecated)]
let _ = DeprecatedEnum::Variant;
#[allow(deprecated)]
let _ = DeprecatedVariant::Variant;
}

0 comments on commit 0ba7d01

Please sign in to comment.