-
Notifications
You must be signed in to change notification settings - Fork 109
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
span and capturing additional fields #526
Comments
The call stack for an error during flatten looks something like
|
Normally you would expect the key/value processing to be in a call stack like this which is what could set the span. I suspect for flattens, serde is capturing what we deserialize and then replaying that, removing us from the call stack to set a more specific span. So we set a span for the whole table with the problem but we aren't rendering multi-line spans correctly (#458) |
btw I have this written out as a test case #[test]
fn flatten_has_valid_span() {
#[derive(Deserialize, Debug)]
struct Unflatten {
#[allow(dead_code)]
item: u8,
#[allow(dead_code)]
i: u8,
}
bad!(
r#"#a bit of content
item = 7
i = false
"#,
Unflatten,
"\
TOML parse error at line 3, column 5
|
3 | i = false
| ^^^^^
invalid type: boolean `false`, expected u8
"
);
#[derive(Deserialize, Debug)]
struct Flatten {
#[allow(dead_code)]
item: u8,
#[allow(dead_code)]
#[serde(flatten)]
rest: std::collections::HashMap<String, u8>,
}
bad!(
r#"#a bit of content
item = 7
i = false
"#,
Flatten,
"\
TOML parse error at line 3, column 5
|
3 | i = false
| ^^^^^
invalid type: boolean `false`, expected u8
"
);
} |
Closing in favor of #589 |
I have to capture additional fields when deserializing.
Unfortunately, this is messing up the nice error messages / span info.
It always points to the first line.
Playground link with tests: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=ca33eb1e091fb94d4313f361022c2208
The text was updated successfully, but these errors were encountered: