Skip to content

Autocompletion does not work for function-local variable when there is a macro on a function #10788

Closed
@gyzerok

Description

@gyzerok

Hello everyone! Love the work you are doing for the community!

Setup

VSCode plugin: v0.2.817
Rust: 1.56.1 (59eed8a2a 2021-11-01)
Cargo: 1.56.0 (4ed5d137b 2021-10-04)
Rust Analyzer: 73668334f 2021-11-15 stable

Problem

I can confirm it happening in NeoVim as well, so it's not unique to VSCode setup.

Screen.Recording.2021-11-17.at.18.34.58.mov

Reproduction

Here is the smallest reproducable example I can get:

  1. Do cargo init rust-analyzer-autocomplete-bug
  2. Do cargo add tracing
  3. Add following to your main.rs and try to type test where comment is
  4. Observe things not working
  5. Remove #[tracing::instrument] and try again to type test where comment is
  6. Observe everything working fine
// main.rs
use std::collections::HashSet;

fn main() {
    println!("Hello, world!");
}

struct Test;

impl Test {
    fn test() -> HashSet<String> {
        HashSet::new()
    }
}

#[tracing::instrument]
async fn buggy_autocomplete() {
    let test = Test::test();
    // cannot autocomplete test here
}

I'd be happy to provide any additional details if needed. Really am excited about your project getting better every weak! 🎉

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-completionautocompletionA-macromacro expansionC-bugCategory: bugS-actionableSomeone could pick this issue up and work on it right now

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions