summaryrefslogtreecommitdiffstats
path: root/src/test/ui/fmt/auxiliary/format-string-proc-macro.rs
blob: e44a84776bc696c01511e35fccf4b8efa2b682c4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// force-host
// no-prefer-dynamic

#![crate_type = "proc-macro"]

extern crate proc_macro;

use proc_macro::{Literal, Span, TokenStream, TokenTree};

#[proc_macro]
pub fn foo_with_input_span(input: TokenStream) -> TokenStream {
    let span = input.into_iter().next().unwrap().span();

    let mut lit = Literal::string("{foo}");
    lit.set_span(span);

    TokenStream::from(TokenTree::Literal(lit))
}

#[proc_macro]
pub fn err_with_input_span(input: TokenStream) -> TokenStream {
    let span = input.into_iter().next().unwrap().span();

    let mut lit = Literal::string("         }");
    lit.set_span(span);

    TokenStream::from(TokenTree::Literal(lit))
}