-
-
Notifications
You must be signed in to change notification settings - Fork 789
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
"undeclared lifetime" when derive Deserialize
for an enum with both flatten
and 'static
fields
#2371
Comments
Since #[derive(Deserialize)]
#[serde(tag = "tag")]
enum InternallyTagged<'a> {
Flatten {
#[serde(flatten)]
nested: Nested,
string: &'a str,
},
} |
Of course, this will not work, but serde in that case usually returns an error from So I think it should either:
|
Actually, I'm not right here. Of course, this will work if you try to deserialize a static string into a type (i.e. you just create a read-only struct around read-only string embedded in binary). This will not work if you try to deserialize heap-allocated string. |
The problem in the impl DeserializeSeed<'static> for Visitor {
type Value = InternallyTagged;
fn deserialize<D>(self, deserializer: D) -> Result<Self::Value, D::Error>
where
D: Deserializer<'de>,// <-- Error here
{
deserializer.deserialize_map(self)
}
} The cleaned generated code: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=6c5e32bd6cef06756b0806be7447f827 |
… workarounds for them
The following code panics with the error:
Commenting out any of fields lead to successful compilation.
Output:
https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=b3e592812a43c300e2d247c9ac0b0033
The text was updated successfully, but these errors were encountered: