diff options
author | Galilée 'Bill' Enguehard <[email protected]> | 2020-05-21 22:27:38 +0100 |
---|---|---|
committer | Galilée 'Bill' Enguehard <[email protected]> | 2020-05-21 22:27:38 +0100 |
commit | 7fece3bdd2450c0807f7dd742239cae95f0cc65e (patch) | |
tree | 866c4db826c959e79c63a6727bdb9f2c61e6fc4f /crates/ra_assists/src/tests | |
parent | db926218b2082077750291f8426ddd28b284cd08 (diff) | |
parent | 59732df8d40dfadc6dcf5951265416576399712a (diff) |
Merge branch 'master' of github.com:rust-analyzer/rust-analyzer into modname_spacing
Diffstat (limited to 'crates/ra_assists/src/tests')
-rw-r--r-- | crates/ra_assists/src/tests/generated.rs | 804 |
1 files changed, 804 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..250e56a69 --- /dev/null +++ b/crates/ra_assists/src/tests/generated.rs | |||
@@ -0,0 +1,804 @@ | |||
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 | $0 | ||
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($0)] | ||
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 | ${0: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 | $0 | ||
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 | $0fn 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 | ${0: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 $0new(data: T) -> Self { Self { data } } | ||
208 | } | ||
209 | |||
210 | "#####, | ||
211 | ) | ||
212 | } | ||
213 | |||
214 | #[test] | ||
215 | fn doctest_add_turbo_fish() { | ||
216 | check_doc_test( | ||
217 | "add_turbo_fish", | ||
218 | r#####" | ||
219 | fn make<T>() -> T { todo!() } | ||
220 | fn main() { | ||
221 | let x = make<|>(); | ||
222 | } | ||
223 | "#####, | ||
224 | r#####" | ||
225 | fn make<T>() -> T { todo!() } | ||
226 | fn main() { | ||
227 | let x = make::<${0:_}>(); | ||
228 | } | ||
229 | "#####, | ||
230 | ) | ||
231 | } | ||
232 | |||
233 | #[test] | ||
234 | fn doctest_apply_demorgan() { | ||
235 | check_doc_test( | ||
236 | "apply_demorgan", | ||
237 | r#####" | ||
238 | fn main() { | ||
239 | if x != 4 ||<|> !y {} | ||
240 | } | ||
241 | "#####, | ||
242 | r#####" | ||
243 | fn main() { | ||
244 | if !(x == 4 && y) {} | ||
245 | } | ||
246 | "#####, | ||
247 | ) | ||
248 | } | ||
249 | |||
250 | #[test] | ||
251 | fn doctest_auto_import() { | ||
252 | check_doc_test( | ||
253 | "auto_import", | ||
254 | r#####" | ||
255 | fn main() { | ||
256 | let map = HashMap<|>::new(); | ||
257 | } | ||
258 | pub mod std { pub mod collections { pub struct HashMap { } } } | ||
259 | "#####, | ||
260 | r#####" | ||
261 | use std::collections::HashMap; | ||
262 | |||
263 | fn main() { | ||
264 | let map = HashMap::new(); | ||
265 | } | ||
266 | pub mod std { pub mod collections { pub struct HashMap { } } } | ||
267 | "#####, | ||
268 | ) | ||
269 | } | ||
270 | |||
271 | #[test] | ||
272 | fn doctest_change_return_type_to_result() { | ||
273 | check_doc_test( | ||
274 | "change_return_type_to_result", | ||
275 | r#####" | ||
276 | fn foo() -> i32<|> { 42i32 } | ||
277 | "#####, | ||
278 | r#####" | ||
279 | fn foo() -> Result<i32, ${0:_}> { Ok(42i32) } | ||
280 | "#####, | ||
281 | ) | ||
282 | } | ||
283 | |||
284 | #[test] | ||
285 | fn doctest_change_visibility() { | ||
286 | check_doc_test( | ||
287 | "change_visibility", | ||
288 | r#####" | ||
289 | <|>fn frobnicate() {} | ||
290 | "#####, | ||
291 | r#####" | ||
292 | pub(crate) fn frobnicate() {} | ||
293 | "#####, | ||
294 | ) | ||
295 | } | ||
296 | |||
297 | #[test] | ||
298 | fn doctest_convert_to_guarded_return() { | ||
299 | check_doc_test( | ||
300 | "convert_to_guarded_return", | ||
301 | r#####" | ||
302 | fn main() { | ||
303 | <|>if cond { | ||
304 | foo(); | ||
305 | bar(); | ||
306 | } | ||
307 | } | ||
308 | "#####, | ||
309 | r#####" | ||
310 | fn main() { | ||
311 | if !cond { | ||
312 | return; | ||
313 | } | ||
314 | foo(); | ||
315 | bar(); | ||
316 | } | ||
317 | "#####, | ||
318 | ) | ||
319 | } | ||
320 | |||
321 | #[test] | ||
322 | fn doctest_fill_match_arms() { | ||
323 | check_doc_test( | ||
324 | "fill_match_arms", | ||
325 | r#####" | ||
326 | enum Action { Move { distance: u32 }, Stop } | ||
327 | |||
328 | fn handle(action: Action) { | ||
329 | match action { | ||
330 | <|> | ||
331 | } | ||
332 | } | ||
333 | "#####, | ||
334 | r#####" | ||
335 | enum Action { Move { distance: u32 }, Stop } | ||
336 | |||
337 | fn handle(action: Action) { | ||
338 | match action { | ||
339 | $0Action::Move { distance } => {} | ||
340 | Action::Stop => {} | ||
341 | } | ||
342 | } | ||
343 | "#####, | ||
344 | ) | ||
345 | } | ||
346 | |||
347 | #[test] | ||
348 | fn doctest_fix_visibility() { | ||
349 | check_doc_test( | ||
350 | "fix_visibility", | ||
351 | r#####" | ||
352 | mod m { | ||
353 | fn frobnicate() {} | ||
354 | } | ||
355 | fn main() { | ||
356 | m::frobnicate<|>() {} | ||
357 | } | ||
358 | "#####, | ||
359 | r#####" | ||
360 | mod m { | ||
361 | $0pub(crate) fn frobnicate() {} | ||
362 | } | ||
363 | fn main() { | ||
364 | m::frobnicate() {} | ||
365 | } | ||
366 | "#####, | ||
367 | ) | ||
368 | } | ||
369 | |||
370 | #[test] | ||
371 | fn doctest_flip_binexpr() { | ||
372 | check_doc_test( | ||
373 | "flip_binexpr", | ||
374 | r#####" | ||
375 | fn main() { | ||
376 | let _ = 90 +<|> 2; | ||
377 | } | ||
378 | "#####, | ||
379 | r#####" | ||
380 | fn main() { | ||
381 | let _ = 2 + 90; | ||
382 | } | ||
383 | "#####, | ||
384 | ) | ||
385 | } | ||
386 | |||
387 | #[test] | ||
388 | fn doctest_flip_comma() { | ||
389 | check_doc_test( | ||
390 | "flip_comma", | ||
391 | r#####" | ||
392 | fn main() { | ||
393 | ((1, 2),<|> (3, 4)); | ||
394 | } | ||
395 | "#####, | ||
396 | r#####" | ||
397 | fn main() { | ||
398 | ((3, 4), (1, 2)); | ||
399 | } | ||
400 | "#####, | ||
401 | ) | ||
402 | } | ||
403 | |||
404 | #[test] | ||
405 | fn doctest_flip_trait_bound() { | ||
406 | check_doc_test( | ||
407 | "flip_trait_bound", | ||
408 | r#####" | ||
409 | fn foo<T: Clone +<|> Copy>() { } | ||
410 | "#####, | ||
411 | r#####" | ||
412 | fn foo<T: Copy + Clone>() { } | ||
413 | "#####, | ||
414 | ) | ||
415 | } | ||
416 | |||
417 | #[test] | ||
418 | fn doctest_inline_local_variable() { | ||
419 | check_doc_test( | ||
420 | "inline_local_variable", | ||
421 | r#####" | ||
422 | fn main() { | ||
423 | let x<|> = 1 + 2; | ||
424 | x * 4; | ||
425 | } | ||
426 | "#####, | ||
427 | r#####" | ||
428 | fn main() { | ||
429 | (1 + 2) * 4; | ||
430 | } | ||
431 | "#####, | ||
432 | ) | ||
433 | } | ||
434 | |||
435 | #[test] | ||
436 | fn doctest_introduce_variable() { | ||
437 | check_doc_test( | ||
438 | "introduce_variable", | ||
439 | r#####" | ||
440 | fn main() { | ||
441 | <|>(1 + 2)<|> * 4; | ||
442 | } | ||
443 | "#####, | ||
444 | r#####" | ||
445 | fn main() { | ||
446 | let $0var_name = (1 + 2); | ||
447 | var_name * 4; | ||
448 | } | ||
449 | "#####, | ||
450 | ) | ||
451 | } | ||
452 | |||
453 | #[test] | ||
454 | fn doctest_invert_if() { | ||
455 | check_doc_test( | ||
456 | "invert_if", | ||
457 | r#####" | ||
458 | fn main() { | ||
459 | if<|> !y { A } else { B } | ||
460 | } | ||
461 | "#####, | ||
462 | r#####" | ||
463 | fn main() { | ||
464 | if y { B } else { A } | ||
465 | } | ||
466 | "#####, | ||
467 | ) | ||
468 | } | ||
469 | |||
470 | #[test] | ||
471 | fn doctest_make_raw_string() { | ||
472 | check_doc_test( | ||
473 | "make_raw_string", | ||
474 | r#####" | ||
475 | fn main() { | ||
476 | "Hello,<|> World!"; | ||
477 | } | ||
478 | "#####, | ||
479 | r#####" | ||
480 | fn main() { | ||
481 | r#"Hello, World!"#; | ||
482 | } | ||
483 | "#####, | ||
484 | ) | ||
485 | } | ||
486 | |||
487 | #[test] | ||
488 | fn doctest_make_usual_string() { | ||
489 | check_doc_test( | ||
490 | "make_usual_string", | ||
491 | r#####" | ||
492 | fn main() { | ||
493 | r#"Hello,<|> "World!""#; | ||
494 | } | ||
495 | "#####, | ||
496 | r#####" | ||
497 | fn main() { | ||
498 | "Hello, \"World!\""; | ||
499 | } | ||
500 | "#####, | ||
501 | ) | ||
502 | } | ||
503 | |||
504 | #[test] | ||
505 | fn doctest_merge_imports() { | ||
506 | check_doc_test( | ||
507 | "merge_imports", | ||
508 | r#####" | ||
509 | use std::<|>fmt::Formatter; | ||
510 | use std::io; | ||
511 | "#####, | ||
512 | r#####" | ||
513 | use std::{fmt::Formatter, io}; | ||
514 | "#####, | ||
515 | ) | ||
516 | } | ||
517 | |||
518 | #[test] | ||
519 | fn doctest_merge_match_arms() { | ||
520 | check_doc_test( | ||
521 | "merge_match_arms", | ||
522 | r#####" | ||
523 | enum Action { Move { distance: u32 }, Stop } | ||
524 | |||
525 | fn handle(action: Action) { | ||
526 | match action { | ||
527 | <|>Action::Move(..) => foo(), | ||
528 | Action::Stop => foo(), | ||
529 | } | ||
530 | } | ||
531 | "#####, | ||
532 | r#####" | ||
533 | enum Action { Move { distance: u32 }, Stop } | ||
534 | |||
535 | fn handle(action: Action) { | ||
536 | match action { | ||
537 | Action::Move(..) | Action::Stop => foo(), | ||
538 | } | ||
539 | } | ||
540 | "#####, | ||
541 | ) | ||
542 | } | ||
543 | |||
544 | #[test] | ||
545 | fn doctest_move_arm_cond_to_match_guard() { | ||
546 | check_doc_test( | ||
547 | "move_arm_cond_to_match_guard", | ||
548 | r#####" | ||
549 | enum Action { Move { distance: u32 }, Stop } | ||
550 | |||
551 | fn handle(action: Action) { | ||
552 | match action { | ||
553 | Action::Move { distance } => <|>if distance > 10 { foo() }, | ||
554 | _ => (), | ||
555 | } | ||
556 | } | ||
557 | "#####, | ||
558 | r#####" | ||
559 | enum Action { Move { distance: u32 }, Stop } | ||
560 | |||
561 | fn handle(action: Action) { | ||
562 | match action { | ||
563 | Action::Move { distance } if distance > 10 => foo(), | ||
564 | _ => (), | ||
565 | } | ||
566 | } | ||
567 | "#####, | ||
568 | ) | ||
569 | } | ||
570 | |||
571 | #[test] | ||
572 | fn doctest_move_bounds_to_where_clause() { | ||
573 | check_doc_test( | ||
574 | "move_bounds_to_where_clause", | ||
575 | r#####" | ||
576 | fn apply<T, U, <|>F: FnOnce(T) -> U>(f: F, x: T) -> U { | ||
577 | f(x) | ||
578 | } | ||
579 | "#####, | ||
580 | r#####" | ||
581 | fn apply<T, U, F>(f: F, x: T) -> U where F: FnOnce(T) -> U { | ||
582 | f(x) | ||
583 | } | ||
584 | "#####, | ||
585 | ) | ||
586 | } | ||
587 | |||
588 | #[test] | ||
589 | fn doctest_move_guard_to_arm_body() { | ||
590 | check_doc_test( | ||
591 | "move_guard_to_arm_body", | ||
592 | r#####" | ||
593 | enum Action { Move { distance: u32 }, Stop } | ||
594 | |||
595 | fn handle(action: Action) { | ||
596 | match action { | ||
597 | Action::Move { distance } <|>if distance > 10 => foo(), | ||
598 | _ => (), | ||
599 | } | ||
600 | } | ||
601 | "#####, | ||
602 | r#####" | ||
603 | enum Action { Move { distance: u32 }, Stop } | ||
604 | |||
605 | fn handle(action: Action) { | ||
606 | match action { | ||
607 | Action::Move { distance } => if distance > 10 { foo() }, | ||
608 | _ => (), | ||
609 | } | ||
610 | } | ||
611 | "#####, | ||
612 | ) | ||
613 | } | ||
614 | |||
615 | #[test] | ||
616 | fn doctest_remove_dbg() { | ||
617 | check_doc_test( | ||
618 | "remove_dbg", | ||
619 | r#####" | ||
620 | fn main() { | ||
621 | <|>dbg!(92); | ||
622 | } | ||
623 | "#####, | ||
624 | r#####" | ||
625 | fn main() { | ||
626 | 92; | ||
627 | } | ||
628 | "#####, | ||
629 | ) | ||
630 | } | ||
631 | |||
632 | #[test] | ||
633 | fn doctest_remove_hash() { | ||
634 | check_doc_test( | ||
635 | "remove_hash", | ||
636 | r#####" | ||
637 | fn main() { | ||
638 | r#"Hello,<|> World!"#; | ||
639 | } | ||
640 | "#####, | ||
641 | r#####" | ||
642 | fn main() { | ||
643 | r"Hello, World!"; | ||
644 | } | ||
645 | "#####, | ||
646 | ) | ||
647 | } | ||
648 | |||
649 | #[test] | ||
650 | fn doctest_remove_mut() { | ||
651 | check_doc_test( | ||
652 | "remove_mut", | ||
653 | r#####" | ||
654 | impl Walrus { | ||
655 | fn feed(&mut<|> self, amount: u32) {} | ||
656 | } | ||
657 | "#####, | ||
658 | r#####" | ||
659 | impl Walrus { | ||
660 | fn feed(&self, amount: u32) {} | ||
661 | } | ||
662 | "#####, | ||
663 | ) | ||
664 | } | ||
665 | |||
666 | #[test] | ||
667 | fn doctest_reorder_fields() { | ||
668 | check_doc_test( | ||
669 | "reorder_fields", | ||
670 | r#####" | ||
671 | struct Foo {foo: i32, bar: i32}; | ||
672 | const test: Foo = <|>Foo {bar: 0, foo: 1} | ||
673 | "#####, | ||
674 | r#####" | ||
675 | struct Foo {foo: i32, bar: i32}; | ||
676 | const test: Foo = Foo {foo: 1, bar: 0} | ||
677 | "#####, | ||
678 | ) | ||
679 | } | ||
680 | |||
681 | #[test] | ||
682 | fn doctest_replace_if_let_with_match() { | ||
683 | check_doc_test( | ||
684 | "replace_if_let_with_match", | ||
685 | r#####" | ||
686 | enum Action { Move { distance: u32 }, Stop } | ||
687 | |||
688 | fn handle(action: Action) { | ||
689 | <|>if let Action::Move { distance } = action { | ||
690 | foo(distance) | ||
691 | } else { | ||
692 | bar() | ||
693 | } | ||
694 | } | ||
695 | "#####, | ||
696 | r#####" | ||
697 | enum Action { Move { distance: u32 }, Stop } | ||
698 | |||
699 | fn handle(action: Action) { | ||
700 | match action { | ||
701 | Action::Move { distance } => foo(distance), | ||
702 | _ => bar(), | ||
703 | } | ||
704 | } | ||
705 | "#####, | ||
706 | ) | ||
707 | } | ||
708 | |||
709 | #[test] | ||
710 | fn doctest_replace_let_with_if_let() { | ||
711 | check_doc_test( | ||
712 | "replace_let_with_if_let", | ||
713 | r#####" | ||
714 | enum Option<T> { Some(T), None } | ||
715 | |||
716 | fn main(action: Action) { | ||
717 | <|>let x = compute(); | ||
718 | } | ||
719 | |||
720 | fn compute() -> Option<i32> { None } | ||
721 | "#####, | ||
722 | r#####" | ||
723 | enum Option<T> { Some(T), None } | ||
724 | |||
725 | fn main(action: Action) { | ||
726 | if let Some(x) = compute() { | ||
727 | } | ||
728 | } | ||
729 | |||
730 | fn compute() -> Option<i32> { None } | ||
731 | "#####, | ||
732 | ) | ||
733 | } | ||
734 | |||
735 | #[test] | ||
736 | fn doctest_replace_qualified_name_with_use() { | ||
737 | check_doc_test( | ||
738 | "replace_qualified_name_with_use", | ||
739 | r#####" | ||
740 | fn process(map: std::collections::<|>HashMap<String, String>) {} | ||
741 | "#####, | ||
742 | r#####" | ||
743 | use std::collections::HashMap; | ||
744 | |||
745 | fn process(map: HashMap<String, String>) {} | ||
746 | "#####, | ||
747 | ) | ||
748 | } | ||
749 | |||
750 | #[test] | ||
751 | fn doctest_replace_unwrap_with_match() { | ||
752 | check_doc_test( | ||
753 | "replace_unwrap_with_match", | ||
754 | r#####" | ||
755 | enum Result<T, E> { Ok(T), Err(E) } | ||
756 | fn main() { | ||
757 | let x: Result<i32, i32> = Result::Ok(92); | ||
758 | let y = x.<|>unwrap(); | ||
759 | } | ||
760 | "#####, | ||
761 | r#####" | ||
762 | enum Result<T, E> { Ok(T), Err(E) } | ||
763 | fn main() { | ||
764 | let x: Result<i32, i32> = Result::Ok(92); | ||
765 | let y = match x { | ||
766 | Ok(a) => a, | ||
767 | $0_ => unreachable!(), | ||
768 | }; | ||
769 | } | ||
770 | "#####, | ||
771 | ) | ||
772 | } | ||
773 | |||
774 | #[test] | ||
775 | fn doctest_split_import() { | ||
776 | check_doc_test( | ||
777 | "split_import", | ||
778 | r#####" | ||
779 | use std::<|>collections::HashMap; | ||
780 | "#####, | ||
781 | r#####" | ||
782 | use std::{collections::HashMap}; | ||
783 | "#####, | ||
784 | ) | ||
785 | } | ||
786 | |||
787 | #[test] | ||
788 | fn doctest_unwrap_block() { | ||
789 | check_doc_test( | ||
790 | "unwrap_block", | ||
791 | r#####" | ||
792 | fn foo() { | ||
793 | if true {<|> | ||
794 | println!("foo"); | ||
795 | } | ||
796 | } | ||
797 | "#####, | ||
798 | r#####" | ||
799 | fn foo() { | ||
800 | println!("foo"); | ||
801 | } | ||
802 | "#####, | ||
803 | ) | ||
804 | } | ||