mirror of
https://github.com/pezkuwichain/serde.git
synced 2026-04-24 08:48:00 +00:00
add #[allow(deprecated)] to derive implementations
Allow deprecated in the `Serialize`/`Deserialize` derive implementations. This allows you to deprecate structs, enums, struct fields, or enum variants and not get compiler warnings/errors about use of deprecated thing. We only do this if `#[deprecated]` or `#[allow(deprecated)]` exist on the root object or the variants of the root object (if it is an enum). Resolves #2195
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
#![deny(deprecated)]
|
||||
#![allow(dead_code)]
|
||||
|
||||
use serde_derive::{Deserialize, Serialize};
|
||||
|
||||
/// deprecated enum
|
||||
#[derive(Serialize, Deserialize)]
|
||||
#[deprecated]
|
||||
enum E1 {
|
||||
A,
|
||||
B,
|
||||
}
|
||||
|
||||
/// deprecated struct
|
||||
#[derive(Serialize, Deserialize)]
|
||||
#[deprecated]
|
||||
struct S1 {
|
||||
a: bool,
|
||||
}
|
||||
|
||||
/// deprecated enum variant
|
||||
#[derive(Serialize, Deserialize)]
|
||||
enum E2 {
|
||||
A,
|
||||
#[deprecated]
|
||||
B,
|
||||
}
|
||||
|
||||
/// deprecated struct field
|
||||
#[derive(Serialize, Deserialize)]
|
||||
struct S2 {
|
||||
#[deprecated]
|
||||
a: bool,
|
||||
}
|
||||
Reference in New Issue
Block a user