aboutsummaryrefslogtreecommitdiff
path: root/crates/ide_assists/src/tests
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ide_assists/src/tests')
-rw-r--r--crates/ide_assists/src/tests/generated.rs1329
1 files changed, 1329 insertions, 0 deletions
diff --git a/crates/ide_assists/src/tests/generated.rs b/crates/ide_assists/src/tests/generated.rs
new file mode 100644
index 000000000..0516deaff
--- /dev/null
+++ b/crates/ide_assists/src/tests/generated.rs
@@ -0,0 +1,1329 @@
1//! Generated file, do not edit by hand, see `xtask/src/codegen`
2
3use super::check_doc_test;
4
5#[test]
6fn doctest_add_explicit_type() {
7 check_doc_test(
8 "add_explicit_type",
9 r#####"
10fn main() {
11 let x$0 = 92;
12}
13"#####,
14 r#####"
15fn main() {
16 let x: i32 = 92;
17}
18"#####,
19 )
20}
21
22#[test]
23fn doctest_add_hash() {
24 check_doc_test(
25 "add_hash",
26 r#####"
27fn main() {
28 r#"Hello,$0 World!"#;
29}
30"#####,
31 r#####"
32fn main() {
33 r##"Hello, World!"##;
34}
35"#####,
36 )
37}
38
39#[test]
40fn doctest_add_impl_default_members() {
41 check_doc_test(
42 "add_impl_default_members",
43 r#####"
44trait Trait {
45 type X;
46 fn foo(&self);
47 fn bar(&self) {}
48}
49
50impl Trait for () {
51 type X = ();
52 fn foo(&self) {}$0
53
54}
55"#####,
56 r#####"
57trait Trait {
58 type X;
59 fn foo(&self);
60 fn bar(&self) {}
61}
62
63impl Trait for () {
64 type X = ();
65 fn foo(&self) {}
66
67 $0fn bar(&self) {}
68}
69"#####,
70 )
71}
72
73#[test]
74fn doctest_add_impl_missing_members() {
75 check_doc_test(
76 "add_impl_missing_members",
77 r#####"
78trait Trait<T> {
79 type X;
80 fn foo(&self) -> T;
81 fn bar(&self) {}
82}
83
84impl Trait<u32> for () {$0
85
86}
87"#####,
88 r#####"
89trait Trait<T> {
90 type X;
91 fn foo(&self) -> T;
92 fn bar(&self) {}
93}
94
95impl Trait<u32> for () {
96 $0type X;
97
98 fn foo(&self) -> u32 {
99 todo!()
100 }
101}
102"#####,
103 )
104}
105
106#[test]
107fn doctest_add_lifetime_to_type() {
108 check_doc_test(
109 "add_lifetime_to_type",
110 r#####"
111struct Point {
112 x: &$0u32,
113 y: u32,
114}
115"#####,
116 r#####"
117struct Point<'a> {
118 x: &'a u32,
119 y: u32,
120}
121"#####,
122 )
123}
124
125#[test]
126fn doctest_add_turbo_fish() {
127 check_doc_test(
128 "add_turbo_fish",
129 r#####"
130fn make<T>() -> T { todo!() }
131fn main() {
132 let x = make$0();
133}
134"#####,
135 r#####"
136fn make<T>() -> T { todo!() }
137fn main() {
138 let x = make::<${0:_}>();
139}
140"#####,
141 )
142}
143
144#[test]
145fn doctest_apply_demorgan() {
146 check_doc_test(
147 "apply_demorgan",
148 r#####"
149fn main() {
150 if x != 4 ||$0 !y {}
151}
152"#####,
153 r#####"
154fn main() {
155 if !(x == 4 && y) {}
156}
157"#####,
158 )
159}
160
161#[test]
162fn doctest_auto_import() {
163 check_doc_test(
164 "auto_import",
165 r#####"
166fn main() {
167 let map = HashMap$0::new();
168}
169pub mod std { pub mod collections { pub struct HashMap { } } }
170"#####,
171 r#####"
172use std::collections::HashMap;
173
174fn main() {
175 let map = HashMap::new();
176}
177pub mod std { pub mod collections { pub struct HashMap { } } }
178"#####,
179 )
180}
181
182#[test]
183fn doctest_change_visibility() {
184 check_doc_test(
185 "change_visibility",
186 r#####"
187$0fn frobnicate() {}
188"#####,
189 r#####"
190pub(crate) fn frobnicate() {}
191"#####,
192 )
193}
194
195#[test]
196fn doctest_convert_integer_literal() {
197 check_doc_test(
198 "convert_integer_literal",
199 r#####"
200const _: i32 = 10$0;
201"#####,
202 r#####"
203const _: i32 = 0b1010;
204"#####,
205 )
206}
207
208#[test]
209fn doctest_convert_to_guarded_return() {
210 check_doc_test(
211 "convert_to_guarded_return",
212 r#####"
213fn main() {
214 $0if cond {
215 foo();
216 bar();
217 }
218}
219"#####,
220 r#####"
221fn main() {
222 if !cond {
223 return;
224 }
225 foo();
226 bar();
227}
228"#####,
229 )
230}
231
232#[test]
233fn doctest_expand_glob_import() {
234 check_doc_test(
235 "expand_glob_import",
236 r#####"
237mod foo {
238 pub struct Bar;
239 pub struct Baz;
240}
241
242use foo::*$0;
243
244fn qux(bar: Bar, baz: Baz) {}
245"#####,
246 r#####"
247mod foo {
248 pub struct Bar;
249 pub struct Baz;
250}
251
252use foo::{Baz, Bar};
253
254fn qux(bar: Bar, baz: Baz) {}
255"#####,
256 )
257}
258
259#[test]
260fn doctest_extract_function() {
261 check_doc_test(
262 "extract_function",
263 r#####"
264fn main() {
265 let n = 1;
266 $0let m = n + 2;
267 let k = m + n;$0
268 let g = 3;
269}
270"#####,
271 r#####"
272fn main() {
273 let n = 1;
274 fun_name(n);
275 let g = 3;
276}
277
278fn $0fun_name(n: i32) {
279 let m = n + 2;
280 let k = m + n;
281}
282"#####,
283 )
284}
285
286#[test]
287fn doctest_extract_struct_from_enum_variant() {
288 check_doc_test(
289 "extract_struct_from_enum_variant",
290 r#####"
291enum A { $0One(u32, u32) }
292"#####,
293 r#####"
294struct One(pub u32, pub u32);
295
296enum A { One(One) }
297"#####,
298 )
299}
300
301#[test]
302fn doctest_extract_variable() {
303 check_doc_test(
304 "extract_variable",
305 r#####"
306fn main() {
307 $0(1 + 2)$0 * 4;
308}
309"#####,
310 r#####"
311fn main() {
312 let $0var_name = (1 + 2);
313 var_name * 4;
314}
315"#####,
316 )
317}
318
319#[test]
320fn doctest_fill_match_arms() {
321 check_doc_test(
322 "fill_match_arms",
323 r#####"
324enum Action { Move { distance: u32 }, Stop }
325
326fn handle(action: Action) {
327 match action {
328 $0
329 }
330}
331"#####,
332 r#####"
333enum Action { Move { distance: u32 }, Stop }
334
335fn handle(action: Action) {
336 match action {
337 $0Action::Move { distance } => {}
338 Action::Stop => {}
339 }
340}
341"#####,
342 )
343}
344
345#[test]
346fn doctest_fix_visibility() {
347 check_doc_test(
348 "fix_visibility",
349 r#####"
350mod m {
351 fn frobnicate() {}
352}
353fn main() {
354 m::frobnicate$0() {}
355}
356"#####,
357 r#####"
358mod m {
359 $0pub(crate) fn frobnicate() {}
360}
361fn main() {
362 m::frobnicate() {}
363}
364"#####,
365 )
366}
367
368#[test]
369fn doctest_flip_binexpr() {
370 check_doc_test(
371 "flip_binexpr",
372 r#####"
373fn main() {
374 let _ = 90 +$0 2;
375}
376"#####,
377 r#####"
378fn main() {
379 let _ = 2 + 90;
380}
381"#####,
382 )
383}
384
385#[test]
386fn doctest_flip_comma() {
387 check_doc_test(
388 "flip_comma",
389 r#####"
390fn main() {
391 ((1, 2),$0 (3, 4));
392}
393"#####,
394 r#####"
395fn main() {
396 ((3, 4), (1, 2));
397}
398"#####,
399 )
400}
401
402#[test]
403fn doctest_flip_trait_bound() {
404 check_doc_test(
405 "flip_trait_bound",
406 r#####"
407fn foo<T: Clone +$0 Copy>() { }
408"#####,
409 r#####"
410fn foo<T: Copy + Clone>() { }
411"#####,
412 )
413}
414
415#[test]
416fn doctest_generate_default_from_enum_variant() {
417 check_doc_test(
418 "generate_default_from_enum_variant",
419 r#####"
420enum Version {
421 Undefined,
422 Minor$0,
423 Major,
424}
425"#####,
426 r#####"
427enum Version {
428 Undefined,
429 Minor,
430 Major,
431}
432
433impl Default for Version {
434 fn default() -> Self {
435 Self::Minor
436 }
437}
438"#####,
439 )
440}
441
442#[test]
443fn doctest_generate_derive() {
444 check_doc_test(
445 "generate_derive",
446 r#####"
447struct Point {
448 x: u32,
449 y: u32,$0
450}
451"#####,
452 r#####"
453#[derive($0)]
454struct Point {
455 x: u32,
456 y: u32,
457}
458"#####,
459 )
460}
461
462#[test]
463fn doctest_generate_enum_match_method() {
464 check_doc_test(
465 "generate_enum_match_method",
466 r#####"
467enum Version {
468 Undefined,
469 Minor$0,
470 Major,
471}
472"#####,
473 r#####"
474enum Version {
475 Undefined,
476 Minor,
477 Major,
478}
479
480impl Version {
481 /// Returns `true` if the version is [`Minor`].
482 fn is_minor(&self) -> bool {
483 matches!(self, Self::Minor)
484 }
485}
486"#####,
487 )
488}
489
490#[test]
491fn doctest_generate_from_impl_for_enum() {
492 check_doc_test(
493 "generate_from_impl_for_enum",
494 r#####"
495enum A { $0One(u32) }
496"#####,
497 r#####"
498enum A { One(u32) }
499
500impl From<u32> for A {
501 fn from(v: u32) -> Self {
502 Self::One(v)
503 }
504}
505"#####,
506 )
507}
508
509#[test]
510fn doctest_generate_function() {
511 check_doc_test(
512 "generate_function",
513 r#####"
514struct Baz;
515fn baz() -> Baz { Baz }
516fn foo() {
517 bar$0("", baz());
518}
519
520"#####,
521 r#####"
522struct Baz;
523fn baz() -> Baz { Baz }
524fn foo() {
525 bar("", baz());
526}
527
528fn bar(arg: &str, baz: Baz) ${0:-> ()} {
529 todo!()
530}
531
532"#####,
533 )
534}
535
536#[test]
537fn doctest_generate_getter() {
538 check_doc_test(
539 "generate_getter",
540 r#####"
541struct Person {
542 nam$0e: String,
543}
544"#####,
545 r#####"
546struct Person {
547 name: String,
548}
549
550impl Person {
551 /// Get a reference to the person's name.
552 fn name(&self) -> &String {
553 &self.name
554 }
555}
556"#####,
557 )
558}
559
560#[test]
561fn doctest_generate_getter_mut() {
562 check_doc_test(
563 "generate_getter_mut",
564 r#####"
565struct Person {
566 nam$0e: String,
567}
568"#####,
569 r#####"
570struct Person {
571 name: String,
572}
573
574impl Person {
575 /// Get a mutable reference to the person's name.
576 fn name_mut(&mut self) -> &mut String {
577 &mut self.name
578 }
579}
580"#####,
581 )
582}
583
584#[test]
585fn doctest_generate_impl() {
586 check_doc_test(
587 "generate_impl",
588 r#####"
589struct Ctx<T: Clone> {
590 data: T,$0
591}
592"#####,
593 r#####"
594struct Ctx<T: Clone> {
595 data: T,
596}
597
598impl<T: Clone> Ctx<T> {
599 $0
600}
601"#####,
602 )
603}
604
605#[test]
606fn doctest_generate_new() {
607 check_doc_test(
608 "generate_new",
609 r#####"
610struct Ctx<T: Clone> {
611 data: T,$0
612}
613"#####,
614 r#####"
615struct Ctx<T: Clone> {
616 data: T,
617}
618
619impl<T: Clone> Ctx<T> {
620 fn $0new(data: T) -> Self { Self { data } }
621}
622"#####,
623 )
624}
625
626#[test]
627fn doctest_generate_setter() {
628 check_doc_test(
629 "generate_setter",
630 r#####"
631struct Person {
632 nam$0e: String,
633}
634"#####,
635 r#####"
636struct Person {
637 name: String,
638}
639
640impl Person {
641 /// Set the person's name.
642 fn set_name(&mut self, name: String) {
643 self.name = name;
644 }
645}
646"#####,
647 )
648}
649
650#[test]
651fn doctest_infer_function_return_type() {
652 check_doc_test(
653 "infer_function_return_type",
654 r#####"
655fn foo() { 4$02i32 }
656"#####,
657 r#####"
658fn foo() -> i32 { 42i32 }
659"#####,
660 )
661}
662
663#[test]
664fn doctest_inline_function() {
665 check_doc_test(
666 "inline_function",
667 r#####"
668fn add(a: u32, b: u32) -> u32 { a + b }
669fn main() {
670 let x = add$0(1, 2);
671}
672"#####,
673 r#####"
674fn add(a: u32, b: u32) -> u32 { a + b }
675fn main() {
676 let x = {
677 let a = 1;
678 let b = 2;
679 a + b
680 };
681}
682"#####,
683 )
684}
685
686#[test]
687fn doctest_inline_local_variable() {
688 check_doc_test(
689 "inline_local_variable",
690 r#####"
691fn main() {
692 let x$0 = 1 + 2;
693 x * 4;
694}
695"#####,
696 r#####"
697fn main() {
698 (1 + 2) * 4;
699}
700"#####,
701 )
702}
703
704#[test]
705fn doctest_introduce_named_lifetime() {
706 check_doc_test(
707 "introduce_named_lifetime",
708 r#####"
709impl Cursor<'_$0> {
710 fn node(self) -> &SyntaxNode {
711 match self {
712 Cursor::Replace(node) | Cursor::Before(node) => node,
713 }
714 }
715}
716"#####,
717 r#####"
718impl<'a> Cursor<'a> {
719 fn node(self) -> &SyntaxNode {
720 match self {
721 Cursor::Replace(node) | Cursor::Before(node) => node,
722 }
723 }
724}
725"#####,
726 )
727}
728
729#[test]
730fn doctest_invert_if() {
731 check_doc_test(
732 "invert_if",
733 r#####"
734fn main() {
735 if$0 !y { A } else { B }
736}
737"#####,
738 r#####"
739fn main() {
740 if y { B } else { A }
741}
742"#####,
743 )
744}
745
746#[test]
747fn doctest_make_raw_string() {
748 check_doc_test(
749 "make_raw_string",
750 r#####"
751fn main() {
752 "Hello,$0 World!";
753}
754"#####,
755 r#####"
756fn main() {
757 r#"Hello, World!"#;
758}
759"#####,
760 )
761}
762
763#[test]
764fn doctest_make_usual_string() {
765 check_doc_test(
766 "make_usual_string",
767 r#####"
768fn main() {
769 r#"Hello,$0 "World!""#;
770}
771"#####,
772 r#####"
773fn main() {
774 "Hello, \"World!\"";
775}
776"#####,
777 )
778}
779
780#[test]
781fn doctest_merge_imports() {
782 check_doc_test(
783 "merge_imports",
784 r#####"
785use std::$0fmt::Formatter;
786use std::io;
787"#####,
788 r#####"
789use std::{fmt::Formatter, io};
790"#####,
791 )
792}
793
794#[test]
795fn doctest_merge_match_arms() {
796 check_doc_test(
797 "merge_match_arms",
798 r#####"
799enum Action { Move { distance: u32 }, Stop }
800
801fn handle(action: Action) {
802 match action {
803 $0Action::Move(..) => foo(),
804 Action::Stop => foo(),
805 }
806}
807"#####,
808 r#####"
809enum Action { Move { distance: u32 }, Stop }
810
811fn handle(action: Action) {
812 match action {
813 Action::Move(..) | Action::Stop => foo(),
814 }
815}
816"#####,
817 )
818}
819
820#[test]
821fn doctest_move_arm_cond_to_match_guard() {
822 check_doc_test(
823 "move_arm_cond_to_match_guard",
824 r#####"
825enum Action { Move { distance: u32 }, Stop }
826
827fn handle(action: Action) {
828 match action {
829 Action::Move { distance } => $0if distance > 10 { foo() },
830 _ => (),
831 }
832}
833"#####,
834 r#####"
835enum Action { Move { distance: u32 }, Stop }
836
837fn handle(action: Action) {
838 match action {
839 Action::Move { distance } if distance > 10 => foo(),
840 _ => (),
841 }
842}
843"#####,
844 )
845}
846
847#[test]
848fn doctest_move_bounds_to_where_clause() {
849 check_doc_test(
850 "move_bounds_to_where_clause",
851 r#####"
852fn apply<T, U, $0F: FnOnce(T) -> U>(f: F, x: T) -> U {
853 f(x)
854}
855"#####,
856 r#####"
857fn apply<T, U, F>(f: F, x: T) -> U where F: FnOnce(T) -> U {
858 f(x)
859}
860"#####,
861 )
862}
863
864#[test]
865fn doctest_move_guard_to_arm_body() {
866 check_doc_test(
867 "move_guard_to_arm_body",
868 r#####"
869enum Action { Move { distance: u32 }, Stop }
870
871fn handle(action: Action) {
872 match action {
873 Action::Move { distance } $0if distance > 10 => foo(),
874 _ => (),
875 }
876}
877"#####,
878 r#####"
879enum Action { Move { distance: u32 }, Stop }
880
881fn handle(action: Action) {
882 match action {
883 Action::Move { distance } => if distance > 10 {
884 foo()
885 },
886 _ => (),
887 }
888}
889"#####,
890 )
891}
892
893#[test]
894fn doctest_move_module_to_file() {
895 check_doc_test(
896 "move_module_to_file",
897 r#####"
898mod $0foo {
899 fn t() {}
900}
901"#####,
902 r#####"
903mod foo;
904"#####,
905 )
906}
907
908#[test]
909fn doctest_pull_assignment_up() {
910 check_doc_test(
911 "pull_assignment_up",
912 r#####"
913fn main() {
914 let mut foo = 6;
915
916 if true {
917 $0foo = 5;
918 } else {
919 foo = 4;
920 }
921}
922"#####,
923 r#####"
924fn main() {
925 let mut foo = 6;
926
927 foo = if true {
928 5
929 } else {
930 4
931 };
932}
933"#####,
934 )
935}
936
937#[test]
938fn doctest_qualify_path() {
939 check_doc_test(
940 "qualify_path",
941 r#####"
942fn main() {
943 let map = HashMap$0::new();
944}
945pub mod std { pub mod collections { pub struct HashMap { } } }
946"#####,
947 r#####"
948fn main() {
949 let map = std::collections::HashMap::new();
950}
951pub mod std { pub mod collections { pub struct HashMap { } } }
952"#####,
953 )
954}
955
956#[test]
957fn doctest_remove_dbg() {
958 check_doc_test(
959 "remove_dbg",
960 r#####"
961fn main() {
962 $0dbg!(92);
963}
964"#####,
965 r#####"
966fn main() {
967 92;
968}
969"#####,
970 )
971}
972
973#[test]
974fn doctest_remove_hash() {
975 check_doc_test(
976 "remove_hash",
977 r#####"
978fn main() {
979 r#"Hello,$0 World!"#;
980}
981"#####,
982 r#####"
983fn main() {
984 r"Hello, World!";
985}
986"#####,
987 )
988}
989
990#[test]
991fn doctest_remove_mut() {
992 check_doc_test(
993 "remove_mut",
994 r#####"
995impl Walrus {
996 fn feed(&mut$0 self, amount: u32) {}
997}
998"#####,
999 r#####"
1000impl Walrus {
1001 fn feed(&self, amount: u32) {}
1002}
1003"#####,
1004 )
1005}
1006
1007#[test]
1008fn doctest_remove_unused_param() {
1009 check_doc_test(
1010 "remove_unused_param",
1011 r#####"
1012fn frobnicate(x: i32$0) {}
1013
1014fn main() {
1015 frobnicate(92);
1016}
1017"#####,
1018 r#####"
1019fn frobnicate() {}
1020
1021fn main() {
1022 frobnicate();
1023}
1024"#####,
1025 )
1026}
1027
1028#[test]
1029fn doctest_reorder_fields() {
1030 check_doc_test(
1031 "reorder_fields",
1032 r#####"
1033struct Foo {foo: i32, bar: i32};
1034const test: Foo = $0Foo {bar: 0, foo: 1}
1035"#####,
1036 r#####"
1037struct Foo {foo: i32, bar: i32};
1038const test: Foo = Foo {foo: 1, bar: 0}
1039"#####,
1040 )
1041}
1042
1043#[test]
1044fn doctest_reorder_impl() {
1045 check_doc_test(
1046 "reorder_impl",
1047 r#####"
1048trait Foo {
1049 fn a() {}
1050 fn b() {}
1051 fn c() {}
1052}
1053
1054struct Bar;
1055$0impl Foo for Bar {
1056 fn b() {}
1057 fn c() {}
1058 fn a() {}
1059}
1060"#####,
1061 r#####"
1062trait Foo {
1063 fn a() {}
1064 fn b() {}
1065 fn c() {}
1066}
1067
1068struct Bar;
1069impl Foo for Bar {
1070 fn a() {}
1071 fn b() {}
1072 fn c() {}
1073}
1074"#####,
1075 )
1076}
1077
1078#[test]
1079fn doctest_replace_derive_with_manual_impl() {
1080 check_doc_test(
1081 "replace_derive_with_manual_impl",
1082 r#####"
1083trait Debug { fn fmt(&self, f: &mut Formatter) -> Result<()>; }
1084#[derive(Deb$0ug, Display)]
1085struct S;
1086"#####,
1087 r#####"
1088trait Debug { fn fmt(&self, f: &mut Formatter) -> Result<()>; }
1089#[derive(Display)]
1090struct S;
1091
1092impl Debug for S {
1093 fn fmt(&self, f: &mut Formatter) -> Result<()> {
1094 ${0:todo!()}
1095 }
1096}
1097"#####,
1098 )
1099}
1100
1101#[test]
1102fn doctest_replace_if_let_with_match() {
1103 check_doc_test(
1104 "replace_if_let_with_match",
1105 r#####"
1106enum Action { Move { distance: u32 }, Stop }
1107
1108fn handle(action: Action) {
1109 $0if let Action::Move { distance } = action {
1110 foo(distance)
1111 } else {
1112 bar()
1113 }
1114}
1115"#####,
1116 r#####"
1117enum Action { Move { distance: u32 }, Stop }
1118
1119fn handle(action: Action) {
1120 match action {
1121 Action::Move { distance } => foo(distance),
1122 _ => bar(),
1123 }
1124}
1125"#####,
1126 )
1127}
1128
1129#[test]
1130fn doctest_replace_impl_trait_with_generic() {
1131 check_doc_test(
1132 "replace_impl_trait_with_generic",
1133 r#####"
1134fn foo(bar: $0impl Bar) {}
1135"#####,
1136 r#####"
1137fn foo<B: Bar>(bar: B) {}
1138"#####,
1139 )
1140}
1141
1142#[test]
1143fn doctest_replace_let_with_if_let() {
1144 check_doc_test(
1145 "replace_let_with_if_let",
1146 r#####"
1147enum Option<T> { Some(T), None }
1148
1149fn main(action: Action) {
1150 $0let x = compute();
1151}
1152
1153fn compute() -> Option<i32> { None }
1154"#####,
1155 r#####"
1156enum Option<T> { Some(T), None }
1157
1158fn main(action: Action) {
1159 if let Some(x) = compute() {
1160 }
1161}
1162
1163fn compute() -> Option<i32> { None }
1164"#####,
1165 )
1166}
1167
1168#[test]
1169fn doctest_replace_match_with_if_let() {
1170 check_doc_test(
1171 "replace_match_with_if_let",
1172 r#####"
1173enum Action { Move { distance: u32 }, Stop }
1174
1175fn handle(action: Action) {
1176 $0match action {
1177 Action::Move { distance } => foo(distance),
1178 _ => bar(),
1179 }
1180}
1181"#####,
1182 r#####"
1183enum Action { Move { distance: u32 }, Stop }
1184
1185fn handle(action: Action) {
1186 if let Action::Move { distance } = action {
1187 foo(distance)
1188 } else {
1189 bar()
1190 }
1191}
1192"#####,
1193 )
1194}
1195
1196#[test]
1197fn doctest_replace_qualified_name_with_use() {
1198 check_doc_test(
1199 "replace_qualified_name_with_use",
1200 r#####"
1201fn process(map: std::collections::$0HashMap<String, String>) {}
1202"#####,
1203 r#####"
1204use std::collections::HashMap;
1205
1206fn process(map: HashMap<String, String>) {}
1207"#####,
1208 )
1209}
1210
1211#[test]
1212fn doctest_replace_string_with_char() {
1213 check_doc_test(
1214 "replace_string_with_char",
1215 r#####"
1216fn main() {
1217 find("{$0");
1218}
1219"#####,
1220 r#####"
1221fn main() {
1222 find('{');
1223}
1224"#####,
1225 )
1226}
1227
1228#[test]
1229fn doctest_replace_unwrap_with_match() {
1230 check_doc_test(
1231 "replace_unwrap_with_match",
1232 r#####"
1233enum Result<T, E> { Ok(T), Err(E) }
1234fn main() {
1235 let x: Result<i32, i32> = Result::Ok(92);
1236 let y = x.$0unwrap();
1237}
1238"#####,
1239 r#####"
1240enum Result<T, E> { Ok(T), Err(E) }
1241fn main() {
1242 let x: Result<i32, i32> = Result::Ok(92);
1243 let y = match x {
1244 Ok(a) => a,
1245 $0_ => unreachable!(),
1246 };
1247}
1248"#####,
1249 )
1250}
1251
1252#[test]
1253fn doctest_split_import() {
1254 check_doc_test(
1255 "split_import",
1256 r#####"
1257use std::$0collections::HashMap;
1258"#####,
1259 r#####"
1260use std::{collections::HashMap};
1261"#####,
1262 )
1263}
1264
1265#[test]
1266fn doctest_toggle_ignore() {
1267 check_doc_test(
1268 "toggle_ignore",
1269 r#####"
1270$0#[test]
1271fn arithmetics {
1272 assert_eq!(2 + 2, 5);
1273}
1274"#####,
1275 r#####"
1276#[test]
1277#[ignore]
1278fn arithmetics {
1279 assert_eq!(2 + 2, 5);
1280}
1281"#####,
1282 )
1283}
1284
1285#[test]
1286fn doctest_unmerge_use() {
1287 check_doc_test(
1288 "unmerge_use",
1289 r#####"
1290use std::fmt::{Debug, Display$0};
1291"#####,
1292 r#####"
1293use std::fmt::{Debug};
1294use std::fmt::Display;
1295"#####,
1296 )
1297}
1298
1299#[test]
1300fn doctest_unwrap_block() {
1301 check_doc_test(
1302 "unwrap_block",
1303 r#####"
1304fn foo() {
1305 if true {$0
1306 println!("foo");
1307 }
1308}
1309"#####,
1310 r#####"
1311fn foo() {
1312 println!("foo");
1313}
1314"#####,
1315 )
1316}
1317
1318#[test]
1319fn doctest_wrap_return_type_in_result() {
1320 check_doc_test(
1321 "wrap_return_type_in_result",
1322 r#####"
1323fn foo() -> i32$0 { 42i32 }
1324"#####,
1325 r#####"
1326fn foo() -> Result<i32, ${0:_}> { Ok(42i32) }
1327"#####,
1328 )
1329}