fix(build): Remove ambiguity in service method call #327
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
I have an existing proto with a method that was unfortunately named
Drop
, and the tonic stub did not compile. When calling methods on Arc where the method is also defined onArc
(e.g.drop
andclone
), callinginner.#method_ident(request)
will actually attempt to call theArc
method instead of the method on the service, resulting in a compile error when building the generated rust file.Here is an excerpt from a test proto, which I have added as tests/ambiguous_methods/proto/ambiguous_methods.proto:
Solution
This change removes the ambiguity by dereferencing the inner
Arc
.An alternative fix would be to use the fully qualified syntax for method calls. I believe that this change should be good enough because
#server_trait
is only known to be#server_trait : Send + Sync + 'static
, andSync
andSend
define no other methods.See also: my PR to grpc-rust for the exact same issue a year ago stepancheg/grpc-rust#142