Repository navigation
Conversation
An async connection protocol's handlers were written `-> impl ::core::future::Future<Output = ..> + Send`. They now import `Future` and write `-> impl Future<Output = ..> + Send`; the `+ Send` stays, since the dispatcher boxes the handlers' futures into a `BoxFuture` and an `async fn` in a trait can't state that bound. `Future` goes through the same marks as the other names generated code uses: the import is emitted only where a signature names it, and a module that declares its own `Future` keeps the full path instead.
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.
Under
async = true, a connection protocol's handlers are generated asThey are now
The
+ Sendstays: the async dispatcher boxes handler futures into the runtime'sBoxFuture, and anasync fnin a trait can't state that bound on the 1.85 floor. Only the path is shortened.How
Futureis added to the generator's marked names (names.rs), the same mechanism asPeer,Fault,Result. The template writes$Future; the import is emitted at the top of the file only when the body marks it, so sync output is unchanged and an async file with no connection protocol gets no import.impl Future<...> + Sendin the trait is the only place the generator emits such a signature (the sender and dispatcher areasync fn), so there is one use site.A schema type named
FutureHandled like a schema type named
PeerorFault(comline-rust#96): the module's declared names (own types, protocols, derived names) are checked, and whereFutureis one of them the import is left out and the signature keeps the full::core::future::Futurepath. It is not aliased. That is a per-module decision, so a file without aFutureof its own gets the short form even if another file in the package declares one.Futureis not added to the trait-in-scope list: the signature only names it, no method of it is called.Tests:
generate.rs: the async output has the import once and the short signature; sync output contains noFuture; a declaredFuturekeeps the full path and no import.compiles.rs:Futurejoins the colliding names (colliding_schemas, built sync and async) and the protocol names that build, so both a struct and a protocol namedFutureare compiled, async included.Generation goldens that will change
After this merges, the one golden in ComlineProject/generation with
::core::future::Futureneeds re-blessing (not part of this PR):conformance/tests/golden/connections_async/rust/conformance.rs: lines 29, 122 and 123 shorten, anduse ::core::future::Future;is added to its imports.connections_async/rust/connection.rsand the other goldens don't contain it.std-extra/has no async signatures, so it is unaffected andSTD_REVis not touched.