@@ -37,7 +37,7 @@ use crate::{
37
37
// bar("", baz());
38
38
// }
39
39
//
40
- // fn bar(arg: &str, baz: Baz) ${0:-> () } {
40
+ // fn bar(arg: &str, baz: Baz) ${0:-> _ } {
41
41
// todo!()
42
42
// }
43
43
//
@@ -342,7 +342,7 @@ impl FunctionBuilder {
342
342
}
343
343
344
344
/// 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 .
346
346
///
347
347
/// The rule for whether we focus a return type or not (and thus focus the function body),
348
348
/// is rather simple:
@@ -357,14 +357,14 @@ fn make_return_type(
357
357
) -> ( Option < ast:: RetType > , bool ) {
358
358
let ( ret_ty, should_focus_return_type) = {
359
359
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 ) ,
362
362
Some ( ty) if ty. is_unit ( ) => ( None , false ) ,
363
363
Some ( ty) => {
364
364
let rendered = ty. display_source_code ( ctx. db ( ) , target_module. into ( ) ) ;
365
365
match rendered {
366
366
Ok ( rendered) => ( Some ( make:: ty ( & rendered) ) , false ) ,
367
- Err ( _) => ( Some ( make:: ty_unit ( ) ) , true ) ,
367
+ Err ( _) => ( Some ( make:: ty_placeholder ( ) ) , true ) ,
368
368
}
369
369
}
370
370
}
@@ -458,7 +458,7 @@ fn fn_args(
458
458
ty
459
459
}
460
460
}
461
- None => String :: from ( "() " ) ,
461
+ None => String :: from ( "_ " ) ,
462
462
} ) ;
463
463
}
464
464
deduplicate_arg_names ( & mut arg_names) ;
@@ -639,7 +639,7 @@ fn foo() {
639
639
bar();
640
640
}
641
641
642
- fn bar() ${0:-> () } {
642
+ fn bar() ${0:-> _ } {
643
643
todo!()
644
644
}
645
645
" ,
@@ -666,7 +666,7 @@ impl Foo {
666
666
}
667
667
}
668
668
669
- fn bar() ${0:-> () } {
669
+ fn bar() ${0:-> _ } {
670
670
todo!()
671
671
}
672
672
" ,
@@ -690,7 +690,7 @@ fn foo1() {
690
690
bar();
691
691
}
692
692
693
- fn bar() ${0:-> () } {
693
+ fn bar() ${0:-> _ } {
694
694
todo!()
695
695
}
696
696
@@ -716,7 +716,7 @@ mod baz {
716
716
bar();
717
717
}
718
718
719
- fn bar() ${0:-> () } {
719
+ fn bar() ${0:-> _ } {
720
720
todo!()
721
721
}
722
722
}
@@ -740,7 +740,7 @@ fn foo() {
740
740
bar(BazBaz);
741
741
}
742
742
743
- fn bar(baz_baz: BazBaz) ${0:-> () } {
743
+ fn bar(baz_baz: BazBaz) ${0:-> _ } {
744
744
todo!()
745
745
}
746
746
" ,
@@ -763,7 +763,7 @@ fn foo() {
763
763
bar(&BazBaz as *const BazBaz);
764
764
}
765
765
766
- fn bar(baz_baz: *const BazBaz) ${0:-> () } {
766
+ fn bar(baz_baz: *const BazBaz) ${0:-> _ } {
767
767
todo!()
768
768
}
769
769
" ,
@@ -788,7 +788,7 @@ fn foo() {
788
788
bar(baz());
789
789
}
790
790
791
- fn bar(baz: Baz) ${0:-> () } {
791
+ fn bar(baz: Baz) ${0:-> _ } {
792
792
todo!()
793
793
}
794
794
" ,
@@ -1091,7 +1091,7 @@ fn foo() {
1091
1091
bar(Baz::new);
1092
1092
}
1093
1093
1094
- fn bar(new: fn) ${0:-> () } {
1094
+ fn bar(new: fn) ${0:-> _ } {
1095
1095
todo!()
1096
1096
}
1097
1097
" ,
@@ -1115,15 +1115,15 @@ fn foo() {
1115
1115
bar(closure)
1116
1116
}
1117
1117
1118
- fn bar(closure: () ) {
1118
+ fn bar(closure: _ ) {
1119
1119
${0:todo!()}
1120
1120
}
1121
1121
" ,
1122
1122
)
1123
1123
}
1124
1124
1125
1125
#[ test]
1126
- fn unresolveable_types_default_to_unit ( ) {
1126
+ fn unresolveable_types_default_to_placeholder ( ) {
1127
1127
check_assist (
1128
1128
generate_function,
1129
1129
r"
@@ -1136,7 +1136,7 @@ fn foo() {
1136
1136
bar(baz)
1137
1137
}
1138
1138
1139
- fn bar(baz: () ) {
1139
+ fn bar(baz: _ ) {
1140
1140
${0:todo!()}
1141
1141
}
1142
1142
" ,
@@ -1400,7 +1400,7 @@ impl Foo {
1400
1400
self.bar();
1401
1401
}
1402
1402
1403
- fn bar(&self) ${0:-> () } {
1403
+ fn bar(&self) ${0:-> _ } {
1404
1404
todo!()
1405
1405
}
1406
1406
}
@@ -1422,7 +1422,7 @@ fn foo() {
1422
1422
bar(42).await();
1423
1423
}
1424
1424
1425
- async fn bar(arg: i32) ${0:-> () } {
1425
+ async fn bar(arg: i32) ${0:-> _ } {
1426
1426
todo!()
1427
1427
}
1428
1428
" ,
@@ -1443,7 +1443,7 @@ fn foo() {S.bar();}
1443
1443
impl S {
1444
1444
1445
1445
1446
- fn bar(&self) ${0:-> () } {
1446
+ fn bar(&self) ${0:-> _ } {
1447
1447
todo!()
1448
1448
}
1449
1449
}
@@ -1465,7 +1465,7 @@ impl S {}
1465
1465
struct S;
1466
1466
fn foo() {S.bar();}
1467
1467
impl S {
1468
- fn bar(&self) ${0:-> () } {
1468
+ fn bar(&self) ${0:-> _ } {
1469
1469
todo!()
1470
1470
}
1471
1471
}
@@ -1490,7 +1490,7 @@ mod s {
1490
1490
impl S {
1491
1491
1492
1492
1493
- pub(crate) fn bar(&self) ${0:-> () } {
1493
+ pub(crate) fn bar(&self) ${0:-> _ } {
1494
1494
todo!()
1495
1495
}
1496
1496
}
@@ -1523,7 +1523,7 @@ mod s {
1523
1523
impl S {
1524
1524
1525
1525
1526
- fn bar(&self) ${0:-> () } {
1526
+ fn bar(&self) ${0:-> _ } {
1527
1527
todo!()
1528
1528
}
1529
1529
}
@@ -1546,7 +1546,7 @@ fn foo() {S.bar();}
1546
1546
impl S {
1547
1547
1548
1548
1549
- fn bar(&self) ${0:-> () } {
1549
+ fn bar(&self) ${0:-> _ } {
1550
1550
todo!()
1551
1551
}
1552
1552
}
@@ -1568,7 +1568,7 @@ fn foo() {S::bar();}
1568
1568
impl S {
1569
1569
1570
1570
1571
- fn bar() ${0:-> () } {
1571
+ fn bar() ${0:-> _ } {
1572
1572
todo!()
1573
1573
}
1574
1574
}
@@ -1590,7 +1590,7 @@ impl S {}
1590
1590
struct S;
1591
1591
fn foo() {S::bar();}
1592
1592
impl S {
1593
- fn bar() ${0:-> () } {
1593
+ fn bar() ${0:-> _ } {
1594
1594
todo!()
1595
1595
}
1596
1596
}
@@ -1615,7 +1615,7 @@ mod s {
1615
1615
impl S {
1616
1616
1617
1617
1618
- pub(crate) fn bar() ${0:-> () } {
1618
+ pub(crate) fn bar() ${0:-> _ } {
1619
1619
todo!()
1620
1620
}
1621
1621
}
@@ -1639,7 +1639,7 @@ fn foo() {S::bar();}
1639
1639
impl S {
1640
1640
1641
1641
1642
- fn bar() ${0:-> () } {
1642
+ fn bar() ${0:-> _ } {
1643
1643
todo!()
1644
1644
}
1645
1645
}
0 commit comments