rust-analyzer icon indicating copy to clipboard operation
rust-analyzer copied to clipboard

Complete does not work inside macros if paired with struct update from Default

Open strowk opened this issue 2 months ago • 1 comments

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: Image

This is what happens: Image

strowk avatar Oct 19 '25 01:10 strowk

Yeah, this is our speculative expansion not doing well, we have multiple issues wrt. that.

ChayimFriedman2 avatar Nov 28 '25 04:11 ChayimFriedman2