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

Fix missing messages when --message-format=json is deeply nested #6032

Closed
wants to merge 2 commits into from
Closed

Fix missing messages when --message-format=json is deeply nested #6032

wants to merge 2 commits into from

Conversation

dtolnay
Copy link
Member

@dtolnay dtolnay commented Sep 16, 2018

This PR demonstrates using miniserde for the JSON messages emitted by machine_message::emit. Miniserde does not rely on recursion so this approach supports messages with any arbitrarily large amount of nesting.

Pulling in a dependency on two different serialization libraries is not ideal, especially as this one is generally more verbose and annoying as a consequence of no recursion. We will need to discuss whether this tradeoff makes sense or whether the bug can be resolved a different way.

I confirmed that this fixes #5992. @ehuss

@rust-highfive
Copy link

r? @alexcrichton

(rust_highfive has picked a reviewer for you, use r? to override)

@ehuss
Copy link
Contributor

ehuss commented Sep 16, 2018

Oh, this is awesome! Sorry, I meant to respond to you. I had played around with miniserde but I didn't get too far. I'll take a closer look tomorrow, but it does seem to fix the issue. I was wondering if you had an idea on how to easily make a test for it. I just made a 150 line macro, but I imagine there should be an easier way to exhibit the issue.

@dtolnay
Copy link
Member Author

dtolnay commented Sep 16, 2018

I added a brief test and confirmed that it fails before this PR.

This commit demonstrates using miniserde for the JSON messages emitted
by machine_message::emit. Miniserde does not rely on recursion so this
approach supports messages with any arbitrarily large amount of nesting.

Pulling in a dependency on two different serialization libraries is not
ideal, especially as this one is generally more verbose and annoying as
a consequence of no recursion. We will need to discuss whether this
tradeoff makes sense or whether the bug can be resolved a different way.
@ehuss
Copy link
Contributor

ehuss commented Sep 16, 2018

Nice! I ran it through some tests without problems. LGTM! If you're saying it is more verbose if there is an error, I think that should be rare, so I personally don't worry about that.

@alexcrichton
Copy link
Member

Nice!

In terms of maintenance though I'd probably prefer to not have two json parsers if we can as well as dual implementations of serialization. The underlying issue here seems somewhat niche to me in the sense that it doesn't necessarily justify the "hammer" of a dual serde implementation.

@dtolnay
Copy link
Member Author

dtolnay commented Sep 20, 2018

Makes sense, I can see the downsides.

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

Successfully merging this pull request may close these issues.

--message-format=json doesn't emit every error message
4 participants