Skip to content

Comments

feat: Support extract variable in macro call#21487

Open
A4-Tacks wants to merge 1 commit intorust-lang:masterfrom
A4-Tacks:extract-var-in-macro
Open

feat: Support extract variable in macro call#21487
A4-Tacks wants to merge 1 commit intorust-lang:masterfrom
A4-Tacks:extract-var-in-macro

Conversation

@A4-Tacks
Copy link
Member

Implement based first and last token mappings

Example

macro_rules! foo {
    (= $($t:tt)*) => { $($t)* };
}

fn main() {
    let x = foo!(= $02 + 3$0 + 4);
}

Before this PR

Assist not applicable

After this PR

macro_rules! foo {
    (= $($t:tt)*) => { $($t)* };
}

fn main() {
    let $0var_name = 2+3;
    let x = foo!(= var_name + 4);
}

Implement based first and last token mappings

Example
---
```rust
macro_rules! foo {
    (= $($t:tt)*) => { $($t)* };
}

fn main() {
    let x = foo!(= $02 + 3$0 + 4);
}
```

**Before this PR**

Assist not applicable

**After this PR**

```rust
macro_rules! foo {
    (= $($t:tt)*) => { $($t)* };
}

fn main() {
    let $0var_name = 2+3;
    let x = foo!(= var_name + 4);
}
```
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jan 18, 2026
@A4-Tacks A4-Tacks changed the title Support extract variable in macro call feat: Support extract variable in macro call Feb 19, 2026
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.

2 participants