Files
rust/compiler/rustc_interface
Jonathan Brouwer 03f0b69902 Rollup merge of #164165 - FranciscoTGouveia:rustc-show-spans-attr, r=petrochenkov
Add a new `rustc_show_spans` internal attribute

This new internal attribute is a first step for solving rust-lang/rust#126763.

Given the code:
```rust
#![feature(rustc_attrs)]

mod x { pub const Y: u8 = 1; }

macro_rules! path  { ($a:tt, $b:tt) => { let _ = $a::$b; }; }

#[rustc_show_spans(path)]
fn no_macro() { let _ = x::Y; }

#[rustc_show_spans(path)]
fn path_bug() { path!(x, Y); }
```

We can now report the spans and thus show the bug of the span not falling inside the macro context:
```
note: showing the spans of the path
 --> test.rs:8:25
  |
8 | fn no_macro() { let _ = x::Y; }
  |                         ^^^^

note: showing the spans of the path
  --> test.rs:11:23
   |
11 | fn path_bug() { path!(x, Y); }
   |                       ^^^^

```

r? @petrochenkov
2026-10-14 19:29:16 +02:00
..