Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add #[allow(deprecated)] to derive implementations #2879

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

rcrisanti
Copy link

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.

Resolves #2195

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.

Resolves serde-rs#2195
@KarstenB
Copy link

KarstenB commented Jan 9, 2025

I just encountered the same issue and was wondering how that could be implemented. While I am perfectly fine with the given PR, I thought about a more generic way. Like:

#[derive(Serialize, Deserialize)]
#[deprecated]
#[serde(allow = deprecated)]
struct bla {}

@rcrisanti
Copy link
Author

@KarstenB that is definitely doable if that is the desired behavior. Personally I'm not sure I can think of a scenario where I do want to see these messages, so I'd at least be in favor of making the default not showing them, with some sort of option to turn them back on.

(For some justification of this, in rust itself they hide deprecation messages in derives, so in my opinion this would put serde more inline with expected behavior.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

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