Skip to content

Autocomplete doesn't work inside 'async_stream' function-like macro #12759

Open

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    C-supportCategory: support questions

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions