Conversation
Generated server code called each handler with method-call syntax on the `Arc` that holds the service. An RPC whose Rust name is also a method of that `Arc` resolved to the wrong method and failed to compile: the generated `register`, or a prelude trait method such as `clone`, `into` or `drop`. Generated code now calls `Trait::method(&*svc, ctx, request)`. An RPC named `New`, `Config` or `ConfigMut` still does not compile, because the generated client has methods with those names. Fixes #309 Assisted-By: Claude <noreply@anthropic.com> Signed-off-by: Iain McGinniss <309153+iainmcgin@users.noreply.github.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
A service with
rpc Register(...)does not compile: generated server code callssvc.register(ctx, req)on anArc<S>, which resolves to the generated extension methodregister(self: Arc<Self>, router). The same happens for any RPC whose Rust name is a prelude trait method thatArcimplements, such asclone,into,try_into,to_owned,as_refanddrop.Generated code now calls
Trait::method(&*svc, ctx, request), in both theRouterregistration and the monomorphic dispatcher. For an existing service this is the call that method syntax already resolved to, with one exception: if the service trait is implemented forArc<X>as well as forX, the generated code now callsX's handler.This makes client methods named
clone,intoandtry_intoreachable for the first time, and method-call syntax does not reach all of them:client.into(req)resolves toInto::into. A follow-up PR will name these client methods with a trailing underscore. It should land before the next release, because renaming them after a release is a breaking change.Fixes #309