rust-analyzer: Autocompletion does not work for function-local variable when there is a macro on a function
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.
Reproduction
Here is the smallest reproducable example I can get:
- Do
cargo init rust-analyzer-autocomplete-bug - Do
cargo add tracing - Add following to your
main.rsand try to typetestwhere comment is - Observe things not working
- Remove
#[tracing::instrument]and try again to typetestwhere comment is - 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! 🎉
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 5
- Comments: 22 (10 by maintainers)
I get what you’re saying, but:
async-trait, there will be twotokiousers complaining that IDE features don’t work with#[tokio::main]async-traitis the only crate where the maintainer refusedFiled https://github.com/async-rs/async-std/issues/998 for the async-std problem.
Regarding the original issue, this is interesting, typing just
tgives the me autocompletion fortest, but if I typeteit disappears.I am getting a feeling that my issue became a discussion for a completely separate issue. Is it so? If yes, can you please open another issue and move your discussion there?
The problem is that not enabling this option leads to other code not being handled correctly. Before the option was enabled by default, we had people reporting those problems instead. It might have been less prevalent, but if we revert the setting, it also means no-one notices the problem.
All proc macros using
synhave this problem, unless they handle it as a special case. See https://github.com/dtolnay/async-trait/issues/178 forasync-trait.I don’t know if that helps but it happens with async-trait as well. I’m pretty sure auto-completion was working there in previous versions of
rust-analyzer.