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

Deserializing untagged enum variants broke/changed between v1.0.38 and v1.0.39 #1216

Closed
tecywiz121 opened this issue Apr 18, 2018 · 5 comments
Labels

Comments

@tecywiz121
Copy link

Still working out the details, but something changed between 1.0.38 and 1.0.39 that's broken my untagged enum.

I'm doing a bisect right now to figure out the commit that introduced the change.

@dtolnay
Copy link
Member

dtolnay commented Apr 18, 2018

Can you share the enum that broke? Is there a custom Deserialize impl involved?

@tecywiz121
Copy link
Author

Sure! Sorry, got a little lost in trying to get cargo to use my local serde.

I wanted a way to reference another file from inside of a TOML file, so I made this. As an aside, if there's a more idiomatic way to do this with serde, I'm all ears.

Playground

Gist

@dtolnay
Copy link
Member

dtolnay commented Apr 18, 2018

I think the trouble is because TOML represents bytes as an array of integers (playground) rather than a string -- so when the Deserialize impl calls deserializer.deserialize_bytes(DataVisitor) the format is allowed to assume you are looking for its representation of bytes. In this case deserialize_str would work instead, or deserialize_any since TOML is self-describing and can figure out the type based on the input data.

Some unrelated suggestions:

  • You can remove with = "expect_equal_to" because that is the default behavior of a newtype variant containing T.

  • You can remove the bound attribute because that bound can be inferred -- just as derive(Debug) is inferring T: Debug, derive(Hash) is inferring T: Hash, etc.

@tecywiz121
Copy link
Author

Thanks for the feedback, very much appreciated! The bound attribute was required when I first wrote this, but I guess that requirement is gone? Weird.

I'd still say this is a bug, since the behavior changed pretty dramatically for a patch version, no?

@dtolnay dtolnay added the bug label Apr 19, 2018
@dtolnay
Copy link
Member

dtolnay commented Apr 19, 2018

Absolutely. Thanks! This is fixed in 3c4961c and released in Serde 1.0.40 so the code in the gist is back to working as before. Really sorry about the breakage.

@dtolnay dtolnay closed this as completed Apr 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants