]> git.lizzy.rs Git - rust.git/blob - tests/target/macros.rs
Merge pull request #1938 from topecongiro/changelog
[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!(
145         #[doc = "bar"]
146         baz
147     );
148 }
149
150 fn issue1739() {
151     sql_function!(
152         add_rss_item,
153         add_rss_item_t,
154         (
155             a: types::Integer,
156             b: types::Timestamptz,
157             c: types::Text,
158             d: types::Text,
159             e: types::Text
160         )
161     );
162
163     w.slice_mut(s![
164         ..,
165         init_size[1] - extreeeeeeeeeeeeeeeeeeeeeeeem..init_size[1],
166         ..
167     ]).par_map_inplace(|el| *el = 0.);
168 }
169
170 fn issue_1885() {
171     let threads = people
172         .into_iter()
173         .map(|name| {
174             chan_select! {
175                 rx.recv() => {}
176             }
177         })
178         .collect::<Vec<_>>();
179 }
180
181 fn issue_1917() {
182     mod x {
183         quickcheck! {
184             fn test(a: String, s: String, b: String) -> TestResult {
185                 if a.find(&s).is_none() {
186
187                     TestResult::from_bool(true)
188                 } else {
189                     TestResult::discard()
190                 }
191             }
192         }
193     }
194 }
195
196 fn issue_1921() {
197     // Macro with tabs.
198     lazy_static! {
199         static ref ONE: u32 = 1;
200         static ref TWO: u32 = 2;
201         static ref THREE: u32 = 3;
202         static ref FOUR: u32 = {
203             let mut acc = 1;
204             acc += 1;
205             acc += 2;
206             acc
207         }
208     }
209 }
210
211 // #1577
212 fn issue1577() {
213     let json = json!({
214         "foo": "bar",
215     });
216 }
217
218 gfx_pipeline!(pipe {
219     vbuf: gfx::VertexBuffer<Vertex> = (),
220     out: gfx::RenderTarget<ColorFormat> = "Target0",
221 });
222
223 // #1919
224 #[test]
225 fn __bindgen_test_layout_HandleWithDtor_open0_int_close0_instantiation() {
226     assert_eq!(
227         ::std::mem::size_of::<HandleWithDtor<::std::os::raw::c_int>>(),
228         8usize,
229         concat!(
230             "Size of template specialization: ",
231             stringify!(HandleWithDtor<::std::os::raw::c_int>)
232         )
233     );
234     assert_eq!(
235         ::std::mem::align_of::<HandleWithDtor<::std::os::raw::c_int>>(),
236         8usize,
237         concat!(
238             "Alignment of template specialization: ",
239             stringify!(HandleWithDtor<::std::os::raw::c_int>)
240         )
241     );
242 }