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