diff options
author | Aleksey Kladov <[email protected]> | 2020-11-09 12:18:40 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2020-11-09 12:18:40 +0000 |
commit | 3cecf78488a40638c8f6ea8b9482080d4bfafca4 (patch) | |
tree | 2370ce0d4aa5e93b99878ba548cb9694a8921509 /crates | |
parent | 29bf6bed9b65691a54a72f83c6cf3be40ae558e8 (diff) |
More consistent naming
Diffstat (limited to 'crates')
-rw-r--r-- | crates/assists/src/handlers/wrap_return_type_in_result.rs (renamed from crates/assists/src/handlers/change_return_type_to_result.rs) | 132 | ||||
-rw-r--r-- | crates/assists/src/lib.rs | 4 | ||||
-rw-r--r-- | crates/assists/src/tests/generated.rs | 26 |
3 files changed, 81 insertions, 81 deletions
diff --git a/crates/assists/src/handlers/change_return_type_to_result.rs b/crates/assists/src/handlers/wrap_return_type_in_result.rs index 76f33a5b6..e08981f89 100644 --- a/crates/assists/src/handlers/change_return_type_to_result.rs +++ b/crates/assists/src/handlers/wrap_return_type_in_result.rs | |||
@@ -8,9 +8,9 @@ use test_utils::mark; | |||
8 | 8 | ||
9 | use crate::{AssistContext, AssistId, AssistKind, Assists}; | 9 | use crate::{AssistContext, AssistId, AssistKind, Assists}; |
10 | 10 | ||
11 | // Assist: change_return_type_to_result | 11 | // Assist: wrap_return_type_in_result |
12 | // | 12 | // |
13 | // Change the function's return type to Result. | 13 | // Wrap the function's return type into Result. |
14 | // | 14 | // |
15 | // ``` | 15 | // ``` |
16 | // fn foo() -> i32<|> { 42i32 } | 16 | // fn foo() -> i32<|> { 42i32 } |
@@ -19,7 +19,7 @@ use crate::{AssistContext, AssistId, AssistKind, Assists}; | |||
19 | // ``` | 19 | // ``` |
20 | // fn foo() -> Result<i32, ${0:_}> { Ok(42i32) } | 20 | // fn foo() -> Result<i32, ${0:_}> { Ok(42i32) } |
21 | // ``` | 21 | // ``` |
22 | pub(crate) fn change_return_type_to_result(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { | 22 | pub(crate) fn wrap_return_type_in_result(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { |
23 | let ret_type = ctx.find_node_at_offset::<ast::RetType>()?; | 23 | let ret_type = ctx.find_node_at_offset::<ast::RetType>()?; |
24 | let parent = ret_type.syntax().parent()?; | 24 | let parent = ret_type.syntax().parent()?; |
25 | let block_expr = match_ast! { | 25 | let block_expr = match_ast! { |
@@ -39,13 +39,13 @@ pub(crate) fn change_return_type_to_result(acc: &mut Assists, ctx: &AssistContex | |||
39 | let first_part_ret_type = ret_type_str.splitn(2, '<').next(); | 39 | let first_part_ret_type = ret_type_str.splitn(2, '<').next(); |
40 | if let Some(ret_type_first_part) = first_part_ret_type { | 40 | if let Some(ret_type_first_part) = first_part_ret_type { |
41 | if ret_type_first_part.ends_with("Result") { | 41 | if ret_type_first_part.ends_with("Result") { |
42 | mark::hit!(change_return_type_to_result_simple_return_type_already_result); | 42 | mark::hit!(wrap_return_type_in_result_simple_return_type_already_result); |
43 | return None; | 43 | return None; |
44 | } | 44 | } |
45 | } | 45 | } |
46 | 46 | ||
47 | acc.add( | 47 | acc.add( |
48 | AssistId("change_return_type_to_result", AssistKind::RefactorRewrite), | 48 | AssistId("wrap_return_type_in_result", AssistKind::RefactorRewrite), |
49 | "Wrap return type in Result", | 49 | "Wrap return type in Result", |
50 | type_ref.syntax().text_range(), | 50 | type_ref.syntax().text_range(), |
51 | |builder| { | 51 | |builder| { |
@@ -278,9 +278,9 @@ mod tests { | |||
278 | use super::*; | 278 | use super::*; |
279 | 279 | ||
280 | #[test] | 280 | #[test] |
281 | fn change_return_type_to_result_simple() { | 281 | fn wrap_return_type_in_result_simple() { |
282 | check_assist( | 282 | check_assist( |
283 | change_return_type_to_result, | 283 | wrap_return_type_in_result, |
284 | r#"fn foo() -> i3<|>2 { | 284 | r#"fn foo() -> i3<|>2 { |
285 | let test = "test"; | 285 | let test = "test"; |
286 | return 42i32; | 286 | return 42i32; |
@@ -293,9 +293,9 @@ mod tests { | |||
293 | } | 293 | } |
294 | 294 | ||
295 | #[test] | 295 | #[test] |
296 | fn change_return_type_to_result_simple_closure() { | 296 | fn wrap_return_type_in_result_simple_closure() { |
297 | check_assist( | 297 | check_assist( |
298 | change_return_type_to_result, | 298 | wrap_return_type_in_result, |
299 | r#"fn foo() { | 299 | r#"fn foo() { |
300 | || -> i32<|> { | 300 | || -> i32<|> { |
301 | let test = "test"; | 301 | let test = "test"; |
@@ -312,9 +312,9 @@ mod tests { | |||
312 | } | 312 | } |
313 | 313 | ||
314 | #[test] | 314 | #[test] |
315 | fn change_return_type_to_result_simple_return_type_bad_cursor() { | 315 | fn wrap_return_type_in_result_simple_return_type_bad_cursor() { |
316 | check_assist_not_applicable( | 316 | check_assist_not_applicable( |
317 | change_return_type_to_result, | 317 | wrap_return_type_in_result, |
318 | r#"fn foo() -> i32 { | 318 | r#"fn foo() -> i32 { |
319 | let test = "test";<|> | 319 | let test = "test";<|> |
320 | return 42i32; | 320 | return 42i32; |
@@ -323,9 +323,9 @@ mod tests { | |||
323 | } | 323 | } |
324 | 324 | ||
325 | #[test] | 325 | #[test] |
326 | fn change_return_type_to_result_simple_return_type_bad_cursor_closure() { | 326 | fn wrap_return_type_in_result_simple_return_type_bad_cursor_closure() { |
327 | check_assist_not_applicable( | 327 | check_assist_not_applicable( |
328 | change_return_type_to_result, | 328 | wrap_return_type_in_result, |
329 | r#"fn foo() { | 329 | r#"fn foo() { |
330 | || -> i32 { | 330 | || -> i32 { |
331 | let test = "test";<|> | 331 | let test = "test";<|> |
@@ -336,9 +336,9 @@ mod tests { | |||
336 | } | 336 | } |
337 | 337 | ||
338 | #[test] | 338 | #[test] |
339 | fn change_return_type_to_result_closure_non_block() { | 339 | fn wrap_return_type_in_result_closure_non_block() { |
340 | check_assist_not_applicable( | 340 | check_assist_not_applicable( |
341 | change_return_type_to_result, | 341 | wrap_return_type_in_result, |
342 | r#"fn foo() { | 342 | r#"fn foo() { |
343 | || -> i<|>32 3; | 343 | || -> i<|>32 3; |
344 | }"#, | 344 | }"#, |
@@ -346,9 +346,9 @@ mod tests { | |||
346 | } | 346 | } |
347 | 347 | ||
348 | #[test] | 348 | #[test] |
349 | fn change_return_type_to_result_simple_return_type_already_result_std() { | 349 | fn wrap_return_type_in_result_simple_return_type_already_result_std() { |
350 | check_assist_not_applicable( | 350 | check_assist_not_applicable( |
351 | change_return_type_to_result, | 351 | wrap_return_type_in_result, |
352 | r#"fn foo() -> std::result::Result<i32<|>, String> { | 352 | r#"fn foo() -> std::result::Result<i32<|>, String> { |
353 | let test = "test"; | 353 | let test = "test"; |
354 | return 42i32; | 354 | return 42i32; |
@@ -357,10 +357,10 @@ mod tests { | |||
357 | } | 357 | } |
358 | 358 | ||
359 | #[test] | 359 | #[test] |
360 | fn change_return_type_to_result_simple_return_type_already_result() { | 360 | fn wrap_return_type_in_result_simple_return_type_already_result() { |
361 | mark::check!(change_return_type_to_result_simple_return_type_already_result); | 361 | mark::check!(wrap_return_type_in_result_simple_return_type_already_result); |
362 | check_assist_not_applicable( | 362 | check_assist_not_applicable( |
363 | change_return_type_to_result, | 363 | wrap_return_type_in_result, |
364 | r#"fn foo() -> Result<i32<|>, String> { | 364 | r#"fn foo() -> Result<i32<|>, String> { |
365 | let test = "test"; | 365 | let test = "test"; |
366 | return 42i32; | 366 | return 42i32; |
@@ -369,9 +369,9 @@ mod tests { | |||
369 | } | 369 | } |
370 | 370 | ||
371 | #[test] | 371 | #[test] |
372 | fn change_return_type_to_result_simple_return_type_already_result_closure() { | 372 | fn wrap_return_type_in_result_simple_return_type_already_result_closure() { |
373 | check_assist_not_applicable( | 373 | check_assist_not_applicable( |
374 | change_return_type_to_result, | 374 | wrap_return_type_in_result, |
375 | r#"fn foo() { | 375 | r#"fn foo() { |
376 | || -> Result<i32<|>, String> { | 376 | || -> Result<i32<|>, String> { |
377 | let test = "test"; | 377 | let test = "test"; |
@@ -382,9 +382,9 @@ mod tests { | |||
382 | } | 382 | } |
383 | 383 | ||
384 | #[test] | 384 | #[test] |
385 | fn change_return_type_to_result_simple_with_cursor() { | 385 | fn wrap_return_type_in_result_simple_with_cursor() { |
386 | check_assist( | 386 | check_assist( |
387 | change_return_type_to_result, | 387 | wrap_return_type_in_result, |
388 | r#"fn foo() -> <|>i32 { | 388 | r#"fn foo() -> <|>i32 { |
389 | let test = "test"; | 389 | let test = "test"; |
390 | return 42i32; | 390 | return 42i32; |
@@ -397,9 +397,9 @@ mod tests { | |||
397 | } | 397 | } |
398 | 398 | ||
399 | #[test] | 399 | #[test] |
400 | fn change_return_type_to_result_simple_with_tail() { | 400 | fn wrap_return_type_in_result_simple_with_tail() { |
401 | check_assist( | 401 | check_assist( |
402 | change_return_type_to_result, | 402 | wrap_return_type_in_result, |
403 | r#"fn foo() -><|> i32 { | 403 | r#"fn foo() -><|> i32 { |
404 | let test = "test"; | 404 | let test = "test"; |
405 | 42i32 | 405 | 42i32 |
@@ -412,9 +412,9 @@ mod tests { | |||
412 | } | 412 | } |
413 | 413 | ||
414 | #[test] | 414 | #[test] |
415 | fn change_return_type_to_result_simple_with_tail_closure() { | 415 | fn wrap_return_type_in_result_simple_with_tail_closure() { |
416 | check_assist( | 416 | check_assist( |
417 | change_return_type_to_result, | 417 | wrap_return_type_in_result, |
418 | r#"fn foo() { | 418 | r#"fn foo() { |
419 | || -><|> i32 { | 419 | || -><|> i32 { |
420 | let test = "test"; | 420 | let test = "test"; |
@@ -431,9 +431,9 @@ mod tests { | |||
431 | } | 431 | } |
432 | 432 | ||
433 | #[test] | 433 | #[test] |
434 | fn change_return_type_to_result_simple_with_tail_only() { | 434 | fn wrap_return_type_in_result_simple_with_tail_only() { |
435 | check_assist( | 435 | check_assist( |
436 | change_return_type_to_result, | 436 | wrap_return_type_in_result, |
437 | r#"fn foo() -> i32<|> { | 437 | r#"fn foo() -> i32<|> { |
438 | 42i32 | 438 | 42i32 |
439 | }"#, | 439 | }"#, |
@@ -444,9 +444,9 @@ mod tests { | |||
444 | } | 444 | } |
445 | 445 | ||
446 | #[test] | 446 | #[test] |
447 | fn change_return_type_to_result_simple_with_tail_block_like() { | 447 | fn wrap_return_type_in_result_simple_with_tail_block_like() { |
448 | check_assist( | 448 | check_assist( |
449 | change_return_type_to_result, | 449 | wrap_return_type_in_result, |
450 | r#"fn foo() -> i32<|> { | 450 | r#"fn foo() -> i32<|> { |
451 | if true { | 451 | if true { |
452 | 42i32 | 452 | 42i32 |
@@ -465,9 +465,9 @@ mod tests { | |||
465 | } | 465 | } |
466 | 466 | ||
467 | #[test] | 467 | #[test] |
468 | fn change_return_type_to_result_simple_without_block_closure() { | 468 | fn wrap_return_type_in_result_simple_without_block_closure() { |
469 | check_assist( | 469 | check_assist( |
470 | change_return_type_to_result, | 470 | wrap_return_type_in_result, |
471 | r#"fn foo() { | 471 | r#"fn foo() { |
472 | || -> i32<|> { | 472 | || -> i32<|> { |
473 | if true { | 473 | if true { |
@@ -490,9 +490,9 @@ mod tests { | |||
490 | } | 490 | } |
491 | 491 | ||
492 | #[test] | 492 | #[test] |
493 | fn change_return_type_to_result_simple_with_nested_if() { | 493 | fn wrap_return_type_in_result_simple_with_nested_if() { |
494 | check_assist( | 494 | check_assist( |
495 | change_return_type_to_result, | 495 | wrap_return_type_in_result, |
496 | r#"fn foo() -> i32<|> { | 496 | r#"fn foo() -> i32<|> { |
497 | if true { | 497 | if true { |
498 | if false { | 498 | if false { |
@@ -519,9 +519,9 @@ mod tests { | |||
519 | } | 519 | } |
520 | 520 | ||
521 | #[test] | 521 | #[test] |
522 | fn change_return_type_to_result_simple_with_await() { | 522 | fn wrap_return_type_in_result_simple_with_await() { |
523 | check_assist( | 523 | check_assist( |
524 | change_return_type_to_result, | 524 | wrap_return_type_in_result, |
525 | r#"async fn foo() -> i<|>32 { | 525 | r#"async fn foo() -> i<|>32 { |
526 | if true { | 526 | if true { |
527 | if false { | 527 | if false { |
@@ -548,9 +548,9 @@ mod tests { | |||
548 | } | 548 | } |
549 | 549 | ||
550 | #[test] | 550 | #[test] |
551 | fn change_return_type_to_result_simple_with_array() { | 551 | fn wrap_return_type_in_result_simple_with_array() { |
552 | check_assist( | 552 | check_assist( |
553 | change_return_type_to_result, | 553 | wrap_return_type_in_result, |
554 | r#"fn foo() -> [i32;<|> 3] { | 554 | r#"fn foo() -> [i32;<|> 3] { |
555 | [1, 2, 3] | 555 | [1, 2, 3] |
556 | }"#, | 556 | }"#, |
@@ -561,9 +561,9 @@ mod tests { | |||
561 | } | 561 | } |
562 | 562 | ||
563 | #[test] | 563 | #[test] |
564 | fn change_return_type_to_result_simple_with_cast() { | 564 | fn wrap_return_type_in_result_simple_with_cast() { |
565 | check_assist( | 565 | check_assist( |
566 | change_return_type_to_result, | 566 | wrap_return_type_in_result, |
567 | r#"fn foo() -<|>> i32 { | 567 | r#"fn foo() -<|>> i32 { |
568 | if true { | 568 | if true { |
569 | if false { | 569 | if false { |
@@ -590,9 +590,9 @@ mod tests { | |||
590 | } | 590 | } |
591 | 591 | ||
592 | #[test] | 592 | #[test] |
593 | fn change_return_type_to_result_simple_with_tail_block_like_match() { | 593 | fn wrap_return_type_in_result_simple_with_tail_block_like_match() { |
594 | check_assist( | 594 | check_assist( |
595 | change_return_type_to_result, | 595 | wrap_return_type_in_result, |
596 | r#"fn foo() -> i32<|> { | 596 | r#"fn foo() -> i32<|> { |
597 | let my_var = 5; | 597 | let my_var = 5; |
598 | match my_var { | 598 | match my_var { |
@@ -611,9 +611,9 @@ mod tests { | |||
611 | } | 611 | } |
612 | 612 | ||
613 | #[test] | 613 | #[test] |
614 | fn change_return_type_to_result_simple_with_loop_with_tail() { | 614 | fn wrap_return_type_in_result_simple_with_loop_with_tail() { |
615 | check_assist( | 615 | check_assist( |
616 | change_return_type_to_result, | 616 | wrap_return_type_in_result, |
617 | r#"fn foo() -> i32<|> { | 617 | r#"fn foo() -> i32<|> { |
618 | let my_var = 5; | 618 | let my_var = 5; |
619 | loop { | 619 | loop { |
@@ -636,9 +636,9 @@ mod tests { | |||
636 | } | 636 | } |
637 | 637 | ||
638 | #[test] | 638 | #[test] |
639 | fn change_return_type_to_result_simple_with_loop_in_let_stmt() { | 639 | fn wrap_return_type_in_result_simple_with_loop_in_let_stmt() { |
640 | check_assist( | 640 | check_assist( |
641 | change_return_type_to_result, | 641 | wrap_return_type_in_result, |
642 | r#"fn foo() -> i32<|> { | 642 | r#"fn foo() -> i32<|> { |
643 | let my_var = let x = loop { | 643 | let my_var = let x = loop { |
644 | break 1; | 644 | break 1; |
@@ -657,9 +657,9 @@ mod tests { | |||
657 | } | 657 | } |
658 | 658 | ||
659 | #[test] | 659 | #[test] |
660 | fn change_return_type_to_result_simple_with_tail_block_like_match_return_expr() { | 660 | fn wrap_return_type_in_result_simple_with_tail_block_like_match_return_expr() { |
661 | check_assist( | 661 | check_assist( |
662 | change_return_type_to_result, | 662 | wrap_return_type_in_result, |
663 | r#"fn foo() -> i32<|> { | 663 | r#"fn foo() -> i32<|> { |
664 | let my_var = 5; | 664 | let my_var = 5; |
665 | let res = match my_var { | 665 | let res = match my_var { |
@@ -681,7 +681,7 @@ mod tests { | |||
681 | ); | 681 | ); |
682 | 682 | ||
683 | check_assist( | 683 | check_assist( |
684 | change_return_type_to_result, | 684 | wrap_return_type_in_result, |
685 | r#"fn foo() -> i32<|> { | 685 | r#"fn foo() -> i32<|> { |
686 | let my_var = 5; | 686 | let my_var = 5; |
687 | let res = if my_var == 5 { | 687 | let res = if my_var == 5 { |
@@ -706,9 +706,9 @@ mod tests { | |||
706 | } | 706 | } |
707 | 707 | ||
708 | #[test] | 708 | #[test] |
709 | fn change_return_type_to_result_simple_with_tail_block_like_match_deeper() { | 709 | fn wrap_return_type_in_result_simple_with_tail_block_like_match_deeper() { |
710 | check_assist( | 710 | check_assist( |
711 | change_return_type_to_result, | 711 | wrap_return_type_in_result, |
712 | r#"fn foo() -> i32<|> { | 712 | r#"fn foo() -> i32<|> { |
713 | let my_var = 5; | 713 | let my_var = 5; |
714 | match my_var { | 714 | match my_var { |
@@ -751,9 +751,9 @@ mod tests { | |||
751 | } | 751 | } |
752 | 752 | ||
753 | #[test] | 753 | #[test] |
754 | fn change_return_type_to_result_simple_with_tail_block_like_early_return() { | 754 | fn wrap_return_type_in_result_simple_with_tail_block_like_early_return() { |
755 | check_assist( | 755 | check_assist( |
756 | change_return_type_to_result, | 756 | wrap_return_type_in_result, |
757 | r#"fn foo() -> i<|>32 { | 757 | r#"fn foo() -> i<|>32 { |
758 | let test = "test"; | 758 | let test = "test"; |
759 | if test == "test" { | 759 | if test == "test" { |
@@ -772,9 +772,9 @@ mod tests { | |||
772 | } | 772 | } |
773 | 773 | ||
774 | #[test] | 774 | #[test] |
775 | fn change_return_type_to_result_simple_with_closure() { | 775 | fn wrap_return_type_in_result_simple_with_closure() { |
776 | check_assist( | 776 | check_assist( |
777 | change_return_type_to_result, | 777 | wrap_return_type_in_result, |
778 | r#"fn foo(the_field: u32) -><|> u32 { | 778 | r#"fn foo(the_field: u32) -><|> u32 { |
779 | let true_closure = || { | 779 | let true_closure = || { |
780 | return true; | 780 | return true; |
@@ -812,7 +812,7 @@ mod tests { | |||
812 | ); | 812 | ); |
813 | 813 | ||
814 | check_assist( | 814 | check_assist( |
815 | change_return_type_to_result, | 815 | wrap_return_type_in_result, |
816 | r#"fn foo(the_field: u32) -> u32<|> { | 816 | r#"fn foo(the_field: u32) -> u32<|> { |
817 | let true_closure = || { | 817 | let true_closure = || { |
818 | return true; | 818 | return true; |
@@ -853,9 +853,9 @@ mod tests { | |||
853 | } | 853 | } |
854 | 854 | ||
855 | #[test] | 855 | #[test] |
856 | fn change_return_type_to_result_simple_with_weird_forms() { | 856 | fn wrap_return_type_in_result_simple_with_weird_forms() { |
857 | check_assist( | 857 | check_assist( |
858 | change_return_type_to_result, | 858 | wrap_return_type_in_result, |
859 | r#"fn foo() -> i32<|> { | 859 | r#"fn foo() -> i32<|> { |
860 | let test = "test"; | 860 | let test = "test"; |
861 | if test == "test" { | 861 | if test == "test" { |
@@ -885,7 +885,7 @@ mod tests { | |||
885 | ); | 885 | ); |
886 | 886 | ||
887 | check_assist( | 887 | check_assist( |
888 | change_return_type_to_result, | 888 | wrap_return_type_in_result, |
889 | r#"fn foo() -> i32<|> { | 889 | r#"fn foo() -> i32<|> { |
890 | let test = "test"; | 890 | let test = "test"; |
891 | if test == "test" { | 891 | if test == "test" { |
@@ -919,7 +919,7 @@ mod tests { | |||
919 | ); | 919 | ); |
920 | 920 | ||
921 | check_assist( | 921 | check_assist( |
922 | change_return_type_to_result, | 922 | wrap_return_type_in_result, |
923 | r#"fn foo() -> i3<|>2 { | 923 | r#"fn foo() -> i3<|>2 { |
924 | let test = "test"; | 924 | let test = "test"; |
925 | let other = 5; | 925 | let other = 5; |
@@ -961,7 +961,7 @@ mod tests { | |||
961 | ); | 961 | ); |
962 | 962 | ||
963 | check_assist( | 963 | check_assist( |
964 | change_return_type_to_result, | 964 | wrap_return_type_in_result, |
965 | r#"fn foo(the_field: u32) -> u32<|> { | 965 | r#"fn foo(the_field: u32) -> u32<|> { |
966 | if the_field < 5 { | 966 | if the_field < 5 { |
967 | let mut i = 0; | 967 | let mut i = 0; |
@@ -1001,7 +1001,7 @@ mod tests { | |||
1001 | ); | 1001 | ); |
1002 | 1002 | ||
1003 | check_assist( | 1003 | check_assist( |
1004 | change_return_type_to_result, | 1004 | wrap_return_type_in_result, |
1005 | r#"fn foo(the_field: u32) -> u3<|>2 { | 1005 | r#"fn foo(the_field: u32) -> u3<|>2 { |
1006 | if the_field < 5 { | 1006 | if the_field < 5 { |
1007 | let mut i = 0; | 1007 | let mut i = 0; |
@@ -1029,7 +1029,7 @@ mod tests { | |||
1029 | ); | 1029 | ); |
1030 | 1030 | ||
1031 | check_assist( | 1031 | check_assist( |
1032 | change_return_type_to_result, | 1032 | wrap_return_type_in_result, |
1033 | r#"fn foo(the_field: u32) -> u32<|> { | 1033 | r#"fn foo(the_field: u32) -> u32<|> { |
1034 | if the_field < 5 { | 1034 | if the_field < 5 { |
1035 | let mut i = 0; | 1035 | let mut i = 0; |
@@ -1059,7 +1059,7 @@ mod tests { | |||
1059 | ); | 1059 | ); |
1060 | 1060 | ||
1061 | check_assist( | 1061 | check_assist( |
1062 | change_return_type_to_result, | 1062 | wrap_return_type_in_result, |
1063 | r#"fn foo(the_field: u32) -> <|>u32 { | 1063 | r#"fn foo(the_field: u32) -> <|>u32 { |
1064 | if the_field < 5 { | 1064 | if the_field < 5 { |
1065 | let mut i = 0; | 1065 | let mut i = 0; |
diff --git a/crates/assists/src/lib.rs b/crates/assists/src/lib.rs index 92f764145..e8d81b33d 100644 --- a/crates/assists/src/lib.rs +++ b/crates/assists/src/lib.rs | |||
@@ -125,7 +125,6 @@ mod handlers { | |||
125 | mod add_turbo_fish; | 125 | mod add_turbo_fish; |
126 | mod apply_demorgan; | 126 | mod apply_demorgan; |
127 | mod auto_import; | 127 | mod auto_import; |
128 | mod change_return_type_to_result; | ||
129 | mod change_visibility; | 128 | mod change_visibility; |
130 | mod convert_integer_literal; | 129 | mod convert_integer_literal; |
131 | mod early_return; | 130 | mod early_return; |
@@ -165,6 +164,7 @@ mod handlers { | |||
165 | mod replace_unwrap_with_match; | 164 | mod replace_unwrap_with_match; |
166 | mod split_import; | 165 | mod split_import; |
167 | mod unwrap_block; | 166 | mod unwrap_block; |
167 | mod wrap_return_type_in_result; | ||
168 | 168 | ||
169 | pub(crate) fn all() -> &'static [Handler] { | 169 | pub(crate) fn all() -> &'static [Handler] { |
170 | &[ | 170 | &[ |
@@ -173,7 +173,6 @@ mod handlers { | |||
173 | add_turbo_fish::add_turbo_fish, | 173 | add_turbo_fish::add_turbo_fish, |
174 | apply_demorgan::apply_demorgan, | 174 | apply_demorgan::apply_demorgan, |
175 | auto_import::auto_import, | 175 | auto_import::auto_import, |
176 | change_return_type_to_result::change_return_type_to_result, | ||
177 | change_visibility::change_visibility, | 176 | change_visibility::change_visibility, |
178 | convert_integer_literal::convert_integer_literal, | 177 | convert_integer_literal::convert_integer_literal, |
179 | early_return::convert_to_guarded_return, | 178 | early_return::convert_to_guarded_return, |
@@ -215,6 +214,7 @@ mod handlers { | |||
215 | replace_unwrap_with_match::replace_unwrap_with_match, | 214 | replace_unwrap_with_match::replace_unwrap_with_match, |
216 | split_import::split_import, | 215 | split_import::split_import, |
217 | unwrap_block::unwrap_block, | 216 | unwrap_block::unwrap_block, |
217 | wrap_return_type_in_result::wrap_return_type_in_result, | ||
218 | // These are manually sorted for better priorities | 218 | // These are manually sorted for better priorities |
219 | add_missing_impl_members::add_missing_impl_members, | 219 | add_missing_impl_members::add_missing_impl_members, |
220 | add_missing_impl_members::add_missing_default_members, | 220 | add_missing_impl_members::add_missing_default_members, |
diff --git a/crates/assists/src/tests/generated.rs b/crates/assists/src/tests/generated.rs index 629788f05..dbf4f21aa 100644 --- a/crates/assists/src/tests/generated.rs +++ b/crates/assists/src/tests/generated.rs | |||
@@ -159,19 +159,6 @@ pub mod std { pub mod collections { pub struct HashMap { } } } | |||
159 | } | 159 | } |
160 | 160 | ||
161 | #[test] | 161 | #[test] |
162 | fn doctest_change_return_type_to_result() { | ||
163 | check_doc_test( | ||
164 | "change_return_type_to_result", | ||
165 | r#####" | ||
166 | fn foo() -> i32<|> { 42i32 } | ||
167 | "#####, | ||
168 | r#####" | ||
169 | fn foo() -> Result<i32, ${0:_}> { Ok(42i32) } | ||
170 | "#####, | ||
171 | ) | ||
172 | } | ||
173 | |||
174 | #[test] | ||
175 | fn doctest_change_visibility() { | 162 | fn doctest_change_visibility() { |
176 | check_doc_test( | 163 | check_doc_test( |
177 | "change_visibility", | 164 | "change_visibility", |
@@ -989,3 +976,16 @@ fn foo() { | |||
989 | "#####, | 976 | "#####, |
990 | ) | 977 | ) |
991 | } | 978 | } |
979 | |||
980 | #[test] | ||
981 | fn doctest_wrap_return_type_in_result() { | ||
982 | check_doc_test( | ||
983 | "wrap_return_type_in_result", | ||
984 | r#####" | ||
985 | fn foo() -> i32<|> { 42i32 } | ||
986 | "#####, | ||
987 | r#####" | ||
988 | fn foo() -> Result<i32, ${0:_}> { Ok(42i32) } | ||
989 | "#####, | ||
990 | ) | ||
991 | } | ||