@@ -192,7 +192,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
192
192
error : MethodError < ' tcx > ,
193
193
expected : Expectation < ' tcx > ,
194
194
trait_missing_method : bool ,
195
- ) -> Result < Diag < ' _ > , ErrorGuaranteed > {
195
+ ) -> ErrorGuaranteed {
196
196
let ( span, sugg_span, source, item_name, args) = match self . tcx . hir_node ( call_id) {
197
197
hir:: Node :: Expr ( & hir:: Expr {
198
198
kind : hir:: ExprKind :: MethodCall ( segment, rcvr, args, _) ,
@@ -226,7 +226,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
226
226
} ;
227
227
228
228
// 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
+ }
230
232
231
233
match error {
232
234
MethodError :: NoMatch ( mut no_match_data) => {
@@ -263,7 +265,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
263
265
& mut sources,
264
266
Some ( sugg_span) ,
265
267
) ;
266
- return Err ( err. emit ( ) ) ;
268
+ return err. emit ( ) ;
267
269
}
268
270
269
271
MethodError :: PrivateMatch ( kind, def_id, out_of_scope_traits) => {
@@ -284,7 +286,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
284
286
. unwrap_or_else ( || self . tcx . def_span ( def_id) ) ;
285
287
err. span_label ( sp, format ! ( "private {kind} defined here" ) ) ;
286
288
self . suggest_valid_traits ( & mut err, item_name, out_of_scope_traits, true ) ;
287
- return Err ( err. emit ( ) ) ;
289
+ return err. emit ( ) ;
288
290
}
289
291
290
292
MethodError :: IllegalSizedBound { candidates, needs_mut, bound_span, self_expr } => {
@@ -341,7 +343,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
341
343
}
342
344
}
343
345
}
344
- return Err ( err. emit ( ) ) ;
346
+ return err. emit ( ) ;
345
347
}
346
348
347
349
MethodError :: BadReturnType => bug ! ( "no return type expectations but got BadReturnType" ) ,
@@ -561,7 +563,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
561
563
}
562
564
}
563
565
564
- pub fn report_no_match_method_error (
566
+ fn report_no_match_method_error (
565
567
& self ,
566
568
mut span : Span ,
567
569
rcvr_ty : Ty < ' tcx > ,
@@ -573,7 +575,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
573
575
no_match_data : & mut NoMatchData < ' tcx > ,
574
576
expected : Expectation < ' tcx > ,
575
577
trait_missing_method : bool ,
576
- ) -> Result < Diag < ' _ > , ErrorGuaranteed > {
578
+ ) -> ErrorGuaranteed {
577
579
let mode = no_match_data. mode ;
578
580
let tcx = self . tcx ;
579
581
let rcvr_ty = self . resolve_vars_if_possible ( rcvr_ty) ;
@@ -605,23 +607,27 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
605
607
606
608
// We could pass the file for long types into these two, but it isn't strictly necessary
607
609
// given how targeted they are.
608
- self . suggest_wrapping_range_with_parens (
610
+ if let Err ( guar ) = self . suggest_wrapping_range_with_parens (
609
611
tcx,
610
612
rcvr_ty,
611
613
source,
612
614
span,
613
615
item_name,
614
616
& 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 (
617
621
tcx,
618
622
rcvr_ty,
619
623
source,
620
624
span,
621
625
item_kind,
622
626
item_name,
623
627
& short_ty_str,
624
- ) ?;
628
+ ) {
629
+ return guar;
630
+ }
625
631
span = item_name. span ;
626
632
627
633
// 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> {
877
883
vec ! [ ( span. shrink_to_lo( ) , format!( "into_iter()." ) ) ] ,
878
884
Applicability :: MaybeIncorrect ,
879
885
) ;
880
- return Ok ( err) ;
886
+ return err. emit ( ) ;
881
887
} else if !unsatisfied_predicates. is_empty ( ) && matches ! ( rcvr_ty. kind( ) , ty:: Param ( _) ) {
882
888
// We special case the situation where we are looking for `_` in
883
889
// `<TypeParam as _>::method` because otherwise the machinery will look for blanket
@@ -1602,7 +1608,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1602
1608
}
1603
1609
1604
1610
self . note_derefed_ty_has_method ( & mut err, source, rcvr_ty, item_name, expected) ;
1605
- Ok ( err)
1611
+ err. emit ( )
1606
1612
}
1607
1613
1608
1614
/// If an appropriate error source is not found, check method chain for possible candidates
0 commit comments