@@ -37,7 +37,7 @@ use crate::{
3737// bar("", baz());
3838// }
3939//
40- // fn bar(arg: &str, baz: Baz) ${0:-> () } {
40+ // fn bar(arg: &str, baz: Baz) ${0:-> _ } {
4141// todo!()
4242// }
4343//
@@ -342,7 +342,7 @@ impl FunctionBuilder {
342342}
343343
344344/// Makes an optional return type along with whether the return type should be focused by the cursor.
345- /// If we cannot infer what the return type should be, we create unit as a placeholder.
345+ /// If we cannot infer what the return type should be, we create a placeholder type .
346346///
347347/// The rule for whether we focus a return type or not (and thus focus the function body),
348348/// is rather simple:
@@ -357,14 +357,14 @@ fn make_return_type(
357357) -> ( Option < ast:: RetType > , bool ) {
358358 let ( ret_ty, should_focus_return_type) = {
359359 match ctx. sema . type_of_expr ( call) . map ( TypeInfo :: original) {
360- Some ( ty) if ty. is_unknown ( ) => ( Some ( make:: ty_unit ( ) ) , true ) ,
361- None => ( Some ( make:: ty_unit ( ) ) , true ) ,
360+ Some ( ty) if ty. is_unknown ( ) => ( Some ( make:: ty_placeholder ( ) ) , true ) ,
361+ None => ( Some ( make:: ty_placeholder ( ) ) , true ) ,
362362 Some ( ty) if ty. is_unit ( ) => ( None , false ) ,
363363 Some ( ty) => {
364364 let rendered = ty. display_source_code ( ctx. db ( ) , target_module. into ( ) ) ;
365365 match rendered {
366366 Ok ( rendered) => ( Some ( make:: ty ( & rendered) ) , false ) ,
367- Err ( _) => ( Some ( make:: ty_unit ( ) ) , true ) ,
367+ Err ( _) => ( Some ( make:: ty_placeholder ( ) ) , true ) ,
368368 }
369369 }
370370 }
@@ -458,7 +458,7 @@ fn fn_args(
458458 ty
459459 }
460460 }
461- None => String :: from ( "() " ) ,
461+ None => String :: from ( "_ " ) ,
462462 } ) ;
463463 }
464464 deduplicate_arg_names ( & mut arg_names) ;
@@ -639,7 +639,7 @@ fn foo() {
639639 bar();
640640}
641641
642- fn bar() ${0:-> () } {
642+ fn bar() ${0:-> _ } {
643643 todo!()
644644}
645645" ,
@@ -666,7 +666,7 @@ impl Foo {
666666 }
667667}
668668
669- fn bar() ${0:-> () } {
669+ fn bar() ${0:-> _ } {
670670 todo!()
671671}
672672" ,
@@ -690,7 +690,7 @@ fn foo1() {
690690 bar();
691691}
692692
693- fn bar() ${0:-> () } {
693+ fn bar() ${0:-> _ } {
694694 todo!()
695695}
696696
@@ -716,7 +716,7 @@ mod baz {
716716 bar();
717717 }
718718
719- fn bar() ${0:-> () } {
719+ fn bar() ${0:-> _ } {
720720 todo!()
721721 }
722722}
@@ -740,7 +740,7 @@ fn foo() {
740740 bar(BazBaz);
741741}
742742
743- fn bar(baz_baz: BazBaz) ${0:-> () } {
743+ fn bar(baz_baz: BazBaz) ${0:-> _ } {
744744 todo!()
745745}
746746" ,
@@ -763,7 +763,7 @@ fn foo() {
763763 bar(&BazBaz as *const BazBaz);
764764}
765765
766- fn bar(baz_baz: *const BazBaz) ${0:-> () } {
766+ fn bar(baz_baz: *const BazBaz) ${0:-> _ } {
767767 todo!()
768768}
769769" ,
@@ -788,7 +788,7 @@ fn foo() {
788788 bar(baz());
789789}
790790
791- fn bar(baz: Baz) ${0:-> () } {
791+ fn bar(baz: Baz) ${0:-> _ } {
792792 todo!()
793793}
794794" ,
@@ -1091,7 +1091,7 @@ fn foo() {
10911091 bar(Baz::new);
10921092}
10931093
1094- fn bar(new: fn) ${0:-> () } {
1094+ fn bar(new: fn) ${0:-> _ } {
10951095 todo!()
10961096}
10971097" ,
@@ -1115,15 +1115,15 @@ fn foo() {
11151115 bar(closure)
11161116}
11171117
1118- fn bar(closure: () ) {
1118+ fn bar(closure: _ ) {
11191119 ${0:todo!()}
11201120}
11211121" ,
11221122 )
11231123 }
11241124
11251125 #[ test]
1126- fn unresolveable_types_default_to_unit ( ) {
1126+ fn unresolveable_types_default_to_placeholder ( ) {
11271127 check_assist (
11281128 generate_function,
11291129 r"
@@ -1136,7 +1136,7 @@ fn foo() {
11361136 bar(baz)
11371137}
11381138
1139- fn bar(baz: () ) {
1139+ fn bar(baz: _ ) {
11401140 ${0:todo!()}
11411141}
11421142" ,
@@ -1400,7 +1400,7 @@ impl Foo {
14001400 self.bar();
14011401 }
14021402
1403- fn bar(&self) ${0:-> () } {
1403+ fn bar(&self) ${0:-> _ } {
14041404 todo!()
14051405 }
14061406}
@@ -1422,7 +1422,7 @@ fn foo() {
14221422 bar(42).await();
14231423}
14241424
1425- async fn bar(arg: i32) ${0:-> () } {
1425+ async fn bar(arg: i32) ${0:-> _ } {
14261426 todo!()
14271427}
14281428" ,
@@ -1443,7 +1443,7 @@ fn foo() {S.bar();}
14431443impl S {
14441444
14451445
1446- fn bar(&self) ${0:-> () } {
1446+ fn bar(&self) ${0:-> _ } {
14471447 todo!()
14481448}
14491449}
@@ -1465,7 +1465,7 @@ impl S {}
14651465struct S;
14661466fn foo() {S.bar();}
14671467impl S {
1468- fn bar(&self) ${0:-> () } {
1468+ fn bar(&self) ${0:-> _ } {
14691469 todo!()
14701470 }
14711471}
@@ -1490,7 +1490,7 @@ mod s {
14901490impl S {
14911491
14921492
1493- pub(crate) fn bar(&self) ${0:-> () } {
1493+ pub(crate) fn bar(&self) ${0:-> _ } {
14941494 todo!()
14951495 }
14961496}
@@ -1523,7 +1523,7 @@ mod s {
15231523impl S {
15241524
15251525
1526- fn bar(&self) ${0:-> () } {
1526+ fn bar(&self) ${0:-> _ } {
15271527 todo!()
15281528}
15291529}
@@ -1546,7 +1546,7 @@ fn foo() {S.bar();}
15461546impl S {
15471547
15481548
1549- fn bar(&self) ${0:-> () } {
1549+ fn bar(&self) ${0:-> _ } {
15501550 todo!()
15511551}
15521552}
@@ -1568,7 +1568,7 @@ fn foo() {S::bar();}
15681568impl S {
15691569
15701570
1571- fn bar() ${0:-> () } {
1571+ fn bar() ${0:-> _ } {
15721572 todo!()
15731573}
15741574}
@@ -1590,7 +1590,7 @@ impl S {}
15901590struct S;
15911591fn foo() {S::bar();}
15921592impl S {
1593- fn bar() ${0:-> () } {
1593+ fn bar() ${0:-> _ } {
15941594 todo!()
15951595 }
15961596}
@@ -1615,7 +1615,7 @@ mod s {
16151615impl S {
16161616
16171617
1618- pub(crate) fn bar() ${0:-> () } {
1618+ pub(crate) fn bar() ${0:-> _ } {
16191619 todo!()
16201620 }
16211621}
@@ -1639,7 +1639,7 @@ fn foo() {S::bar();}
16391639impl S {
16401640
16411641
1642- fn bar() ${0:-> () } {
1642+ fn bar() ${0:-> _ } {
16431643 todo!()
16441644}
16451645}
0 commit comments