diff options
Diffstat (limited to 'crates/ra_assists/src/tests/generated.rs')
-rw-r--r-- | crates/ra_assists/src/tests/generated.rs | 762 |
1 files changed, 762 insertions, 0 deletions
diff --git a/crates/ra_assists/src/tests/generated.rs b/crates/ra_assists/src/tests/generated.rs new file mode 100644 index 000000000..972dbd251 --- /dev/null +++ b/crates/ra_assists/src/tests/generated.rs | |||
@@ -0,0 +1,762 @@ | |||
1 | //! Generated file, do not edit by hand, see `xtask/src/codegen` | ||
2 | |||
3 | use super::check_doc_test; | ||
4 | |||
5 | #[test] | ||
6 | fn doctest_add_custom_impl() { | ||
7 | check_doc_test( | ||
8 | "add_custom_impl", | ||
9 | r#####" | ||
10 | #[derive(Deb<|>ug, Display)] | ||
11 | struct S; | ||
12 | "#####, | ||
13 | r#####" | ||
14 | #[derive(Display)] | ||
15 | struct S; | ||
16 | |||
17 | impl Debug for S { | ||
18 | |||
19 | } | ||
20 | "#####, | ||
21 | ) | ||
22 | } | ||
23 | |||
24 | #[test] | ||
25 | fn doctest_add_derive() { | ||
26 | check_doc_test( | ||
27 | "add_derive", | ||
28 | r#####" | ||
29 | struct Point { | ||
30 | x: u32, | ||
31 | y: u32,<|> | ||
32 | } | ||
33 | "#####, | ||
34 | r#####" | ||
35 | #[derive()] | ||
36 | struct Point { | ||
37 | x: u32, | ||
38 | y: u32, | ||
39 | } | ||
40 | "#####, | ||
41 | ) | ||
42 | } | ||
43 | |||
44 | #[test] | ||
45 | fn doctest_add_explicit_type() { | ||
46 | check_doc_test( | ||
47 | "add_explicit_type", | ||
48 | r#####" | ||
49 | fn main() { | ||
50 | let x<|> = 92; | ||
51 | } | ||
52 | "#####, | ||
53 | r#####" | ||
54 | fn main() { | ||
55 | let x: i32 = 92; | ||
56 | } | ||
57 | "#####, | ||
58 | ) | ||
59 | } | ||
60 | |||
61 | #[test] | ||
62 | fn doctest_add_function() { | ||
63 | check_doc_test( | ||
64 | "add_function", | ||
65 | r#####" | ||
66 | struct Baz; | ||
67 | fn baz() -> Baz { Baz } | ||
68 | fn foo() { | ||
69 | bar<|>("", baz()); | ||
70 | } | ||
71 | |||
72 | "#####, | ||
73 | r#####" | ||
74 | struct Baz; | ||
75 | fn baz() -> Baz { Baz } | ||
76 | fn foo() { | ||
77 | bar("", baz()); | ||
78 | } | ||
79 | |||
80 | fn bar(arg: &str, baz: Baz) { | ||
81 | todo!() | ||
82 | } | ||
83 | |||
84 | "#####, | ||
85 | ) | ||
86 | } | ||
87 | |||
88 | #[test] | ||
89 | fn doctest_add_hash() { | ||
90 | check_doc_test( | ||
91 | "add_hash", | ||
92 | r#####" | ||
93 | fn main() { | ||
94 | r#"Hello,<|> World!"#; | ||
95 | } | ||
96 | "#####, | ||
97 | r#####" | ||
98 | fn main() { | ||
99 | r##"Hello, World!"##; | ||
100 | } | ||
101 | "#####, | ||
102 | ) | ||
103 | } | ||
104 | |||
105 | #[test] | ||
106 | fn doctest_add_impl() { | ||
107 | check_doc_test( | ||
108 | "add_impl", | ||
109 | r#####" | ||
110 | struct Ctx<T: Clone> { | ||
111 | data: T,<|> | ||
112 | } | ||
113 | "#####, | ||
114 | r#####" | ||
115 | struct Ctx<T: Clone> { | ||
116 | data: T, | ||
117 | } | ||
118 | |||
119 | impl<T: Clone> Ctx<T> { | ||
120 | |||
121 | } | ||
122 | "#####, | ||
123 | ) | ||
124 | } | ||
125 | |||
126 | #[test] | ||
127 | fn doctest_add_impl_default_members() { | ||
128 | check_doc_test( | ||
129 | "add_impl_default_members", | ||
130 | r#####" | ||
131 | trait Trait { | ||
132 | Type X; | ||
133 | fn foo(&self); | ||
134 | fn bar(&self) {} | ||
135 | } | ||
136 | |||
137 | impl Trait for () { | ||
138 | Type X = (); | ||
139 | fn foo(&self) {}<|> | ||
140 | |||
141 | } | ||
142 | "#####, | ||
143 | r#####" | ||
144 | trait Trait { | ||
145 | Type X; | ||
146 | fn foo(&self); | ||
147 | fn bar(&self) {} | ||
148 | } | ||
149 | |||
150 | impl Trait for () { | ||
151 | Type X = (); | ||
152 | fn foo(&self) {} | ||
153 | fn bar(&self) {} | ||
154 | |||
155 | } | ||
156 | "#####, | ||
157 | ) | ||
158 | } | ||
159 | |||
160 | #[test] | ||
161 | fn doctest_add_impl_missing_members() { | ||
162 | check_doc_test( | ||
163 | "add_impl_missing_members", | ||
164 | r#####" | ||
165 | trait Trait<T> { | ||
166 | Type X; | ||
167 | fn foo(&self) -> T; | ||
168 | fn bar(&self) {} | ||
169 | } | ||
170 | |||
171 | impl Trait<u32> for () {<|> | ||
172 | |||
173 | } | ||
174 | "#####, | ||
175 | r#####" | ||
176 | trait Trait<T> { | ||
177 | Type X; | ||
178 | fn foo(&self) -> T; | ||
179 | fn bar(&self) {} | ||
180 | } | ||
181 | |||
182 | impl Trait<u32> for () { | ||
183 | fn foo(&self) -> u32 { | ||
184 | todo!() | ||
185 | } | ||
186 | |||
187 | } | ||
188 | "#####, | ||
189 | ) | ||
190 | } | ||
191 | |||
192 | #[test] | ||
193 | fn doctest_add_new() { | ||
194 | check_doc_test( | ||
195 | "add_new", | ||
196 | r#####" | ||
197 | struct Ctx<T: Clone> { | ||
198 | data: T,<|> | ||
199 | } | ||
200 | "#####, | ||
201 | r#####" | ||
202 | struct Ctx<T: Clone> { | ||
203 | data: T, | ||
204 | } | ||
205 | |||
206 | impl<T: Clone> Ctx<T> { | ||
207 | fn new(data: T) -> Self { Self { data } } | ||
208 | } | ||
209 | |||
210 | "#####, | ||
211 | ) | ||
212 | } | ||
213 | |||
214 | #[test] | ||
215 | fn doctest_apply_demorgan() { | ||
216 | check_doc_test( | ||
217 | "apply_demorgan", | ||
218 | r#####" | ||
219 | fn main() { | ||
220 | if x != 4 ||<|> !y {} | ||
221 | } | ||
222 | "#####, | ||
223 | r#####" | ||
224 | fn main() { | ||
225 | if !(x == 4 && y) {} | ||
226 | } | ||
227 | "#####, | ||
228 | ) | ||
229 | } | ||
230 | |||
231 | #[test] | ||
232 | fn doctest_auto_import() { | ||
233 | check_doc_test( | ||
234 | "auto_import", | ||
235 | r#####" | ||
236 | fn main() { | ||
237 | let map = HashMap<|>::new(); | ||
238 | } | ||
239 | pub mod std { pub mod collections { pub struct HashMap { } } } | ||
240 | "#####, | ||
241 | r#####" | ||
242 | use std::collections::HashMap; | ||
243 | |||
244 | fn main() { | ||
245 | let map = HashMap::new(); | ||
246 | } | ||
247 | pub mod std { pub mod collections { pub struct HashMap { } } } | ||
248 | "#####, | ||
249 | ) | ||
250 | } | ||
251 | |||
252 | #[test] | ||
253 | fn doctest_change_return_type_to_result() { | ||
254 | check_doc_test( | ||
255 | "change_return_type_to_result", | ||
256 | r#####" | ||
257 | fn foo() -> i32<|> { 42i32 } | ||
258 | "#####, | ||
259 | r#####" | ||
260 | fn foo() -> Result<i32, > { Ok(42i32) } | ||
261 | "#####, | ||
262 | ) | ||
263 | } | ||
264 | |||
265 | #[test] | ||
266 | fn doctest_change_visibility() { | ||
267 | check_doc_test( | ||
268 | "change_visibility", | ||
269 | r#####" | ||
270 | <|>fn frobnicate() {} | ||
271 | "#####, | ||
272 | r#####" | ||
273 | pub(crate) fn frobnicate() {} | ||
274 | "#####, | ||
275 | ) | ||
276 | } | ||
277 | |||
278 | #[test] | ||
279 | fn doctest_convert_to_guarded_return() { | ||
280 | check_doc_test( | ||
281 | "convert_to_guarded_return", | ||
282 | r#####" | ||
283 | fn main() { | ||
284 | <|>if cond { | ||
285 | foo(); | ||
286 | bar(); | ||
287 | } | ||
288 | } | ||
289 | "#####, | ||
290 | r#####" | ||
291 | fn main() { | ||
292 | if !cond { | ||
293 | return; | ||
294 | } | ||
295 | foo(); | ||
296 | bar(); | ||
297 | } | ||
298 | "#####, | ||
299 | ) | ||
300 | } | ||
301 | |||
302 | #[test] | ||
303 | fn doctest_fill_match_arms() { | ||
304 | check_doc_test( | ||
305 | "fill_match_arms", | ||
306 | r#####" | ||
307 | enum Action { Move { distance: u32 }, Stop } | ||
308 | |||
309 | fn handle(action: Action) { | ||
310 | match action { | ||
311 | <|> | ||
312 | } | ||
313 | } | ||
314 | "#####, | ||
315 | r#####" | ||
316 | enum Action { Move { distance: u32 }, Stop } | ||
317 | |||
318 | fn handle(action: Action) { | ||
319 | match action { | ||
320 | Action::Move { distance } => {} | ||
321 | Action::Stop => {} | ||
322 | } | ||
323 | } | ||
324 | "#####, | ||
325 | ) | ||
326 | } | ||
327 | |||
328 | #[test] | ||
329 | fn doctest_flip_binexpr() { | ||
330 | check_doc_test( | ||
331 | "flip_binexpr", | ||
332 | r#####" | ||
333 | fn main() { | ||
334 | let _ = 90 +<|> 2; | ||
335 | } | ||
336 | "#####, | ||
337 | r#####" | ||
338 | fn main() { | ||
339 | let _ = 2 + 90; | ||
340 | } | ||
341 | "#####, | ||
342 | ) | ||
343 | } | ||
344 | |||
345 | #[test] | ||
346 | fn doctest_flip_comma() { | ||
347 | check_doc_test( | ||
348 | "flip_comma", | ||
349 | r#####" | ||
350 | fn main() { | ||
351 | ((1, 2),<|> (3, 4)); | ||
352 | } | ||
353 | "#####, | ||
354 | r#####" | ||
355 | fn main() { | ||
356 | ((3, 4), (1, 2)); | ||
357 | } | ||
358 | "#####, | ||
359 | ) | ||
360 | } | ||
361 | |||
362 | #[test] | ||
363 | fn doctest_flip_trait_bound() { | ||
364 | check_doc_test( | ||
365 | "flip_trait_bound", | ||
366 | r#####" | ||
367 | fn foo<T: Clone +<|> Copy>() { } | ||
368 | "#####, | ||
369 | r#####" | ||
370 | fn foo<T: Copy + Clone>() { } | ||
371 | "#####, | ||
372 | ) | ||
373 | } | ||
374 | |||
375 | #[test] | ||
376 | fn doctest_inline_local_variable() { | ||
377 | check_doc_test( | ||
378 | "inline_local_variable", | ||
379 | r#####" | ||
380 | fn main() { | ||
381 | let x<|> = 1 + 2; | ||
382 | x * 4; | ||
383 | } | ||
384 | "#####, | ||
385 | r#####" | ||
386 | fn main() { | ||
387 | (1 + 2) * 4; | ||
388 | } | ||
389 | "#####, | ||
390 | ) | ||
391 | } | ||
392 | |||
393 | #[test] | ||
394 | fn doctest_introduce_variable() { | ||
395 | check_doc_test( | ||
396 | "introduce_variable", | ||
397 | r#####" | ||
398 | fn main() { | ||
399 | <|>(1 + 2)<|> * 4; | ||
400 | } | ||
401 | "#####, | ||
402 | r#####" | ||
403 | fn main() { | ||
404 | let var_name = (1 + 2); | ||
405 | var_name * 4; | ||
406 | } | ||
407 | "#####, | ||
408 | ) | ||
409 | } | ||
410 | |||
411 | #[test] | ||
412 | fn doctest_invert_if() { | ||
413 | check_doc_test( | ||
414 | "invert_if", | ||
415 | r#####" | ||
416 | fn main() { | ||
417 | if<|> !y { A } else { B } | ||
418 | } | ||
419 | "#####, | ||
420 | r#####" | ||
421 | fn main() { | ||
422 | if y { B } else { A } | ||
423 | } | ||
424 | "#####, | ||
425 | ) | ||
426 | } | ||
427 | |||
428 | #[test] | ||
429 | fn doctest_make_raw_string() { | ||
430 | check_doc_test( | ||
431 | "make_raw_string", | ||
432 | r#####" | ||
433 | fn main() { | ||
434 | "Hello,<|> World!"; | ||
435 | } | ||
436 | "#####, | ||
437 | r#####" | ||
438 | fn main() { | ||
439 | r#"Hello, World!"#; | ||
440 | } | ||
441 | "#####, | ||
442 | ) | ||
443 | } | ||
444 | |||
445 | #[test] | ||
446 | fn doctest_make_usual_string() { | ||
447 | check_doc_test( | ||
448 | "make_usual_string", | ||
449 | r#####" | ||
450 | fn main() { | ||
451 | r#"Hello,<|> "World!""#; | ||
452 | } | ||
453 | "#####, | ||
454 | r#####" | ||
455 | fn main() { | ||
456 | "Hello, \"World!\""; | ||
457 | } | ||
458 | "#####, | ||
459 | ) | ||
460 | } | ||
461 | |||
462 | #[test] | ||
463 | fn doctest_merge_imports() { | ||
464 | check_doc_test( | ||
465 | "merge_imports", | ||
466 | r#####" | ||
467 | use std::<|>fmt::Formatter; | ||
468 | use std::io; | ||
469 | "#####, | ||
470 | r#####" | ||
471 | use std::{fmt::Formatter, io}; | ||
472 | "#####, | ||
473 | ) | ||
474 | } | ||
475 | |||
476 | #[test] | ||
477 | fn doctest_merge_match_arms() { | ||
478 | check_doc_test( | ||
479 | "merge_match_arms", | ||
480 | r#####" | ||
481 | enum Action { Move { distance: u32 }, Stop } | ||
482 | |||
483 | fn handle(action: Action) { | ||
484 | match action { | ||
485 | <|>Action::Move(..) => foo(), | ||
486 | Action::Stop => foo(), | ||
487 | } | ||
488 | } | ||
489 | "#####, | ||
490 | r#####" | ||
491 | enum Action { Move { distance: u32 }, Stop } | ||
492 | |||
493 | fn handle(action: Action) { | ||
494 | match action { | ||
495 | Action::Move(..) | Action::Stop => foo(), | ||
496 | } | ||
497 | } | ||
498 | "#####, | ||
499 | ) | ||
500 | } | ||
501 | |||
502 | #[test] | ||
503 | fn doctest_move_arm_cond_to_match_guard() { | ||
504 | check_doc_test( | ||
505 | "move_arm_cond_to_match_guard", | ||
506 | r#####" | ||
507 | enum Action { Move { distance: u32 }, Stop } | ||
508 | |||
509 | fn handle(action: Action) { | ||
510 | match action { | ||
511 | Action::Move { distance } => <|>if distance > 10 { foo() }, | ||
512 | _ => (), | ||
513 | } | ||
514 | } | ||
515 | "#####, | ||
516 | r#####" | ||
517 | enum Action { Move { distance: u32 }, Stop } | ||
518 | |||
519 | fn handle(action: Action) { | ||
520 | match action { | ||
521 | Action::Move { distance } if distance > 10 => foo(), | ||
522 | _ => (), | ||
523 | } | ||
524 | } | ||
525 | "#####, | ||
526 | ) | ||
527 | } | ||
528 | |||
529 | #[test] | ||
530 | fn doctest_move_bounds_to_where_clause() { | ||
531 | check_doc_test( | ||
532 | "move_bounds_to_where_clause", | ||
533 | r#####" | ||
534 | fn apply<T, U, <|>F: FnOnce(T) -> U>(f: F, x: T) -> U { | ||
535 | f(x) | ||
536 | } | ||
537 | "#####, | ||
538 | r#####" | ||
539 | fn apply<T, U, F>(f: F, x: T) -> U where F: FnOnce(T) -> U { | ||
540 | f(x) | ||
541 | } | ||
542 | "#####, | ||
543 | ) | ||
544 | } | ||
545 | |||
546 | #[test] | ||
547 | fn doctest_move_guard_to_arm_body() { | ||
548 | check_doc_test( | ||
549 | "move_guard_to_arm_body", | ||
550 | r#####" | ||
551 | enum Action { Move { distance: u32 }, Stop } | ||
552 | |||
553 | fn handle(action: Action) { | ||
554 | match action { | ||
555 | Action::Move { distance } <|>if distance > 10 => foo(), | ||
556 | _ => (), | ||
557 | } | ||
558 | } | ||
559 | "#####, | ||
560 | r#####" | ||
561 | enum Action { Move { distance: u32 }, Stop } | ||
562 | |||
563 | fn handle(action: Action) { | ||
564 | match action { | ||
565 | Action::Move { distance } => if distance > 10 { foo() }, | ||
566 | _ => (), | ||
567 | } | ||
568 | } | ||
569 | "#####, | ||
570 | ) | ||
571 | } | ||
572 | |||
573 | #[test] | ||
574 | fn doctest_remove_dbg() { | ||
575 | check_doc_test( | ||
576 | "remove_dbg", | ||
577 | r#####" | ||
578 | fn main() { | ||
579 | <|>dbg!(92); | ||
580 | } | ||
581 | "#####, | ||
582 | r#####" | ||
583 | fn main() { | ||
584 | 92; | ||
585 | } | ||
586 | "#####, | ||
587 | ) | ||
588 | } | ||
589 | |||
590 | #[test] | ||
591 | fn doctest_remove_hash() { | ||
592 | check_doc_test( | ||
593 | "remove_hash", | ||
594 | r#####" | ||
595 | fn main() { | ||
596 | r#"Hello,<|> World!"#; | ||
597 | } | ||
598 | "#####, | ||
599 | r#####" | ||
600 | fn main() { | ||
601 | r"Hello, World!"; | ||
602 | } | ||
603 | "#####, | ||
604 | ) | ||
605 | } | ||
606 | |||
607 | #[test] | ||
608 | fn doctest_remove_mut() { | ||
609 | check_doc_test( | ||
610 | "remove_mut", | ||
611 | r#####" | ||
612 | impl Walrus { | ||
613 | fn feed(&mut<|> self, amount: u32) {} | ||
614 | } | ||
615 | "#####, | ||
616 | r#####" | ||
617 | impl Walrus { | ||
618 | fn feed(&self, amount: u32) {} | ||
619 | } | ||
620 | "#####, | ||
621 | ) | ||
622 | } | ||
623 | |||
624 | #[test] | ||
625 | fn doctest_reorder_fields() { | ||
626 | check_doc_test( | ||
627 | "reorder_fields", | ||
628 | r#####" | ||
629 | struct Foo {foo: i32, bar: i32}; | ||
630 | const test: Foo = <|>Foo {bar: 0, foo: 1} | ||
631 | "#####, | ||
632 | r#####" | ||
633 | struct Foo {foo: i32, bar: i32}; | ||
634 | const test: Foo = Foo {foo: 1, bar: 0} | ||
635 | "#####, | ||
636 | ) | ||
637 | } | ||
638 | |||
639 | #[test] | ||
640 | fn doctest_replace_if_let_with_match() { | ||
641 | check_doc_test( | ||
642 | "replace_if_let_with_match", | ||
643 | r#####" | ||
644 | enum Action { Move { distance: u32 }, Stop } | ||
645 | |||
646 | fn handle(action: Action) { | ||
647 | <|>if let Action::Move { distance } = action { | ||
648 | foo(distance) | ||
649 | } else { | ||
650 | bar() | ||
651 | } | ||
652 | } | ||
653 | "#####, | ||
654 | r#####" | ||
655 | enum Action { Move { distance: u32 }, Stop } | ||
656 | |||
657 | fn handle(action: Action) { | ||
658 | match action { | ||
659 | Action::Move { distance } => foo(distance), | ||
660 | _ => bar(), | ||
661 | } | ||
662 | } | ||
663 | "#####, | ||
664 | ) | ||
665 | } | ||
666 | |||
667 | #[test] | ||
668 | fn doctest_replace_let_with_if_let() { | ||
669 | check_doc_test( | ||
670 | "replace_let_with_if_let", | ||
671 | r#####" | ||
672 | enum Option<T> { Some(T), None } | ||
673 | |||
674 | fn main(action: Action) { | ||
675 | <|>let x = compute(); | ||
676 | } | ||
677 | |||
678 | fn compute() -> Option<i32> { None } | ||
679 | "#####, | ||
680 | r#####" | ||
681 | enum Option<T> { Some(T), None } | ||
682 | |||
683 | fn main(action: Action) { | ||
684 | if let Some(x) = compute() { | ||
685 | } | ||
686 | } | ||
687 | |||
688 | fn compute() -> Option<i32> { None } | ||
689 | "#####, | ||
690 | ) | ||
691 | } | ||
692 | |||
693 | #[test] | ||
694 | fn doctest_replace_qualified_name_with_use() { | ||
695 | check_doc_test( | ||
696 | "replace_qualified_name_with_use", | ||
697 | r#####" | ||
698 | fn process(map: std::collections::<|>HashMap<String, String>) {} | ||
699 | "#####, | ||
700 | r#####" | ||
701 | use std::collections::HashMap; | ||
702 | |||
703 | fn process(map: HashMap<String, String>) {} | ||
704 | "#####, | ||
705 | ) | ||
706 | } | ||
707 | |||
708 | #[test] | ||
709 | fn doctest_replace_unwrap_with_match() { | ||
710 | check_doc_test( | ||
711 | "replace_unwrap_with_match", | ||
712 | r#####" | ||
713 | enum Result<T, E> { Ok(T), Err(E) } | ||
714 | fn main() { | ||
715 | let x: Result<i32, i32> = Result::Ok(92); | ||
716 | let y = x.<|>unwrap(); | ||
717 | } | ||
718 | "#####, | ||
719 | r#####" | ||
720 | enum Result<T, E> { Ok(T), Err(E) } | ||
721 | fn main() { | ||
722 | let x: Result<i32, i32> = Result::Ok(92); | ||
723 | let y = match x { | ||
724 | Ok(a) => a, | ||
725 | _ => unreachable!(), | ||
726 | }; | ||
727 | } | ||
728 | "#####, | ||
729 | ) | ||
730 | } | ||
731 | |||
732 | #[test] | ||
733 | fn doctest_split_import() { | ||
734 | check_doc_test( | ||
735 | "split_import", | ||
736 | r#####" | ||
737 | use std::<|>collections::HashMap; | ||
738 | "#####, | ||
739 | r#####" | ||
740 | use std::{collections::HashMap}; | ||
741 | "#####, | ||
742 | ) | ||
743 | } | ||
744 | |||
745 | #[test] | ||
746 | fn doctest_unwrap_block() { | ||
747 | check_doc_test( | ||
748 | "unwrap_block", | ||
749 | r#####" | ||
750 | fn foo() { | ||
751 | if true {<|> | ||
752 | println!("foo"); | ||
753 | } | ||
754 | } | ||
755 | "#####, | ||
756 | r#####" | ||
757 | fn foo() { | ||
758 | println!("foo"); | ||
759 | } | ||
760 | "#####, | ||
761 | ) | ||
762 | } | ||