about summary refs log tree commit diff
path: root/tests/ui/macros/metavar-expressions/concat-trace-errors.rs
blob: 45407f5e86d5696e77a375a2e79b2a8280490300 (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
29
30
31
32
33
// Our diagnostics should be able to point to a specific input that caused an invalid
// identifier.

#![feature(macro_metavar_expr_concat)]

// See what we can do without expanding anything
macro_rules! pre_expansion {
    ($a:ident) => {
        ${concat("hi", " bye ")};
        ${concat("hi", "-", "bye")};
        ${concat($a, "-")};
    }
}

macro_rules! post_expansion {
    ($a:literal) => {
        const _: () = ${concat("hi", $a, "bye")};
        //~^ ERROR is not generating a valid identifier
    }
}

post_expansion!("!");

macro_rules! post_expansion_many {
    ($a:ident, $b:ident, $c:ident, $d:literal, $e:ident) => {
        const _: () = ${concat($a, $b, $c, $d, $e)};
        //~^ ERROR is not generating a valid identifier
    }
}

post_expansion_many!(a, b, c, ".d", e);

fn main() {}