mirror of
https://github.com/allankoechke/rust.git
synced 2026-12-01 17:40:16 +00:00
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