aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_assists/src/doc_tests
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_assists/src/doc_tests')
-rw-r--r--crates/ra_assists/src/doc_tests/generated.rs749
1 files changed, 0 insertions, 749 deletions
diff --git a/crates/ra_assists/src/doc_tests/generated.rs b/crates/ra_assists/src/doc_tests/generated.rs
deleted file mode 100644
index 6696cc832..000000000
--- a/crates/ra_assists/src/doc_tests/generated.rs
+++ /dev/null
@@ -1,749 +0,0 @@
1//! Generated file, do not edit by hand, see `xtask/src/codegen`
2
3use super::check;
4
5#[test]
6fn doctest_add_custom_impl() {
7 check(
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(
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(
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(
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(
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(
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(
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(
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(
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(
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(
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_visibility() {
254 check(
255 "change_visibility",
256 r#####"
257<|>fn frobnicate() {}
258"#####,
259 r#####"
260pub(crate) fn frobnicate() {}
261"#####,
262 )
263}
264
265#[test]
266fn doctest_convert_to_guarded_return() {
267 check(
268 "convert_to_guarded_return",
269 r#####"
270fn main() {
271 <|>if cond {
272 foo();
273 bar();
274 }
275}
276"#####,
277 r#####"
278fn main() {
279 if !cond {
280 return;
281 }
282 foo();
283 bar();
284}
285"#####,
286 )
287}
288
289#[test]
290fn doctest_fill_match_arms() {
291 check(
292 "fill_match_arms",
293 r#####"
294enum Action { Move { distance: u32 }, Stop }
295
296fn handle(action: Action) {
297 match action {
298 <|>
299 }
300}
301"#####,
302 r#####"
303enum Action { Move { distance: u32 }, Stop }
304
305fn handle(action: Action) {
306 match action {
307 Action::Move { distance } => {}
308 Action::Stop => {}
309 }
310}
311"#####,
312 )
313}
314
315#[test]
316fn doctest_flip_binexpr() {
317 check(
318 "flip_binexpr",
319 r#####"
320fn main() {
321 let _ = 90 +<|> 2;
322}
323"#####,
324 r#####"
325fn main() {
326 let _ = 2 + 90;
327}
328"#####,
329 )
330}
331
332#[test]
333fn doctest_flip_comma() {
334 check(
335 "flip_comma",
336 r#####"
337fn main() {
338 ((1, 2),<|> (3, 4));
339}
340"#####,
341 r#####"
342fn main() {
343 ((3, 4), (1, 2));
344}
345"#####,
346 )
347}
348
349#[test]
350fn doctest_flip_trait_bound() {
351 check(
352 "flip_trait_bound",
353 r#####"
354fn foo<T: Clone +<|> Copy>() { }
355"#####,
356 r#####"
357fn foo<T: Copy + Clone>() { }
358"#####,
359 )
360}
361
362#[test]
363fn doctest_inline_local_variable() {
364 check(
365 "inline_local_variable",
366 r#####"
367fn main() {
368 let x<|> = 1 + 2;
369 x * 4;
370}
371"#####,
372 r#####"
373fn main() {
374 (1 + 2) * 4;
375}
376"#####,
377 )
378}
379
380#[test]
381fn doctest_introduce_variable() {
382 check(
383 "introduce_variable",
384 r#####"
385fn main() {
386 <|>(1 + 2)<|> * 4;
387}
388"#####,
389 r#####"
390fn main() {
391 let var_name = (1 + 2);
392 var_name * 4;
393}
394"#####,
395 )
396}
397
398#[test]
399fn doctest_invert_if() {
400 check(
401 "invert_if",
402 r#####"
403fn main() {
404 if<|> !y { A } else { B }
405}
406"#####,
407 r#####"
408fn main() {
409 if y { B } else { A }
410}
411"#####,
412 )
413}
414
415#[test]
416fn doctest_make_raw_string() {
417 check(
418 "make_raw_string",
419 r#####"
420fn main() {
421 "Hello,<|> World!";
422}
423"#####,
424 r#####"
425fn main() {
426 r#"Hello, World!"#;
427}
428"#####,
429 )
430}
431
432#[test]
433fn doctest_make_usual_string() {
434 check(
435 "make_usual_string",
436 r#####"
437fn main() {
438 r#"Hello,<|> "World!""#;
439}
440"#####,
441 r#####"
442fn main() {
443 "Hello, \"World!\"";
444}
445"#####,
446 )
447}
448
449#[test]
450fn doctest_merge_imports() {
451 check(
452 "merge_imports",
453 r#####"
454use std::<|>fmt::Formatter;
455use std::io;
456"#####,
457 r#####"
458use std::{fmt::Formatter, io};
459"#####,
460 )
461}
462
463#[test]
464fn doctest_merge_match_arms() {
465 check(
466 "merge_match_arms",
467 r#####"
468enum Action { Move { distance: u32 }, Stop }
469
470fn handle(action: Action) {
471 match action {
472 <|>Action::Move(..) => foo(),
473 Action::Stop => foo(),
474 }
475}
476"#####,
477 r#####"
478enum Action { Move { distance: u32 }, Stop }
479
480fn handle(action: Action) {
481 match action {
482 Action::Move(..) | Action::Stop => foo(),
483 }
484}
485"#####,
486 )
487}
488
489#[test]
490fn doctest_move_arm_cond_to_match_guard() {
491 check(
492 "move_arm_cond_to_match_guard",
493 r#####"
494enum Action { Move { distance: u32 }, Stop }
495
496fn handle(action: Action) {
497 match action {
498 Action::Move { distance } => <|>if distance > 10 { foo() },
499 _ => (),
500 }
501}
502"#####,
503 r#####"
504enum Action { Move { distance: u32 }, Stop }
505
506fn handle(action: Action) {
507 match action {
508 Action::Move { distance } if distance > 10 => foo(),
509 _ => (),
510 }
511}
512"#####,
513 )
514}
515
516#[test]
517fn doctest_move_bounds_to_where_clause() {
518 check(
519 "move_bounds_to_where_clause",
520 r#####"
521fn apply<T, U, <|>F: FnOnce(T) -> U>(f: F, x: T) -> U {
522 f(x)
523}
524"#####,
525 r#####"
526fn apply<T, U, F>(f: F, x: T) -> U where F: FnOnce(T) -> U {
527 f(x)
528}
529"#####,
530 )
531}
532
533#[test]
534fn doctest_move_guard_to_arm_body() {
535 check(
536 "move_guard_to_arm_body",
537 r#####"
538enum Action { Move { distance: u32 }, Stop }
539
540fn handle(action: Action) {
541 match action {
542 Action::Move { distance } <|>if distance > 10 => foo(),
543 _ => (),
544 }
545}
546"#####,
547 r#####"
548enum Action { Move { distance: u32 }, Stop }
549
550fn handle(action: Action) {
551 match action {
552 Action::Move { distance } => if distance > 10 { foo() },
553 _ => (),
554 }
555}
556"#####,
557 )
558}
559
560#[test]
561fn doctest_remove_dbg() {
562 check(
563 "remove_dbg",
564 r#####"
565fn main() {
566 <|>dbg!(92);
567}
568"#####,
569 r#####"
570fn main() {
571 92;
572}
573"#####,
574 )
575}
576
577#[test]
578fn doctest_remove_hash() {
579 check(
580 "remove_hash",
581 r#####"
582fn main() {
583 r#"Hello,<|> World!"#;
584}
585"#####,
586 r#####"
587fn main() {
588 r"Hello, World!";
589}
590"#####,
591 )
592}
593
594#[test]
595fn doctest_remove_mut() {
596 check(
597 "remove_mut",
598 r#####"
599impl Walrus {
600 fn feed(&mut<|> self, amount: u32) {}
601}
602"#####,
603 r#####"
604impl Walrus {
605 fn feed(&self, amount: u32) {}
606}
607"#####,
608 )
609}
610
611#[test]
612fn doctest_reorder_fields() {
613 check(
614 "reorder_fields",
615 r#####"
616struct Foo {foo: i32, bar: i32};
617const test: Foo = <|>Foo {bar: 0, foo: 1}
618"#####,
619 r#####"
620struct Foo {foo: i32, bar: i32};
621const test: Foo = Foo {foo: 1, bar: 0}
622"#####,
623 )
624}
625
626#[test]
627fn doctest_replace_if_let_with_match() {
628 check(
629 "replace_if_let_with_match",
630 r#####"
631enum Action { Move { distance: u32 }, Stop }
632
633fn handle(action: Action) {
634 <|>if let Action::Move { distance } = action {
635 foo(distance)
636 } else {
637 bar()
638 }
639}
640"#####,
641 r#####"
642enum Action { Move { distance: u32 }, Stop }
643
644fn handle(action: Action) {
645 match action {
646 Action::Move { distance } => foo(distance),
647 _ => bar(),
648 }
649}
650"#####,
651 )
652}
653
654#[test]
655fn doctest_replace_let_with_if_let() {
656 check(
657 "replace_let_with_if_let",
658 r#####"
659enum Option<T> { Some(T), None }
660
661fn main(action: Action) {
662 <|>let x = compute();
663}
664
665fn compute() -> Option<i32> { None }
666"#####,
667 r#####"
668enum Option<T> { Some(T), None }
669
670fn main(action: Action) {
671 if let Some(x) = compute() {
672 }
673}
674
675fn compute() -> Option<i32> { None }
676"#####,
677 )
678}
679
680#[test]
681fn doctest_replace_qualified_name_with_use() {
682 check(
683 "replace_qualified_name_with_use",
684 r#####"
685fn process(map: std::collections::<|>HashMap<String, String>) {}
686"#####,
687 r#####"
688use std::collections::HashMap;
689
690fn process(map: HashMap<String, String>) {}
691"#####,
692 )
693}
694
695#[test]
696fn doctest_replace_unwrap_with_match() {
697 check(
698 "replace_unwrap_with_match",
699 r#####"
700enum Result<T, E> { Ok(T), Err(E) }
701fn main() {
702 let x: Result<i32, i32> = Result::Ok(92);
703 let y = x.<|>unwrap();
704}
705"#####,
706 r#####"
707enum Result<T, E> { Ok(T), Err(E) }
708fn main() {
709 let x: Result<i32, i32> = Result::Ok(92);
710 let y = match x {
711 Ok(a) => a,
712 _ => unreachable!(),
713 };
714}
715"#####,
716 )
717}
718
719#[test]
720fn doctest_split_import() {
721 check(
722 "split_import",
723 r#####"
724use std::<|>collections::HashMap;
725"#####,
726 r#####"
727use std::{collections::HashMap};
728"#####,
729 )
730}
731
732#[test]
733fn doctest_unwrap_block() {
734 check(
735 "unwrap_block",
736 r#####"
737fn foo() {
738 if true {<|>
739 println!("foo");
740 }
741}
742"#####,
743 r#####"
744fn foo() {
745 println!("foo");
746}
747"#####,
748 )
749}