@@ -192,7 +192,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
192192 error : MethodError < ' tcx > ,
193193 expected : Expectation < ' tcx > ,
194194 trait_missing_method : bool ,
195- ) -> Result < Diag < ' _ > , ErrorGuaranteed > {
195+ ) -> ErrorGuaranteed {
196196 let ( span, sugg_span, source, item_name, args) = match self . tcx . hir_node ( call_id) {
197197 hir:: Node :: Expr ( & hir:: Expr {
198198 kind : hir:: ExprKind :: MethodCall ( segment, rcvr, args, _) ,
@@ -226,7 +226,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
226226 } ;
227227
228228 // Avoid suggestions when we don't know what's going on.
229- rcvr_ty. error_reported ( ) ?;
229+ if let Err ( guar) = rcvr_ty. error_reported ( ) {
230+ return guar;
231+ }
230232
231233 match error {
232234 MethodError :: NoMatch ( mut no_match_data) => {
@@ -263,7 +265,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
263265 & mut sources,
264266 Some ( sugg_span) ,
265267 ) ;
266- return Err ( err. emit ( ) ) ;
268+ return err. emit ( ) ;
267269 }
268270
269271 MethodError :: PrivateMatch ( kind, def_id, out_of_scope_traits) => {
@@ -284,7 +286,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
284286 . unwrap_or_else ( || self . tcx . def_span ( def_id) ) ;
285287 err. span_label ( sp, format ! ( "private {kind} defined here" ) ) ;
286288 self . suggest_valid_traits ( & mut err, item_name, out_of_scope_traits, true ) ;
287- return Err ( err. emit ( ) ) ;
289+ return err. emit ( ) ;
288290 }
289291
290292 MethodError :: IllegalSizedBound { candidates, needs_mut, bound_span, self_expr } => {
@@ -341,7 +343,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
341343 }
342344 }
343345 }
344- return Err ( err. emit ( ) ) ;
346+ return err. emit ( ) ;
345347 }
346348
347349 MethodError :: BadReturnType => bug ! ( "no return type expectations but got BadReturnType" ) ,
@@ -561,7 +563,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
561563 }
562564 }
563565
564- pub fn report_no_match_method_error (
566+ fn report_no_match_method_error (
565567 & self ,
566568 mut span : Span ,
567569 rcvr_ty : Ty < ' tcx > ,
@@ -573,7 +575,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
573575 no_match_data : & mut NoMatchData < ' tcx > ,
574576 expected : Expectation < ' tcx > ,
575577 trait_missing_method : bool ,
576- ) -> Result < Diag < ' _ > , ErrorGuaranteed > {
578+ ) -> ErrorGuaranteed {
577579 let mode = no_match_data. mode ;
578580 let tcx = self . tcx ;
579581 let rcvr_ty = self . resolve_vars_if_possible ( rcvr_ty) ;
@@ -605,23 +607,27 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
605607
606608 // We could pass the file for long types into these two, but it isn't strictly necessary
607609 // given how targeted they are.
608- self . suggest_wrapping_range_with_parens (
610+ if let Err ( guar ) = self . suggest_wrapping_range_with_parens (
609611 tcx,
610612 rcvr_ty,
611613 source,
612614 span,
613615 item_name,
614616 & short_ty_str,
615- ) ?;
616- self . suggest_constraining_numerical_ty (
617+ ) {
618+ return guar;
619+ }
620+ if let Err ( guar) = self . suggest_constraining_numerical_ty (
617621 tcx,
618622 rcvr_ty,
619623 source,
620624 span,
621625 item_kind,
622626 item_name,
623627 & short_ty_str,
624- ) ?;
628+ ) {
629+ return guar;
630+ }
625631 span = item_name. span ;
626632
627633 // Don't show generic arguments when the method can't be found in any implementation (#81576).
@@ -877,7 +883,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
877883 vec ! [ ( span. shrink_to_lo( ) , format!( "into_iter()." ) ) ] ,
878884 Applicability :: MaybeIncorrect ,
879885 ) ;
880- return Ok ( err) ;
886+ return err. emit ( ) ;
881887 } else if !unsatisfied_predicates. is_empty ( ) && matches ! ( rcvr_ty. kind( ) , ty:: Param ( _) ) {
882888 // We special case the situation where we are looking for `_` in
883889 // `<TypeParam as _>::method` because otherwise the machinery will look for blanket
@@ -1602,7 +1608,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
16021608 }
16031609
16041610 self . note_derefed_ty_has_method ( & mut err, source, rcvr_ty, item_name, expected) ;
1605- Ok ( err)
1611+ err. emit ( )
16061612 }
16071613
16081614 /// If an appropriate error source is not found, check method chain for possible candidates
0 commit comments