@@ -47,42 +47,22 @@ pub(super) fn compare_impl_method<'tcx>(
4747
4848 let impl_m_span = tcx. def_span ( impl_m. def_id ) ;
4949
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+ } ;
8666}
8767
8868/// This function is best explained by example. Consider a trait:
@@ -1493,7 +1473,7 @@ fn compare_synthetic_generics<'tcx>(
14931473 // explicit generics
14941474 ( true , false ) => {
14951475 err. span_label ( impl_span, "expected generic parameter, found `impl Trait`" ) ;
1496- ( || {
1476+ let _ : Option < _ > = try {
14971477 // try taking the name from the trait impl
14981478 // FIXME: this is obviously suboptimal since the name can already be used
14991479 // as another generic argument
@@ -1526,14 +1506,13 @@ fn compare_synthetic_generics<'tcx>(
15261506 ] ,
15271507 Applicability :: MaybeIncorrect ,
15281508 ) ;
1529- Some ( ( ) )
1530- } ) ( ) ;
1509+ } ;
15311510 }
15321511 // The case where the trait method uses `impl Trait`, but the impl method uses
15331512 // explicit generics.
15341513 ( false , true ) => {
15351514 err. span_label ( impl_span, "expected `impl Trait`, found generic parameter" ) ;
1536- ( || {
1515+ let _ : Option < _ > = try {
15371516 let impl_m = impl_m. def_id . as_local ( ) ?;
15381517 let impl_m = tcx. hir ( ) . expect_impl_item ( impl_m) ;
15391518 let input_tys = match impl_m. kind {
@@ -1573,8 +1552,7 @@ fn compare_synthetic_generics<'tcx>(
15731552 ] ,
15741553 Applicability :: MaybeIncorrect ,
15751554 ) ;
1576- Some ( ( ) )
1577- } ) ( ) ;
1555+ } ;
15781556 }
15791557 _ => unreachable ! ( ) ,
15801558 }
@@ -1799,16 +1777,16 @@ pub(super) fn compare_impl_ty<'tcx>(
17991777) {
18001778 debug ! ( "compare_impl_type(impl_trait_ref={:?})" , impl_trait_ref) ;
18011779
1802- let _: Result < ( ) , ErrorGuaranteed > = ( || {
1780+ let _: Result < ( ) , ErrorGuaranteed > = try {
18031781 compare_number_of_generics ( tcx, impl_ty, trait_ty, trait_item_span, false ) ?;
18041782
18051783 compare_generic_param_kinds ( tcx, impl_ty, trait_ty, false ) ?;
18061784
18071785 let sp = tcx. def_span ( impl_ty. def_id ) ;
18081786 compare_type_predicate_entailment ( tcx, impl_ty, sp, trait_ty, impl_trait_ref) ?;
18091787
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+ } ;
18121790}
18131791
18141792/// The equivalent of [compare_method_predicate_entailment], but for associated types
0 commit comments