-
Notifications
You must be signed in to change notification settings - Fork 384
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 generated mod.rs to pass cargo fmt -- --check #622
Fix generated mod.rs to pass cargo fmt -- --check #622
Conversation
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.
Two comments, and also can you split PRs into unrelated issues please?
protobuf-codegen/src/gen/mod_rs.rs
Outdated
w.write_line(""); | ||
w.comment(&format!( | ||
"This file is generated by {} {}. Do not edit", | ||
env!("CARGO_PKG_NAME"), |
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.
Code generator is not necessarily executed by cargo. See how similar code is inserted in other files.
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.
Removed
protobuf-codegen/src/gen/mod_rs.rs
Outdated
env!("CARGO_PKG_NAME"), | ||
env!("CARGO_PKG_VERSION") | ||
)); | ||
w.comment("@generated"); |
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.
That was
w.comment(&format!("{}generated", "@"));
intentionally, so the generator is not considered to be generated.
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.
Reverted
protobuf-codegen/src/gen/mod_rs.rs
Outdated
for m in mods { | ||
w.write_line(""); |
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.
Now it writes a line between mods? Doesn't look right.
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.
The formatter won't sort mods when they are empty line delimited
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.
Wouldn't it be better to just sort mods?
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.
Sure, if u prefer
Thanks! |
Currently, the generated
mod.rs
does not passcargo fmt -- --check
, and this becomes a problem when ppl choose to include generated files as part of source code.This PR tries to make
rustfmt
happy by adding an empty line after each 'pub mod' import. It also addsThis file is generated by
line to makemod.rs
consistent with other files.This closes #621