]> git.lizzy.rs Git - rust.git/blob - tests/ui/attributes/key-value-expansion.rs
Rollup merge of #107761 - oli-obk:miri_🪵, r=TaKO8Ki
[rust.git] / tests / ui / attributes / key-value-expansion.rs
1 // Regression tests for issue #55414, expansion happens in the value of a key-value attribute,
2 // and the expanded expression is more complex than simply a macro call.
3
4 // aux-build:key-value-expansion.rs
5
6 #![feature(rustc_attrs)]
7
8 extern crate key_value_expansion;
9
10 // Minimized test case.
11
12 macro_rules! bug {
13     ($expr:expr) => {
14         #[rustc_dummy = $expr] // Any key-value attribute, not necessarily `doc`
15         struct S;
16     };
17 }
18
19 // Any expressions containing macro call `X` that's more complex than `X` itself.
20 // Parentheses will work.
21 bug!((column!())); //~ ERROR unexpected expression: `(7u32)`
22
23 // Original test case.
24
25 macro_rules! bug {
26     () => {
27         bug!("bug" + stringify!(found)); //~ ERROR unexpected expression: `"bug" + "found"`
28     };
29     ($test:expr) => {
30         #[doc = $test]
31         struct Test {}
32     };
33 }
34
35 bug!();
36
37 // Test case from #66804.
38
39 macro_rules! doc_comment {
40     ($x:expr) => {
41         #[doc = $x]
42         extern {}
43     };
44 }
45
46 macro_rules! some_macro {
47     ($t1: ty) => {
48         doc_comment! {format!("{coor}", coor = stringify!($t1)).as_str()}
49         //~^ ERROR unexpected expression: `{
50     };
51 }
52
53 some_macro!(u8);
54
55 fn main() {}