rust-lang / rust-lang/rust-analyzer
Autocomplete doesn't work inside 'async_stream' function-like macro
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 16.9k
- Forks
- 2.2k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 72
Description
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 the run_route_chat function, autocomplete works fine. However, when typing characters inside the async_stream::stream! macro block, the autocompletions don't show up.
async fn run_route_chat(client: &mut RouteGuideClient<Channel>) -> Result<(), Box<dyn Error>> {
let start = time::Instant::now();
let outbound = async_stream::stream! {
// ------------------------------------------------------------------------------------
// ----------------- autocompletions stop working inside here ------------------------
// ------------------------------------------------------------------------------------
let mut interval = time::interval(Duration::from_secs(1));
loop {
let time = interval.tick().await;
let elapsed = time.duration_since(start);
let note = RouteNote {
location: Some(Point {
latitude: 409146138 + elapsed.as_secs() as i32,
longitude: -746188906,
}),
message: format!("at {:?}", elapsed),
};
yield note;
}
};
let response = client.route_chat(Request::new(outbound)).await?;
let mut inbound = response.into_inner();
while let Some(note) = inbound.message().await? {
println!("NOTE = {:?}", note);
}
Ok(())
}
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue in routeguide/client.rs by comparing completion inside and outside the async_stream::stream! macro block. Start by examining how rust-analyzer handles this function-like macro, and consider the issue resolved when autocomplete suggestions appear inside the block as they do in the surrounding function.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- developer-experience, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100