@@ -364,7 +364,7 @@ fn typeck_with_fallback<'tcx>(
364
364
365
365
let typeck_results = Inherited :: build ( tcx, def_id) . enter ( |inh| {
366
366
let param_env = tcx. param_env ( def_id) ;
367
- let fcx = if let Some ( hir:: FnSig { header, decl, .. } ) = fn_sig {
367
+ let ( fcx, wf_tys ) = if let Some ( hir:: FnSig { header, decl, .. } ) = fn_sig {
368
368
let fn_sig = if crate :: collect:: get_infer_ret_ty ( & decl. output ) . is_some ( ) {
369
369
let fcx = FnCtxt :: new ( & inh, param_env, body. value . hir_id ) ;
370
370
<dyn AstConv < ' _ > >:: ty_of_fn (
@@ -383,17 +383,25 @@ fn typeck_with_fallback<'tcx>(
383
383
384
384
check_abi ( tcx, id, span, fn_sig. abi ( ) ) ;
385
385
386
+ // When normalizing the function signature, we assume all types are
387
+ // well-formed. So, we don't need to worry about the obligations
388
+ // from normalization. We could just discard these, but to align with
389
+ // compare_method and elsewhere, we just add implied bounds for
390
+ // these types.
391
+ let mut wf_tys = vec ! [ ] ;
386
392
// Compute the fty from point of view of inside the fn.
387
393
let fn_sig = tcx. liberate_late_bound_regions ( def_id. to_def_id ( ) , fn_sig) ;
394
+ wf_tys. extend ( fn_sig. inputs_and_output . iter ( ) ) ;
388
395
let fn_sig = inh. normalize_associated_types_in (
389
396
body. value . span ,
390
397
body_id. hir_id ,
391
398
param_env,
392
399
fn_sig,
393
400
) ;
401
+ wf_tys. extend ( fn_sig. inputs_and_output . iter ( ) ) ;
394
402
395
403
let fcx = check_fn ( & inh, param_env, fn_sig, decl, id, body, None , true ) . 0 ;
396
- fcx
404
+ ( fcx, wf_tys )
397
405
} else {
398
406
let fcx = FnCtxt :: new ( & inh, param_env, body. value . hir_id ) ;
399
407
let expected_type = body_ty
@@ -443,7 +451,7 @@ fn typeck_with_fallback<'tcx>(
443
451
444
452
fcx. write_ty ( id, expected_type) ;
445
453
446
- fcx
454
+ ( fcx, vec ! [ ] )
447
455
} ;
448
456
449
457
let fallback_has_occurred = fcx. type_inference_fallback ( ) ;
@@ -467,7 +475,7 @@ fn typeck_with_fallback<'tcx>(
467
475
fcx. select_all_obligations_or_error ( ) ;
468
476
469
477
if fn_sig. is_some ( ) {
470
- fcx. regionck_fn ( id, body) ;
478
+ fcx. regionck_fn ( id, body, span , & wf_tys ) ;
471
479
} else {
472
480
fcx. regionck_expr ( body) ;
473
481
}
0 commit comments