]>
Commit | Line | Data |
---|---|---|
f20569fa XL |
1 | // rustfmt-normalize_comments: true |
2 | // rustfmt-format_macro_matchers: true | |
3 | itemmacro!(this, is.now().formatted(yay)); | |
4 | ||
5 | itemmacro!( | |
6 | really, | |
7 | long.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbb() | |
8 | .is | |
9 | .formatted() | |
10 | ); | |
11 | ||
12 | itemmacro! {this, is.brace().formatted()} | |
13 | ||
14 | fn main() { | |
15 | foo!(); | |
16 | ||
17 | foo!(,); | |
18 | ||
19 | bar!(a, b, c); | |
20 | ||
21 | bar!(a, b, c,); | |
22 | ||
23 | baz!(1 + 2 + 3, quux.kaas()); | |
24 | ||
25 | quux!( | |
26 | AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA, | |
27 | BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB | |
28 | ); | |
29 | ||
30 | kaas!( | |
31 | // comments | |
32 | a, // post macro | |
33 | b // another | |
34 | ); | |
35 | ||
36 | trailingcomma!(a, b, c,); | |
37 | // Preserve trailing comma only when necessary. | |
38 | ok!(file.seek(SeekFrom::Start( | |
39 | table.map(|table| fixture.offset(table)).unwrap_or(0), | |
40 | ))); | |
41 | ||
42 | noexpr!( i am not an expression, OK? ); | |
43 | ||
44 | vec![a, b, c]; | |
45 | ||
46 | vec![ | |
47 | AAAAAA, | |
48 | AAAAAA, | |
49 | AAAAAA, | |
50 | AAAAAA, | |
51 | AAAAAA, | |
52 | AAAAAA, | |
53 | AAAAAA, | |
54 | AAAAAA, | |
55 | AAAAAA, | |
56 | BBBBB, | |
57 | 5, | |
58 | 100 - 30, | |
59 | 1.33, | |
60 | b, | |
61 | b, | |
62 | b, | |
63 | ]; | |
64 | ||
65 | vec![a /* comment */]; | |
66 | ||
67 | // Trailing spaces after a comma | |
68 | vec![a]; | |
69 | ||
70 | vec![a; b]; | |
71 | vec![a; b]; | |
72 | vec![a; b]; | |
73 | ||
74 | vec![a, b; c]; | |
75 | vec![a; b, c]; | |
76 | ||
77 | vec![ | |
78 | a; | |
79 | (|x| { | |
80 | let y = x + 1; | |
81 | let z = y + 1; | |
82 | z | |
83 | })(2) | |
84 | ]; | |
85 | vec![ | |
86 | a; | |
87 | xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx | |
88 | ]; | |
89 | vec![a; unsafe { x + 1 }]; | |
90 | ||
91 | unknown_bracket_macro__comma_should_not_be_stripped![a,]; | |
92 | ||
93 | foo(makro!(1, 3)); | |
94 | ||
95 | hamkaas! { () }; | |
96 | ||
97 | macrowithbraces! {dont, format, me} | |
98 | ||
99 | x!(fn); | |
100 | ||
101 | some_macro!(); | |
102 | ||
103 | some_macro![]; | |
104 | ||
105 | some_macro! { | |
106 | // comment | |
107 | }; | |
108 | ||
109 | some_macro! { | |
110 | // comment | |
111 | }; | |
112 | ||
113 | some_macro!( | |
114 | // comment | |
115 | not function like | |
116 | ); | |
117 | ||
118 | // #1712 | |
119 | let image = gray_image!( | |
120 | 00, 01, 02; | |
121 | 10, 11, 12; | |
122 | 20, 21, 22); | |
123 | ||
124 | // #1092 | |
125 | chain!(input, a: take!(max_size), || []); | |
126 | ||
127 | // #2727 | |
128 | foo!("bar"); | |
129 | } | |
130 | ||
131 | impl X { | |
132 | empty_invoc! {} | |
133 | empty_invoc! {} | |
134 | } | |
135 | ||
136 | fn issue_1279() { | |
137 | println!("dsfs"); // a comment | |
138 | } | |
139 | ||
140 | fn issue_1555() { | |
141 | let hello = &format!( | |
142 | "HTTP/1.1 200 OK\r\nServer: {}\r\n\r\n{}", | |
143 | "65454654654654654654654655464", "4" | |
144 | ); | |
145 | } | |
146 | ||
147 | fn issue1178() { | |
148 | macro_rules! foo { | |
149 | (#[$attr:meta] $name:ident) => {}; | |
150 | } | |
151 | ||
152 | foo!( | |
153 | #[doc = "bar"] | |
154 | baz | |
155 | ); | |
156 | } | |
157 | ||
158 | fn issue1739() { | |
159 | sql_function!( | |
160 | add_rss_item, | |
161 | add_rss_item_t, | |
162 | ( | |
163 | a: types::Integer, | |
164 | b: types::Timestamptz, | |
165 | c: types::Text, | |
166 | d: types::Text, | |
167 | e: types::Text | |
168 | ) | |
169 | ); | |
170 | ||
171 | w.slice_mut(s![ | |
172 | .., | |
173 | init_size[1] - extreeeeeeeeeeeeeeeeeeeeeeeem..init_size[1], | |
174 | .. | |
175 | ]) | |
176 | .par_map_inplace(|el| *el = 0.); | |
177 | } | |
178 | ||
179 | fn issue_1885() { | |
180 | let threads = people | |
181 | .into_iter() | |
182 | .map(|name| { | |
183 | chan_select! { | |
184 | rx.recv() => {} | |
185 | } | |
186 | }) | |
187 | .collect::<Vec<_>>(); | |
188 | } | |
189 | ||
190 | fn issue_1917() { | |
191 | mod x { | |
192 | quickcheck! { | |
193 | fn test(a: String, s: String, b: String) -> TestResult { | |
194 | if a.find(&s).is_none() { | |
195 | ||
196 | TestResult::from_bool(true) | |
197 | } else { | |
198 | TestResult::discard() | |
199 | } | |
200 | } | |
201 | } | |
202 | } | |
203 | } | |
204 | ||
205 | fn issue_1921() { | |
206 | // Macro with tabs. | |
207 | lazy_static! { | |
208 | static ref ONE: u32 = 1; | |
209 | static ref TWO: u32 = 2; | |
210 | static ref THREE: u32 = 3; | |
211 | static ref FOUR: u32 = { | |
212 | let mut acc = 1; | |
213 | acc += 1; | |
214 | acc += 2; | |
215 | acc | |
216 | }; | |
217 | } | |
218 | } | |
219 | ||
220 | // #1577 | |
221 | fn issue1577() { | |
222 | let json = json!({ | |
223 | "foo": "bar", | |
224 | }); | |
225 | } | |
226 | ||
227 | // #3174 | |
228 | fn issue_3174() { | |
229 | let data = if let Some(debug) = error.debug_info() { | |
230 | json!({ | |
231 | "errorKind": format!("{:?}", error.err_kind()), | |
232 | "debugMessage": debug.message, | |
233 | }) | |
234 | } else { | |
235 | json!({ "errorKind": format!("{:?}", error.err_kind()) }) | |
236 | }; | |
237 | } | |
238 | ||
239 | gfx_pipeline!(pipe { | |
240 | vbuf: gfx::VertexBuffer<Vertex> = (), | |
241 | out: gfx::RenderTarget<ColorFormat> = "Target0", | |
242 | }); | |
243 | ||
244 | // #1919 | |
245 | #[test] | |
246 | fn __bindgen_test_layout_HandleWithDtor_open0_int_close0_instantiation() { | |
247 | assert_eq!( | |
248 | ::std::mem::size_of::<HandleWithDtor<::std::os::raw::c_int>>(), | |
249 | 8usize, | |
250 | concat!( | |
251 | "Size of template specialization: ", | |
252 | stringify!(HandleWithDtor<::std::os::raw::c_int>) | |
253 | ) | |
254 | ); | |
255 | assert_eq!( | |
256 | ::std::mem::align_of::<HandleWithDtor<::std::os::raw::c_int>>(), | |
257 | 8usize, | |
258 | concat!( | |
259 | "Alignment of template specialization: ", | |
260 | stringify!(HandleWithDtor<::std::os::raw::c_int>) | |
261 | ) | |
262 | ); | |
263 | } | |
264 | ||
265 | // #878 | |
266 | macro_rules! try_opt { | |
267 | ($expr:expr) => { | |
268 | match $expr { | |
269 | Some(val) => val, | |
270 | ||
271 | None => { | |
272 | return None; | |
273 | } | |
274 | } | |
275 | }; | |
276 | } | |
277 | ||
278 | // #2214 | |
279 | // macro call whose argument is an array with trailing comma. | |
280 | fn issue2214() { | |
281 | make_test!( | |
282 | str_searcher_ascii_haystack, | |
283 | "bb", | |
284 | "abbcbbd", | |
285 | [ | |
286 | Reject(0, 1), | |
287 | Match(1, 3), | |
288 | Reject(3, 4), | |
289 | Match(4, 6), | |
290 | Reject(6, 7), | |
291 | ] | |
292 | ); | |
293 | } | |
294 | ||
295 | fn special_case_macros() { | |
296 | let p = eprint!(); | |
297 | let q = eprint!("{}", 1); | |
298 | let r = eprint!( | |
299 | "{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}", | |
300 | 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 | |
301 | ); | |
302 | let s = eprint!( | |
303 | "{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}", | |
304 | 1, | |
305 | 2, | |
306 | 3, | |
307 | 4, | |
308 | 5, | |
309 | 6, | |
310 | 7, | |
311 | 8, | |
312 | 9, | |
313 | 10, | |
314 | 11, | |
315 | 12, | |
316 | 13, | |
317 | 14, | |
318 | 15, | |
319 | 16, | |
320 | 17, | |
321 | 18, | |
322 | 19, | |
323 | 20, | |
324 | 21, | |
325 | 22, | |
326 | 23, | |
327 | 24, | |
328 | 25, | |
329 | 26 | |
330 | ); | |
331 | ||
332 | let q = eprintln!("{}", 1); | |
333 | let r = eprintln!( | |
334 | "{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}", | |
335 | 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 | |
336 | ); | |
337 | let s = eprintln!( | |
338 | "{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}", | |
339 | 1, | |
340 | 2, | |
341 | 3, | |
342 | 4, | |
343 | 5, | |
344 | 6, | |
345 | 7, | |
346 | 8, | |
347 | 9, | |
348 | 10, | |
349 | 11, | |
350 | 12, | |
351 | 13, | |
352 | 14, | |
353 | 15, | |
354 | 16, | |
355 | 17, | |
356 | 18, | |
357 | 19, | |
358 | 20, | |
359 | 21, | |
360 | 22, | |
361 | 23, | |
362 | 24, | |
363 | 25, | |
364 | 26 | |
365 | ); | |
366 | ||
367 | let q = format!("{}", 1); | |
368 | let r = format!( | |
369 | "{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}", | |
370 | 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 | |
371 | ); | |
372 | let s = format!( | |
373 | "{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}", | |
374 | 1, | |
375 | 2, | |
376 | 3, | |
377 | 4, | |
378 | 5, | |
379 | 6, | |
380 | 7, | |
381 | 8, | |
382 | 9, | |
383 | 10, | |
384 | 11, | |
385 | 12, | |
386 | 13, | |
387 | 14, | |
388 | 15, | |
389 | 16, | |
390 | 17, | |
391 | 18, | |
392 | 19, | |
393 | 20, | |
394 | 21, | |
395 | 22, | |
396 | 23, | |
397 | 24, | |
398 | 25, | |
399 | 26 | |
400 | ); | |
401 | ||
402 | let q = format_args!("{}", 1); | |
403 | let r = format_args!( | |
404 | "{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}", | |
405 | 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 | |
406 | ); | |
407 | let s = format_args!( | |
408 | "{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}", | |
409 | 1, | |
410 | 2, | |
411 | 3, | |
412 | 4, | |
413 | 5, | |
414 | 6, | |
415 | 7, | |
416 | 8, | |
417 | 9, | |
418 | 10, | |
419 | 11, | |
420 | 12, | |
421 | 13, | |
422 | 14, | |
423 | 15, | |
424 | 16, | |
425 | 17, | |
426 | 18, | |
427 | 19, | |
428 | 20, | |
429 | 21, | |
430 | 22, | |
431 | 23, | |
432 | 24, | |
433 | 25, | |
434 | 26 | |
435 | ); | |
436 | ||
437 | let q = print!("{}", 1); | |
438 | let r = print!( | |
439 | "{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}", | |
440 | 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 | |
441 | ); | |
442 | let s = print!( | |
443 | "{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}", | |
444 | 1, | |
445 | 2, | |
446 | 3, | |
447 | 4, | |
448 | 5, | |
449 | 6, | |
450 | 7, | |
451 | 8, | |
452 | 9, | |
453 | 10, | |
454 | 11, | |
455 | 12, | |
456 | 13, | |
457 | 14, | |
458 | 15, | |
459 | 16, | |
460 | 17, | |
461 | 18, | |
462 | 19, | |
463 | 20, | |
464 | 21, | |
465 | 22, | |
466 | 23, | |
467 | 24, | |
468 | 25, | |
469 | 26 | |
470 | ); | |
471 | ||
472 | let q = println!("{}", 1); | |
473 | let r = println!( | |
474 | "{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}", | |
475 | 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 | |
476 | ); | |
477 | let s = println!( | |
478 | "{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}", | |
479 | 1, | |
480 | 2, | |
481 | 3, | |
482 | 4, | |
483 | 5, | |
484 | 6, | |
485 | 7, | |
486 | 8, | |
487 | 9, | |
488 | 10, | |
489 | 11, | |
490 | 12, | |
491 | 13, | |
492 | 14, | |
493 | 15, | |
494 | 16, | |
495 | 17, | |
496 | 18, | |
497 | 19, | |
498 | 20, | |
499 | 21, | |
500 | 22, | |
501 | 23, | |
502 | 24, | |
503 | 25, | |
504 | 26 | |
505 | ); | |
506 | ||
507 | let q = unreachable!("{}", 1); | |
508 | let r = unreachable!( | |
509 | "{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}", | |
510 | 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 | |
511 | ); | |
512 | let s = unreachable!( | |
513 | "{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}", | |
514 | 1, | |
515 | 2, | |
516 | 3, | |
517 | 4, | |
518 | 5, | |
519 | 6, | |
520 | 7, | |
521 | 8, | |
522 | 9, | |
523 | 10, | |
524 | 11, | |
525 | 12, | |
526 | 13, | |
527 | 14, | |
528 | 15, | |
529 | 16, | |
530 | 17, | |
531 | 18, | |
532 | 19, | |
533 | 20, | |
534 | 21, | |
535 | 22, | |
536 | 23, | |
537 | 24, | |
538 | 25, | |
539 | 26 | |
540 | ); | |
541 | ||
542 | debug!("{}", 1); | |
543 | debug!( | |
544 | "{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}", | |
545 | 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 | |
546 | ); | |
547 | debug!( | |
548 | "{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}", | |
549 | 1, | |
550 | 2, | |
551 | 3, | |
552 | 4, | |
553 | 5, | |
554 | 6, | |
555 | 7, | |
556 | 8, | |
557 | 9, | |
558 | 10, | |
559 | 11, | |
560 | 12, | |
561 | 13, | |
562 | 14, | |
563 | 15, | |
564 | 16, | |
565 | 17, | |
566 | 18, | |
567 | 19, | |
568 | 20, | |
569 | 21, | |
570 | 22, | |
571 | 23, | |
572 | 24, | |
573 | 25, | |
574 | 26 | |
575 | ); | |
576 | ||
577 | error!("{}", 1); | |
578 | error!( | |
579 | "{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}", | |
580 | 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 | |
581 | ); | |
582 | error!( | |
583 | "{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}", | |
584 | 1, | |
585 | 2, | |
586 | 3, | |
587 | 4, | |
588 | 5, | |
589 | 6, | |
590 | 7, | |
591 | 8, | |
592 | 9, | |
593 | 10, | |
594 | 11, | |
595 | 12, | |
596 | 13, | |
597 | 14, | |
598 | 15, | |
599 | 16, | |
600 | 17, | |
601 | 18, | |
602 | 19, | |
603 | 20, | |
604 | 21, | |
605 | 22, | |
606 | 23, | |
607 | 24, | |
608 | 25, | |
609 | 26 | |
610 | ); | |
611 | ||
612 | info!("{}", 1); | |
613 | info!( | |
614 | "{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}", | |
615 | 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 | |
616 | ); | |
617 | info!( | |
618 | "{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}", | |
619 | 1, | |
620 | 2, | |
621 | 3, | |
622 | 4, | |
623 | 5, | |
624 | 6, | |
625 | 7, | |
626 | 8, | |
627 | 9, | |
628 | 10, | |
629 | 11, | |
630 | 12, | |
631 | 13, | |
632 | 14, | |
633 | 15, | |
634 | 16, | |
635 | 17, | |
636 | 18, | |
637 | 19, | |
638 | 20, | |
639 | 21, | |
640 | 22, | |
641 | 23, | |
642 | 24, | |
643 | 25, | |
644 | 26 | |
645 | ); | |
646 | ||
647 | panic!("{}", 1); | |
648 | panic!( | |
649 | "{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}", | |
650 | 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 | |
651 | ); | |
652 | panic!( | |
653 | "{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}", | |
654 | 1, | |
655 | 2, | |
656 | 3, | |
657 | 4, | |
658 | 5, | |
659 | 6, | |
660 | 7, | |
661 | 8, | |
662 | 9, | |
663 | 10, | |
664 | 11, | |
665 | 12, | |
666 | 13, | |
667 | 14, | |
668 | 15, | |
669 | 16, | |
670 | 17, | |
671 | 18, | |
672 | 19, | |
673 | 20, | |
674 | 21, | |
675 | 22, | |
676 | 23, | |
677 | 24, | |
678 | 25, | |
679 | 26 | |
680 | ); | |
681 | ||
682 | warn!("{}", 1); | |
683 | warn!( | |
684 | "{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}", | |
685 | 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 | |
686 | ); | |
687 | warn!( | |
688 | "{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}", | |
689 | 1, | |
690 | 2, | |
691 | 3, | |
692 | 4, | |
693 | 5, | |
694 | 6, | |
695 | 7, | |
696 | 8, | |
697 | 9, | |
698 | 10, | |
699 | 11, | |
700 | 12, | |
701 | 13, | |
702 | 14, | |
703 | 15, | |
704 | 16, | |
705 | 17, | |
706 | 18, | |
707 | 19, | |
708 | 20, | |
709 | 21, | |
710 | 22, | |
711 | 23, | |
712 | 24, | |
713 | 25, | |
714 | 26 | |
715 | ); | |
716 | ||
717 | assert!(); | |
718 | assert!(result == 42); | |
719 | assert!(result == 42, "Ahoy there, {}!", target); | |
720 | assert!( | |
721 | result == 42, | |
722 | "Arr! While plunderin' the hold, we got '{}' when given '{}' (we expected '{}')", | |
723 | result, | |
724 | input, | |
725 | expected | |
726 | ); | |
727 | assert!( | |
728 | result == 42, | |
729 | "{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}", | |
730 | 1, | |
731 | 2, | |
732 | 3, | |
733 | 4, | |
734 | 5, | |
735 | 6, | |
736 | 7, | |
737 | 8, | |
738 | 9, | |
739 | 10, | |
740 | 11, | |
741 | 12, | |
742 | 13, | |
743 | 14, | |
744 | 15, | |
745 | 16, | |
746 | 17, | |
747 | 18, | |
748 | 19, | |
749 | 20, | |
750 | 21, | |
751 | 22, | |
752 | 23, | |
753 | 24, | |
754 | 25, | |
755 | 26 | |
756 | ); | |
757 | ||
758 | assert_eq!(); | |
759 | assert_eq!(left); | |
760 | assert_eq!(left, right); | |
761 | assert_eq!(left, right, "Ahoy there, {}!", target); | |
762 | assert_eq!( | |
763 | left, right, | |
764 | "Arr! While plunderin' the hold, we got '{}' when given '{}' (we expected '{}')", | |
765 | result, input, expected | |
766 | ); | |
767 | assert_eq!( | |
768 | first_realllllllllllly_long_variable_that_doesnt_fit_one_one_line, | |
769 | second_reallllllllllly_long_variable_that_doesnt_fit_one_one_line, | |
770 | "Arr! While plunderin' the hold, we got '{}' when given '{}' (we expected '{}')", | |
771 | result, | |
772 | input, | |
773 | expected | |
774 | ); | |
775 | assert_eq!( | |
776 | left + 42, | |
777 | right, | |
778 | "Arr! While plunderin' the hold, we got '{}' when given '{}' (we expected '{}')", | |
779 | result, | |
780 | input, | |
781 | expected | |
782 | ); | |
783 | assert_eq!( | |
784 | left, | |
785 | right, | |
786 | "{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}", | |
787 | 1, | |
788 | 2, | |
789 | 3, | |
790 | 4, | |
791 | 5, | |
792 | 6, | |
793 | 7, | |
794 | 8, | |
795 | 9, | |
796 | 10, | |
797 | 11, | |
798 | 12, | |
799 | 13, | |
800 | 14, | |
801 | 15, | |
802 | 16, | |
803 | 17, | |
804 | 18, | |
805 | 19, | |
806 | 20, | |
807 | 21, | |
808 | 22, | |
809 | 23, | |
810 | 24, | |
811 | 25, | |
812 | 26 | |
813 | ); | |
814 | ||
815 | write!(&mut s, "Ahoy there, {}!", target); | |
816 | write!( | |
817 | &mut s, | |
818 | "Arr! While plunderin' the hold, we got '{}' when given '{}' (we expected '{}')", | |
819 | result, input, expected | |
820 | ); | |
821 | write!( | |
822 | &mut s, | |
823 | "{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}", | |
824 | 1, | |
825 | 2, | |
826 | 3, | |
827 | 4, | |
828 | 5, | |
829 | 6, | |
830 | 7, | |
831 | 8, | |
832 | 9, | |
833 | 10, | |
834 | 11, | |
835 | 12, | |
836 | 13, | |
837 | 14, | |
838 | 15, | |
839 | 16, | |
840 | 17, | |
841 | 18, | |
842 | 19, | |
843 | 20, | |
844 | 21, | |
845 | 22, | |
846 | 23, | |
847 | 24, | |
848 | 25, | |
849 | 26 | |
850 | ); | |
851 | ||
852 | writeln!(&mut s, "Ahoy there, {}!", target); | |
853 | writeln!( | |
854 | &mut s, | |
855 | "Arr! While plunderin' the hold, we got '{}' when given '{}' (we expected '{}')", | |
856 | result, input, expected | |
857 | ); | |
858 | writeln!( | |
859 | &mut s, | |
860 | "{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}", | |
861 | 1, | |
862 | 2, | |
863 | 3, | |
864 | 4, | |
865 | 5, | |
866 | 6, | |
867 | 7, | |
868 | 8, | |
869 | 9, | |
870 | 10, | |
871 | 11, | |
872 | 12, | |
873 | 13, | |
874 | 14, | |
875 | 15, | |
876 | 16, | |
877 | 17, | |
878 | 18, | |
879 | 19, | |
880 | 20, | |
881 | 21, | |
882 | 22, | |
883 | 23, | |
884 | 24, | |
885 | 25, | |
886 | 26 | |
887 | ); | |
888 | } | |
889 | ||
890 | // #1209 | |
891 | impl Foo { | |
892 | /// foo | |
893 | pub fn foo(&self) -> Bar<foo!()> {} | |
894 | } | |
895 | ||
896 | // #819 | |
897 | fn macro_in_pattern_position() { | |
898 | let x = match y { | |
899 | foo!() => (), | |
900 | bar!(a, b, c) => (), | |
901 | bar!(a, b, c,) => (), | |
902 | baz!(1 + 2 + 3, quux.kaas()) => (), | |
903 | quux!( | |
904 | AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA, | |
905 | BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB | |
906 | ) => (), | |
907 | }; | |
908 | } | |
909 | ||
910 | macro foo() {} | |
911 | ||
912 | pub macro bar($x:ident + $y:expr;) { | |
913 | fn foo($x: Foo) { | |
914 | long_function( | |
915 | a_long_argument_to_a_long_function_is_what_this_is(AAAAAAAAAAAAAAAAAAAAAAAAAAAA), | |
916 | $x.bar($y), | |
917 | ); | |
918 | } | |
919 | } | |
920 | ||
921 | macro foo() { | |
922 | // a comment | |
923 | fn foo() { | |
924 | // another comment | |
925 | bar(); | |
926 | } | |
927 | } | |
928 | ||
929 | // #2574 | |
930 | macro_rules! test { | |
931 | () => {{}}; | |
932 | } | |
933 | ||
934 | macro lex_err($kind: ident $(, $body: expr)*) { | |
935 | Err(QlError::LexError(LexError::$kind($($body,)*))) | |
936 | } | |
937 | ||
938 | // Preserve trailing comma on item-level macro with `()` or `[]`. | |
939 | methods![get, post, delete,]; | |
940 | methods!(get, post, delete,); | |
941 | ||
942 | // #2588 | |
943 | macro_rules! m { | |
944 | () => { | |
945 | r#" | |
946 | test | |
947 | "# | |
948 | }; | |
949 | } | |
950 | fn foo() { | |
951 | f! {r#" | |
952 | test | |
953 | "#}; | |
954 | } | |
955 | ||
956 | // #2591 | |
957 | fn foo() { | |
958 | match 0u32 { | |
959 | 0 => (), | |
960 | _ => unreachable!(/* obviously */), | |
961 | } | |
962 | } | |
963 | ||
964 | fn foo() { | |
965 | let _ = column!(/* here */); | |
966 | } | |
967 | ||
968 | // #2616 | |
969 | // Preserve trailing comma when using mixed layout for macro call. | |
970 | fn foo() { | |
971 | foo!( | |
972 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | |
973 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 | |
974 | ); | |
975 | foo!( | |
976 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | |
977 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | |
978 | ); | |
979 | } | |
980 | ||
981 | // #2830 | |
982 | // Preserve trailing comma-less/ness inside nested macro. | |
983 | named!( | |
984 | do_parse_gsv<GsvData>, | |
985 | map_res!( | |
986 | do_parse!( | |
987 | number_of_sentences: map_res!(digit, parse_num::<u16>) | |
988 | >> char!(',') | |
989 | >> sentence_index: map_res!(digit, parse_num::<u16>) | |
990 | >> char!(',') | |
991 | >> total_number_of_sats: map_res!(digit, parse_num::<u16>) | |
992 | >> char!(',') | |
993 | >> sat0: opt!(complete!(parse_gsv_sat_info)) | |
994 | >> sat1: opt!(complete!(parse_gsv_sat_info)) | |
995 | >> sat2: opt!(complete!(parse_gsv_sat_info)) | |
996 | >> sat3: opt!(complete!(parse_gsv_sat_info)) | |
997 | >> ( | |
998 | number_of_sentences, | |
999 | sentence_index, | |
1000 | total_number_of_sats, | |
1001 | sat0, | |
1002 | sat1, | |
1003 | sat2, | |
1004 | sat3 | |
1005 | ) | |
1006 | ), | |
1007 | construct_gsv_data | |
1008 | ) | |
1009 | ); | |
1010 | ||
1011 | // #2857 | |
1012 | convert_args!(vec!(1, 2, 3)); | |
1013 | ||
1014 | // #3031 | |
1015 | thread_local!( | |
1016 | /// TLV Holds a set of JSTraceables that need to be rooted | |
1017 | static ROOTED_TRACEABLES: RefCell<RootedTraceableSet> = RefCell::new(RootedTraceableSet::new()); | |
1018 | ); | |
1019 | ||
1020 | thread_local![ | |
1021 | /// TLV Holds a set of JSTraceables that need to be rooted | |
1022 | static ROOTED_TRACEABLES: RefCell<RootedTraceableSet> = RefCell::new(RootedTraceableSet::new()); | |
1023 | ||
1024 | /// TLV Holds a set of JSTraceables that need to be rooted | |
1025 | static ROOTED_TRACEABLES: RefCell<RootedTraceableSet> = | |
1026 | RefCell::new(RootedTraceableSet::new(0)); | |
1027 | ||
1028 | /// TLV Holds a set of JSTraceables that need to be rooted | |
1029 | static ROOTED_TRACEABLES: RefCell<RootedTraceableSet> = | |
1030 | RefCell::new(RootedTraceableSet::new(), xxx, yyy); | |
1031 | ||
1032 | /// TLV Holds a set of JSTraceables that need to be rooted | |
1033 | static ROOTED_TRACEABLES: RefCell<RootedTraceableSet> = | |
1034 | RefCell::new(RootedTraceableSet::new(1234)); | |
1035 | ]; | |
1036 | ||
1037 | fn issue3004() { | |
1038 | foo!(|_| { () }); | |
1039 | stringify!((foo+)); | |
1040 | } | |
1041 | ||
1042 | // #3331 | |
1043 | pub fn fold_abi<V: Fold + ?Sized>(_visitor: &mut V, _i: Abi) -> Abi { | |
1044 | Abi { | |
1045 | extern_token: Token![extern](tokens_helper(_visitor, &_i.extern_token.span)), | |
1046 | name: (_i.name).map(|it| _visitor.fold_lit_str(it)), | |
1047 | } | |
1048 | } | |
1049 | ||
1050 | // #3463 | |
1051 | x! {()} | |
1052 | ||
1053 | // #3746 | |
1054 | f!(match a { | |
1055 | 4 => &[ | |
1056 | (3, false), // Missing | |
1057 | (4, true) // I-frame | |
1058 | ][..], | |
1059 | }); | |
1060 | ||
1061 | // #3583 | |
1062 | foo!(|x = y|); |