-
Notifications
You must be signed in to change notification settings - Fork 1k
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
tonic-build: use unified syntax to clone Arc
s
#1182
Conversation
This changes generated code, so I'm expecting some tests to break. I'm relying on CI to run the tests and tell me which break, so I can fix them. LMK if I should figure out how to run them myself instead! |
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!
Youll need to run the bootstrap test and commit the generated code to get CI to pass. then we can merge thanks! |
Thanks @LucioFranco! I've done that now, but I'm not entirely sure my changes are correct. They are different from what the CI output showed, and they are not related to the code changes I made either. Edit: I get the same diffs after running the tests on master, which definitely seems wrong! |
how are you running the tests? |
nitpick: Its called "Fully Qualified Syntax" rather than "Unified Syntax". See https://doc.rust-lang.org/book/ch19-03-advanced-traits.html#fully-qualified-syntax-for-disambiguation-calling-methods-with-the-same-name |
On a clean checkout, I simply run
I suppose you are right. I took the term from the clippy lint, no idea where they got it from. It was called "universal function call syntax" at one point. |
Ah I see. I guess it has several names :P |
I had to run |
The purpose is to prevent the `clone_on_ref_ptr` clippy lint from triggering on code generated by tonic.
Thanks, removing the second commit, |
This PR changes the generated code to use the unified function syntax for cloning
Arc
values (Arc::clone(foo)
instead offoo.clone()
).Motivation
In https://github.com/MaterializeInc/materialize, we use tonic, and we also enforce the clippy lint
clone_on_ref_ptr
. This lint currently triggers on code generated by tonic, which forces us to disable it for modules that import tonic-generated code.The main motivation for this PR is that we don't have to disable the lint anymore. Using unified function syntax when cloning
Arc
s also makes the code more obvious, which is nice.Solution
Adjust the generated code to conform with the style clippy proposes.