You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Looking into the rename feature I discovered that rustc does not gives an unreachable warning with serde rename collisions with enums whereas it does on structs as mentioned in #754
Would you still be open to a PR to make clashing renames an error? If so I'm happy to give it a go.
Example
use serde::{Deserialize};#[derive(Deserialize)]enumMessage{#[serde(rename = "Response")]Request{id:String},#[serde(rename = "Response")]Response{id:String},}fnmain(){let json = "{\"Response\": {\"id\": \"...\"}}";let parsed:Message = match serde_json::from_str(&json){Ok(contact) => contact,Err(err) => {println!("{:?}", err);unimplemented!()}};match parsed {Message::Request{ id } => println!("request {}", id),Message::Response{ id } => println!("response {}", id)}}
The text was updated successfully, but these errors were encountered:
seam345
changed the title
Duplicate field names after rename attributes are applied nolonger results in unreachable warning
No unreachable warning when duplicate field names after rename attributes
Nov 3, 2022
seam345
changed the title
No unreachable warning when duplicate field names after rename attributes
No unreachable warning when duplicate field names on enum after rename attributes
May 13, 2023
Looking into the rename feature I discovered that rustc does not gives an unreachable warning with serde rename collisions with
enums
whereas it does onstructs
as mentioned in #754Would you still be open to a PR to make clashing renames an error? If so I'm happy to give it a go.
Example
Output
request ...
with no compiler warnings
playgrounds link https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=c6a787d51f1290af999a0e36b9a6d366
The text was updated successfully, but these errors were encountered: