-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Autocomplete doesn't work inside 'async_stream' function-like macro #12759
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
Comments
Try using a stable toolchain if you don't depend on nightly. |
I think I originally had it on rust stable, but changed it to nightly to see if the problem had been patched! |
Since async_stream is a function-like proc macro, there isn't much we can do to make it handle incomplete code. So as long as what you're typing isn't syntactically complete Rust, the macro probably refuses to expand and so we can't provide completions. This would have to be fixed by the macro authors. (You can test whether this is the case by 1. using the "expand macro" function to see whether rust-analyzer can actually expand the macro, and 2. writing some complete, but not necessarily valid statement like |
That makes sense. I just tried both 1 and 2 above and it looks like it's definitely the case that the syntactically incomplete Rust is preventing the macro from expanding properly, which in turn is killing the autocomplete - when typing any valid statement or simply holding the cursor inside the macro and invoking macro expand, I can see that rust-analyzer expands it to this:
Typing in any incomplete Rust and attempting to expand the macro fails as predicted. I'll try to bring it up with the macro authors! |
This comment was marked as off-topic.
This comment was marked as off-topic.
@nyxtom That's not the same problem. If proc macros aren't expanding for you, there should be an error underline on the |
i think i run in the same problem with code: fn main() -> Result<(), Box<dyn std::error::Error>> {
use crossbeam::channel::*;
let (tx1, rx1) = unbounded::<usize>();
let (tx2, rx2) = unbounded::<usize>();
// if the following is just *one* "recv", completion works until something invalid
select! {
recv(rx1) -> msg => {
// no completion at all
},
recv(rx2) -> msg => {
// no completion at all
},
default => (),
}
return Ok(());
} the weird thing is if there is just 1 personally i would expect there to have full typings like a normal(closure) function ( rust-analyzer (vscode): |
rust-analyzer version:
rust-analyzer 0.0.0 (5342f47f4 2022-07-09)
rustc version:
rustc 1.64.0-nightly (27eb6d701 2022-07-04)
I'm learning Rust and I was playing around with the routeguide tutorial from tonic.
When I open
routeguide/client.rs
and type some characters at the top of therun_route_chat
function, autocomplete works fine. However, when typing characters inside theasync_stream::stream!
macro block, the autocompletions don't show up.Demo:
https://streamable.com/c0vl10#
I've read the blog post and all the various issues talking about the root causes so I think I have an understanding of why this is occurring, but I thought I'd file the issue anyway.
The text was updated successfully, but these errors were encountered: