Skip to content

fix: do not panic when inline call param usages in macro - #23231

Open
A4-Tacks wants to merge 1 commit into
rust-lang:masterfrom
A4-Tacks:inline-call-ref-in-macro
Open

fix: do not panic when inline call param usages in macro#23231
A4-Tacks wants to merge 1 commit into
rust-lang:masterfrom
A4-Tacks:inline-call-ref-in-macro

Conversation

@A4-Tacks

@A4-Tacks A4-Tacks commented Aug 25, 2026

Copy link
Copy Markdown
Member

Fixup #23122

Example

macro_rules! identity { ($($t:tt)*) => { $($t)* }; }
struct Foo;
impl Foo {
    fn foo(self, r1: u32, r2: u32, (complex,): (u32,)) {
        identity! {
            let _ = self;
            let _ = r1;
            let _ = (r2, r2);
            let _ = complex;
        }
    }
}
fn bar() {
    Foo.$0foo(1, 2, (3,));
}

Before this PR

request handler panicked: TextRange -offset overflowed

After this PR

fn bar() {
    {
        let this = Foo;
        let r1 = 1;
        let r2 = 2;
        let (complex,) = (3,);
        identity! {
            let _ = this;
            let _ = r1;
            let _ = (r2, r2);
            let _ = complex;
        }
    };
}

Example
---
```rust
macro_rules! identity { ($($t:tt)*) => { $($t)* }; }
struct Foo;
impl Foo {
    fn foo(self, r1: u32, r2: u32, (complex,): (u32,)) {
        identity! {
            let _ = self;
            let _ = r1;
            let _ = (r2, r2);
            let _ = complex;
        }
    }
}
fn bar() {
    Foo.$0foo(1, 2, (3,));
}
```

**Before this PR**

request handler panicked: TextRange -offset overflowed

**After this PR**

```rust
fn bar() {
    {
        let this = Foo;
        let r1 = 1;
        let r2 = 2;
        let (complex,) = (3,);
        identity! {
            let _ = this;
            let _ = r1;
            let _ = (r2, r2);
            let _ = complex;
        }
    };
}
```
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 25, 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