Skip to content

Commit 436c2eb

Browse files
committed
introduce test for 146808
1 parent f524236 commit 436c2eb

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
extern crate proc_macro;
2+
use proc_macro::*;
3+
4+
fn spans_callsite(ts: TokenStream) -> TokenStream {
5+
let mut new_ts = TokenStream::new();
6+
7+
for i in ts {
8+
let new_token = i.clone();
9+
match new_token {
10+
TokenTree::Group(g) => {
11+
new_ts.extend([Group::new(g.delimiter(), spans_callsite(g.stream()))])
12+
}
13+
mut other => {
14+
other.set_span(Span::call_site());
15+
new_ts.extend([other]);
16+
}
17+
}
18+
}
19+
20+
new_ts
21+
}
22+
23+
#[proc_macro_attribute]
24+
pub fn all_spans_same(_: TokenStream, ts: TokenStream) -> TokenStream {
25+
spans_callsite(ts)
26+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// regression test for #146808
2+
//@ proc-macro: all_spans_same.rs
3+
extern crate all_spans_same;
4+
5+
#[all_spans_same::all_spans_same]
6+
#[allow{}]
7+
fn main() {}

0 commit comments

Comments
 (0)