Skip to content

#[derive(Serialize) and #[derive(Deserialize)] on deprecated types emit deprecation warnings #2195

Open
@nsunderland1

Description

@nsunderland1

Given this code (playground link):

#[deprecated]
#[derive(Default, serde::Serialize)]
struct WithSerialize;

#[deprecated]
#[derive(Default, serde::Deserialize)]
struct WithDeserialize;

#[deprecated]
#[derive(Default)]
struct WithoutSerde;

fn main() {
}

I expect not to get deprecation warnings. Instead, I get the following:

warning: use of deprecated struct `WithSerialize`
 [--> src/main.rs:3:8
](https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=22d2042e09ce11dddfcbac0464dd4fe3#)  |
3 | struct WithSerialize;
  |        ^^^^^^^^^^^^^
  |
  = note: `#[warn(deprecated)]` on by default

warning: use of deprecated struct `WithDeserialize`
 [--> src/main.rs:7:8
](https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=22d2042e09ce11dddfcbac0464dd4fe3#)  |
7 | struct WithDeserialize;
  |        ^^^^^^^^^^^^^^^

warning: use of deprecated unit struct `WithDeserialize`
 [--> src/main.rs:7:8
](https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=22d2042e09ce11dddfcbac0464dd4fe3#)  |
7 | struct WithDeserialize;
  |        ^^^^^^^^^^^^^^^

Notice that the derives for Default don't trigger any warnings (this seems to have been fixed some time ago).

Not aware of any workaround (other than undeprecating), and this leads to a bunch of warnings for things that are deprecated but that we still want to be able to support serialization for.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions