Skip to content

feat: complete locals in record field#22440

Open
A4-Tacks wants to merge 1 commit into
rust-lang:masterfrom
A4-Tacks:record-field-locals
Open

feat: complete locals in record field#22440
A4-Tacks wants to merge 1 commit into
rust-lang:masterfrom
A4-Tacks:record-field-locals

Conversation

@A4-Tacks
Copy link
Copy Markdown
Member

Example

fn outer() {
    let foo = 3;
    {
        let bar = 3;
        struct Foo {
            b$0
        }
        let baz = 3;
        let qux = 3;
    }
    let fez = 3;
}

Completes:

bn bar: i32,
bn baz: i32,
bn foo: i32,
kw pub
kw pub(crate)
kw pub(super)

Example
---
```rust
fn outer() {
    let foo = 3;
    {
        let bar = 3;
        struct Foo {
            b$0
        }
        let baz = 3;
        let qux = 3;
    }
    let fez = 3;
}
```

Completes:

```text
bn bar: i32,
bn baz: i32,
bn foo: i32,
kw pub
kw pub(crate)
kw pub(super)
```
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 24, 2026
@ChayimFriedman2
Copy link
Copy Markdown
Contributor

I feel like local structs, especially in the middle of a function, are rare enough to not justify this.

@A4-Tacks
Copy link
Copy Markdown
Member Author

This can be temporary, first creating a structure within the function and then move it to the top level

This assist is very useful when refactoring large functions

@ChayimFriedman2
Copy link
Copy Markdown
Contributor

I've never done that and I fail to even imagine how it'll be useful.

I don't want this, but CC @rust-lang/rust-analyzer.

@Veykril
Copy link
Copy Markdown
Member

Veykril commented May 26, 2026

I agree, this seems to have little value and in fact might even be confusing at times due to showing non fields here,

@A4-Tacks
Copy link
Copy Markdown
Member Author

confusing at times due to showing non fields here,

This was originally only a completion for visibility, I think there's no problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants