rust-lang / rust-lang/rust-analyzer
Complete does not work inside macros if paired with struct update from Default
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 version: 0.3.2593-standalone (6b2e677795 2025-08-25)
rustc version: rustc 1.88.0 (6b00bc388 2025-06-23)
editor or extension: VSCode, extension "Version 0.3.2593"
code snippet to reproduce:
struct MyStruct {
a: i32,
b: String,
}
impl Default for MyStruct {
fn default() -> Self {
MyStruct {
a: 0,
b: String::new(),
}
}
}
fn get_one() -> MyStruct {
MyStruct {
..Default::default()
}
}
fn get_many() -> Vec<MyStruct> {
vec![
MyStruct {
..Default::default()
},
]
}
To reproduce expected outcome put cursor within get_one function directly above ..Default::default(), then try to complete, i.e hit ctrl+space. The result is a and b suggestions.
To reproduce failed outcome put cursor within get_many function also directly above ..Default::default(), then repeat a and b would not be suggested as fields (VS Code does suggest them as text items, but this is not what is expected and would not work when struct is in another file).
Here is the LSP log from failed run:
[Trace - 3:14:57 AM] Sending request 'textDocument/completion - (51)'.
Params: {
"textDocument": {
"uri": "file:///c%3A/work/rustanalyzerbug/src/main.rs"
},
"position": {
"line": 24,
"character": 12
},
"context": {
"triggerKind": 1
}
}
[Trace - 3:14:57 AM] Received response 'textDocument/completion - (51)' in 1ms.
No result returned.
This is what is expected:
This is what happens:
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
Start by reproducing the provided Rust snippet and inspecting the textDocument/completion request for the struct update inside vec!. Compare completion handling in get_one with get_many, using the supplied LSP log to trace why no result is returned. Done means fields a and b are offered as completions in both contexts.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- developer-experience, devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100