@@ -84,6 +84,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
8484
8585 self . annotate_expected_due_to_let_ty ( err, expr, error) ;
8686
87+ // FIXME(#73154): For now, we do leak check when coercing function
88+ // pointers in typeck, instead of only during borrowck. This can lead
89+ // to these `RegionsInsufficientlyPolymorphic` errors that aren't helpful.
90+ if matches ! ( error, Some ( TypeError :: RegionsInsufficientlyPolymorphic ( ..) ) ) {
91+ return ;
92+ }
93+
8794 if self . is_destruct_assignment_desugaring ( expr) {
8895 return ;
8996 }
@@ -263,22 +270,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
263270 let expr_ty = self . resolve_vars_with_obligations ( checked_ty) ;
264271 let mut err = self . err_ctxt ( ) . report_mismatched_types ( & cause, expected, expr_ty, e) ;
265272
266- let is_insufficiently_polymorphic =
267- matches ! ( e, TypeError :: RegionsInsufficientlyPolymorphic ( ..) ) ;
268-
269- // FIXME(#73154): For now, we do leak check when coercing function
270- // pointers in typeck, instead of only during borrowck. This can lead
271- // to these `RegionsInsufficientlyPolymorphic` errors that aren't helpful.
272- if !is_insufficiently_polymorphic {
273- self . emit_coerce_suggestions (
274- & mut err,
275- expr,
276- expr_ty,
277- expected,
278- expected_ty_expr,
279- Some ( e) ,
280- ) ;
281- }
273+ self . emit_coerce_suggestions ( & mut err, expr, expr_ty, expected, expected_ty_expr, Some ( e) ) ;
282274
283275 ( expected, Some ( err) )
284276 }
0 commit comments