@@ -47,42 +47,22 @@ pub(super) fn compare_impl_method<'tcx>(
47
47
48
48
let impl_m_span = tcx. def_span ( impl_m. def_id ) ;
49
49
50
- if let Err ( _) = compare_self_type ( tcx, impl_m, impl_m_span, trait_m, impl_trait_ref) {
51
- return ;
52
- }
53
-
54
- if let Err ( _) = compare_number_of_generics ( tcx, impl_m, trait_m, trait_item_span, false ) {
55
- return ;
56
- }
57
-
58
- if let Err ( _) = compare_generic_param_kinds ( tcx, impl_m, trait_m, false ) {
59
- return ;
60
- }
61
-
62
- if let Err ( _) =
63
- compare_number_of_method_arguments ( tcx, impl_m, impl_m_span, trait_m, trait_item_span)
64
- {
65
- return ;
66
- }
67
-
68
- if let Err ( _) = compare_synthetic_generics ( tcx, impl_m, trait_m) {
69
- return ;
70
- }
71
-
72
- if let Err ( _) = compare_asyncness ( tcx, impl_m, impl_m_span, trait_m, trait_item_span) {
73
- return ;
74
- }
75
-
76
- if let Err ( _) = compare_method_predicate_entailment (
77
- tcx,
78
- impl_m,
79
- impl_m_span,
80
- trait_m,
81
- impl_trait_ref,
82
- CheckImpliedWfMode :: Check ,
83
- ) {
84
- return ;
85
- }
50
+ let _: Result < _ , ErrorGuaranteed > = try {
51
+ compare_self_type ( tcx, impl_m, impl_m_span, trait_m, impl_trait_ref) ?;
52
+ compare_number_of_generics ( tcx, impl_m, trait_m, trait_item_span, false ) ?;
53
+ compare_generic_param_kinds ( tcx, impl_m, trait_m, false ) ?;
54
+ compare_number_of_method_arguments ( tcx, impl_m, impl_m_span, trait_m, trait_item_span) ?;
55
+ compare_synthetic_generics ( tcx, impl_m, trait_m) ?;
56
+ compare_asyncness ( tcx, impl_m, impl_m_span, trait_m, trait_item_span) ?;
57
+ compare_method_predicate_entailment (
58
+ tcx,
59
+ impl_m,
60
+ impl_m_span,
61
+ trait_m,
62
+ impl_trait_ref,
63
+ CheckImpliedWfMode :: Check ,
64
+ ) ?;
65
+ } ;
86
66
}
87
67
88
68
/// This function is best explained by example. Consider a trait:
@@ -1493,7 +1473,7 @@ fn compare_synthetic_generics<'tcx>(
1493
1473
// explicit generics
1494
1474
( true , false ) => {
1495
1475
err. span_label ( impl_span, "expected generic parameter, found `impl Trait`" ) ;
1496
- ( || {
1476
+ let _ : Option < _ > = try {
1497
1477
// try taking the name from the trait impl
1498
1478
// FIXME: this is obviously suboptimal since the name can already be used
1499
1479
// as another generic argument
@@ -1526,14 +1506,13 @@ fn compare_synthetic_generics<'tcx>(
1526
1506
] ,
1527
1507
Applicability :: MaybeIncorrect ,
1528
1508
) ;
1529
- Some ( ( ) )
1530
- } ) ( ) ;
1509
+ } ;
1531
1510
}
1532
1511
// The case where the trait method uses `impl Trait`, but the impl method uses
1533
1512
// explicit generics.
1534
1513
( false , true ) => {
1535
1514
err. span_label ( impl_span, "expected `impl Trait`, found generic parameter" ) ;
1536
- ( || {
1515
+ let _ : Option < _ > = try {
1537
1516
let impl_m = impl_m. def_id . as_local ( ) ?;
1538
1517
let impl_m = tcx. hir ( ) . expect_impl_item ( impl_m) ;
1539
1518
let input_tys = match impl_m. kind {
@@ -1573,8 +1552,7 @@ fn compare_synthetic_generics<'tcx>(
1573
1552
] ,
1574
1553
Applicability :: MaybeIncorrect ,
1575
1554
) ;
1576
- Some ( ( ) )
1577
- } ) ( ) ;
1555
+ } ;
1578
1556
}
1579
1557
_ => unreachable ! ( ) ,
1580
1558
}
@@ -1799,16 +1777,16 @@ pub(super) fn compare_impl_ty<'tcx>(
1799
1777
) {
1800
1778
debug ! ( "compare_impl_type(impl_trait_ref={:?})" , impl_trait_ref) ;
1801
1779
1802
- let _: Result < ( ) , ErrorGuaranteed > = ( || {
1780
+ let _: Result < ( ) , ErrorGuaranteed > = try {
1803
1781
compare_number_of_generics ( tcx, impl_ty, trait_ty, trait_item_span, false ) ?;
1804
1782
1805
1783
compare_generic_param_kinds ( tcx, impl_ty, trait_ty, false ) ?;
1806
1784
1807
1785
let sp = tcx. def_span ( impl_ty. def_id ) ;
1808
1786
compare_type_predicate_entailment ( tcx, impl_ty, sp, trait_ty, impl_trait_ref) ?;
1809
1787
1810
- check_type_bounds ( tcx, trait_ty, impl_ty, impl_ty_span, impl_trait_ref)
1811
- } ) ( ) ;
1788
+ check_type_bounds ( tcx, trait_ty, impl_ty, impl_ty_span, impl_trait_ref) ? ;
1789
+ } ;
1812
1790
}
1813
1791
1814
1792
/// The equivalent of [compare_method_predicate_entailment], but for associated types
0 commit comments