@@ -84,6 +84,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
84
84
85
85
self . annotate_expected_due_to_let_ty ( err, expr, error) ;
86
86
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
+
87
94
if self . is_destruct_assignment_desugaring ( expr) {
88
95
return ;
89
96
}
@@ -263,22 +270,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
263
270
let expr_ty = self . resolve_vars_with_obligations ( checked_ty) ;
264
271
let mut err = self . err_ctxt ( ) . report_mismatched_types ( & cause, expected, expr_ty, e) ;
265
272
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) ) ;
282
274
283
275
( expected, Some ( err) )
284
276
}
0 commit comments