-
Notifications
You must be signed in to change notification settings - Fork 526
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
Ignore empty codegen modules in outputs #726
Ignore empty codegen modules in outputs #726
Conversation
@trevoranderson thank you for doing this! Would it be possible to add a test of the original behavior that was fixed with this so we can make sure we don't regress in the future? |
…x and seeing it fail, by adding the non-working reverted fix and seeing it still fail, and finally by adding the fix back in and seeing it pass
Made an attempt at that too. I used an proto adapted from the hyperium issue report which reproduces the issue without my fix and works with the fix applied. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM thanks!
@@ -156,6 +150,13 @@ use crate::ident::to_snake; | |||
use crate::message_graph::MessageGraph; | |||
use crate::path::PathMap; | |||
|
|||
mod ast; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this change?
…s_and_include_file
This file was generated by the previous version of prost-build. This behaviour was fixed in tokio-rs/prost#726.
This file was generated by the previous version of prost-build. This behaviour was fixed in tokio-rs/prost#726.
This file was generated by the previous version of prost-build. This behaviour was fixed in tokio-rs/prost#726.
References:
Original report: #228
My report: #724
Partial fix in: #605
Issue with fix: hyperium/tonic#964
Reverted in: #639
After digging in, the issue with the first fix is that while it prevented the file from being generated, it did not prevent the file from being referenced in the "include" file because both locations iterate the module hash. My proposed solution is to instead avoid adding the empty module to the list at all. Then the file does not get output and the include file does not have an entry that would otherwise be referencing an empty file.
Also did a small refactor pass on the surrounding loop to destructure the tuple instead of using tuple.0 syntax wherever it is used.
Tested by reproducing the original issue using
tonic-build
with the original behavior working then reintroduced the bug, then fixed it with my changes. Manually verified output files and included them in a new rust project to make sure they worked and verified that the extra file is not present in file system or the include file. Also ran cargo test on prost