-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Auto completion of async fn xxxx
for desugared async fn in trait
form
#17719
Labels
Comments
There's a question on On "Implement missing members", should we fill them in sugar version or original form for |
I'd say sugared version, and then if we don't have it yet, have a desugar assist that goes from |
bors
added a commit
that referenced
this issue
Jul 29, 2024
feat(ide-completion): explictly show `async` keyword on `impl trait` methods OLD: <img width="676" alt="image" src="https://github.com/user-attachments/assets/f6fa626f-6b6d-4c22-af27-b0755e7a6bf8"> Now: <img width="684" alt="image" src="https://github.com/user-attachments/assets/efbaac0e-c805-4dd2-859d-3e44b2886dbb"> --- This is an preparation for #17719. ```rust use std::future::Future; trait DesugaredAsyncTrait { fn foo(&self) -> impl Future<Output = usize> + Send; fn bar(&self) -> impl Future<Output = usize> + Send; } struct Foo; impl DesugaredAsyncTrait for Foo { fn foo(&self) -> impl Future<Output = usize> + Send { async { 1 } } // async fn bar(&self) -> usize { 1 } } fn main() { let fut = Foo.bar(); fn _assert_send<T: Send>(_: T) {} _assert_send(fut); } ``` If we don't distinguish `async` or not. It would be confusing to generate sugared version `async fn foo ....` and original form `fn foo` for `async fn in trait` that is defined in desugar form.
RalfJung
pushed a commit
to RalfJung/rust
that referenced
this issue
Aug 1, 2024
feat(ide-completion): explictly show `async` keyword on `impl trait` methods OLD: <img width="676" alt="image" src="https://github.com/user-attachments/assets/f6fa626f-6b6d-4c22-af27-b0755e7a6bf8"> Now: <img width="684" alt="image" src="https://github.com/user-attachments/assets/efbaac0e-c805-4dd2-859d-3e44b2886dbb"> --- This is an preparation for rust-lang/rust-analyzer#17719. ```rust use std::future::Future; trait DesugaredAsyncTrait { fn foo(&self) -> impl Future<Output = usize> + Send; fn bar(&self) -> impl Future<Output = usize> + Send; } struct Foo; impl DesugaredAsyncTrait for Foo { fn foo(&self) -> impl Future<Output = usize> + Send { async { 1 } } // async fn bar(&self) -> usize { 1 } } fn main() { let fut = Foo.bar(); fn _assert_send<T: Send>(_: T) {} _assert_send(fut); } ``` If we don't distinguish `async` or not. It would be confusing to generate sugared version `async fn foo ....` and original form `fn foo` for `async fn in trait` that is defined in desugar form.
bors
added a commit
that referenced
this issue
Sep 1, 2024
feat(ide-completion): extra sugar auto-completion `async fn ...` in `impl trait` for `async fn in trait` that's defined in desugar form Solves #17719. --- Preview <img width="670" alt="image" src="https://github.com/user-attachments/assets/64ccef84-4062-4702-8760-89220585f422"> <img width="540" alt="image" src="https://github.com/user-attachments/assets/d22637f9-d531-43b2-a9f1-cd40a002903a"> <img width="631" alt="image" src="https://github.com/user-attachments/assets/21cd2142-bb8e-4493-9ac7-e6a9e7076904">
bors
added a commit
that referenced
this issue
Sep 1, 2024
feat(ide-completion): extra sugar auto-completion `async fn ...` in `impl trait` for `async fn in trait` that's defined in desugar form Solves #17719. --- Preview <img width="670" alt="image" src="https://github.com/user-attachments/assets/64ccef84-4062-4702-8760-89220585f422"> <img width="540" alt="image" src="https://github.com/user-attachments/assets/d22637f9-d531-43b2-a9f1-cd40a002903a"> <img width="631" alt="image" src="https://github.com/user-attachments/assets/21cd2142-bb8e-4493-9ac7-e6a9e7076904">
Fixed in #17737 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi. I'm thinking about improving the dx of writing
impl DesugaredAsyncTrait for Foo
. So far the rust analyzer will only infer auto completion likeHowever, I found that the compiler will allow the following code compiles.
If this is an expected behavior(It's expected, see the following zulipchat link), maybe it's ok to make rust analyzer to support auto completion that starts withasync fn foo
( the sugar version rather than only desugared version like now) forDesugaredAsyncTrait
.This will surely improve the dx of writing
impl DesugaredAsyncTrait for XXX
greatly without the need to writeimpl Future<Output=XXXX> + Send
over and over again(Though there are also auto completed by the rust-analyzer :).Related:
The text was updated successfully, but these errors were encountered: