]> git.proxmox.com Git - rustc.git/blob - src/test/ui/proc-macro/auxiliary/mixed-site-span.rs
Update unsuspicious file list
[rustc.git] / src / test / ui / proc-macro / auxiliary / mixed-site-span.rs
1 // force-host
2 // no-prefer-dynamic
3
4 #![feature(proc_macro_quote)]
5
6 #![crate_type = "proc-macro"]
7
8 extern crate proc_macro;
9 use proc_macro::*;
10
11 #[proc_macro]
12 pub fn proc_macro_rules(input: TokenStream) -> TokenStream {
13 if input.is_empty() {
14 let id = |s| TokenTree::from(Ident::new(s, Span::mixed_site()));
15 let item_def = id("ItemDef");
16 let local_def = id("local_def");
17 let item_use = id("ItemUse");
18 let local_use = id("local_use");
19 let mut single_quote = Punct::new('\'', Spacing::Joint);
20 single_quote.set_span(Span::mixed_site());
21 let label_use: TokenStream = [
22 TokenTree::from(single_quote),
23 id("label_use"),
24 ].iter().cloned().collect();
25 quote!(
26 struct $item_def;
27 let $local_def = 0;
28
29 $item_use; // OK
30 $local_use; // ERROR
31 break $label_use; // ERROR
32 )
33 } else {
34 let mut dollar_crate = input.into_iter().next().unwrap();
35 dollar_crate.set_span(Span::mixed_site());
36 quote!(
37 type A = $dollar_crate::ItemUse;
38 )
39 }
40 }