]> git.lizzy.rs Git - rust.git/blob - tests/target/macros.rs
Do not add trailing comma inside macro invocation unless there already is
[rust.git] / tests / target / macros.rs
1 // rustfmt-normalize_comments: true
2 itemmacro!(this, is.now().formatted(yay));
3
4 itemmacro!(
5     really,
6     long.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbb()
7         .is
8         .formatted()
9 );
10
11 itemmacro!{this, is.bracket().formatted()}
12
13 peg_file! modname("mygrammarfile.rustpeg");
14
15 fn main() {
16     foo!();
17
18     bar!(a, b, c);
19
20     bar!(a, b, c,);
21
22     baz!(1 + 2 + 3, quux.kaas());
23
24     quux!(
25         AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA,
26         BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
27     );
28
29     kaas!(
30         // comments
31         a, // post macro
32         b /* another */
33     );
34
35     trailingcomma!(a, b, c,);
36
37     noexpr!( i am not an expression, OK? );
38
39     vec![a, b, c];
40
41     vec![
42         AAAAAA,
43         AAAAAA,
44         AAAAAA,
45         AAAAAA,
46         AAAAAA,
47         AAAAAA,
48         AAAAAA,
49         AAAAAA,
50         AAAAAA,
51         BBBBB,
52         5,
53         100 - 30,
54         1.33,
55         b,
56         b,
57         b,
58     ];
59
60     vec![a /* comment */];
61
62     // Trailing spaces after a comma
63     vec![a];
64
65     vec![a; b];
66     vec![a; b];
67     vec![a; b];
68
69     vec![a, b; c];
70     vec![a; b, c];
71
72     vec![
73         a;
74         (|x| {
75              let y = x + 1;
76              let z = y + 1;
77              z
78          })(2)
79     ];
80     vec![
81         a;
82         xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
83     ];
84     vec![a; unsafe { x + 1 }];
85
86     unknown_bracket_macro__comma_should_not_be_stripped![a,];
87
88     foo(makro!(1, 3));
89
90     hamkaas!{ () };
91
92     macrowithbraces! {dont,    format, me}
93
94     x!(fn);
95
96     some_macro!();
97
98     some_macro![];
99
100     some_macro!{
101         // comment
102     };
103
104     some_macro!{
105         // comment
106     };
107
108     some_macro!(
109         // comment
110         not function like
111     );
112
113     // #1712
114     let image = gray_image!(
115         00, 01, 02;
116         10, 11, 12;
117         20, 21, 22);
118
119     // #1092
120     chain!(input, a:take!(max_size), || []);
121 }
122
123 impl X {
124     empty_invoc!{}
125 }
126
127 fn issue_1279() {
128     println!("dsfs"); // a comment
129 }
130
131 fn issue_1555() {
132     let hello = &format!(
133         "HTTP/1.1 200 OK\r\nServer: {}\r\n\r\n{}",
134         "65454654654654654654654655464",
135         "4"
136     );
137 }
138
139 fn issue1178() {
140     macro_rules! foo {
141         (#[$attr:meta] $name:ident) => {}
142     }
143
144     foo!(#[doc = "bar"] baz);
145 }
146 fn issue1739() {
147     sql_function!(
148         add_rss_item,
149         add_rss_item_t,
150         (
151             a: types::Integer,
152             b: types::Timestamptz,
153             c: types::Text,
154             d: types::Text,
155             e: types::Text
156         )
157     );
158
159     w.slice_mut(s![
160         ..,
161         init_size[1] - extreeeeeeeeeeeeeeeeeeeeeeeem..init_size[1],
162         ..
163     ]).par_map_inplace(|el| *el = 0.);
164 }
165
166 // Put the following tests with macro invocations whose arguments cannot be parsed as expressioins
167 // at the end of the file for now.
168
169 // #1577
170 fn issue1577() {
171     let json = json!({
172         "foo": "bar",
173     });
174 }
175
176 gfx_pipeline!(pipe {
177     vbuf: gfx::VertexBuffer<Vertex> = (),
178     out: gfx::RenderTarget<ColorFormat> = "Target0",
179 });