rust-lang / rust-lang/rust-analyzer
Intellisense fails when using macros
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: 0.3.1916-standalone (7a8374c16 2024-04-08) and 0.4.1918-standalone (a5feb4f05 2024-04-09)
rustc version: 1.77.2 (25ef9e3d8 2024-04-09)
editor or extension: VSCode 1.88.0 2024-04-03
code snippet to reproduce:
main.rs:
use tracing::Level;
use tracing_subscriber::FmtSubscriber;
#[allow(dead_code)]
fn main() {
let subscriber = FmtSubscriber::builder()
.with_max_level(Level::TRACE)
.with_target(false)
.finish();
tracing::subscriber::set_global_default(subscriber).expect("setting default subscriber failed");
be_translated(vec![1, 2, 3]);
}
// #[cfg_attr(feature = "tracing", tracing::instrument(skip(v)))]
#[cfg_attr(feature = "tracing", tracing::instrument)]
// #[tracing::instrument]
fn be_translated(v: Vec<usize>) {
println!("{:?}", v.len());
}
Cargo.toml:
[features]
default = ["tracing"]
tracing = []
[dependencies]
tracing = "0.1"
tracing-subscriber = "0.3"
If I add the cfg_attr, then autocomplete does not work:
If I remove cfg_attr, autocomplete works:
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 report with the shown main.rs and Cargo.toml, comparing completion with and without the cfg_attr macro. Start by tracing rust-analyzer's completion handling for macro-annotated functions. Done means autocomplete works in the cfg_attr case while preserving the behavior of the non-macro example.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100