@@ -1421,7 +1421,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
14211421 return ;
14221422 }
14231423 } ;
1424- let ( sig , map) = tcx. instantiate_bound_regions ( sig, |br| {
1424+ let ( unnormalized_sig , map) = tcx. instantiate_bound_regions ( sig, |br| {
14251425 use crate :: renumber:: RegionCtxt ;
14261426
14271427 let region_ctxt_fn = || {
@@ -1443,7 +1443,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
14431443 region_ctxt_fn,
14441444 )
14451445 } ) ;
1446- debug ! ( ?sig ) ;
1446+ debug ! ( ?unnormalized_sig ) ;
14471447 // IMPORTANT: We have to prove well formed for the function signature before
14481448 // we normalize it, as otherwise types like `<&'a &'b () as Trait>::Assoc`
14491449 // get normalized away, causing us to ignore the `'b: 'a` bound used by the function.
@@ -1453,15 +1453,31 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
14531453 //
14541454 // See #91068 for an example.
14551455 self . prove_predicates (
1456- sig . inputs_and_output . iter ( ) . map ( |ty| {
1456+ unnormalized_sig . inputs_and_output . iter ( ) . map ( |ty| {
14571457 ty:: Binder :: dummy ( ty:: PredicateKind :: Clause ( ty:: ClauseKind :: WellFormed (
14581458 ty. into ( ) ,
14591459 ) ) )
14601460 } ) ,
14611461 term_location. to_locations ( ) ,
14621462 ConstraintCategory :: Boring ,
14631463 ) ;
1464- let sig = self . normalize ( sig, term_location) ;
1464+
1465+ let sig = self . normalize ( unnormalized_sig, term_location) ;
1466+ // HACK(#114936): `WF(sig)` does not imply `WF(normalized(sig))`
1467+ // with built-in `Fn` implementations, since the impl may not be
1468+ // well-formed itself.
1469+ if sig != unnormalized_sig {
1470+ self . prove_predicates (
1471+ sig. inputs_and_output . iter ( ) . map ( |ty| {
1472+ ty:: Binder :: dummy ( ty:: PredicateKind :: Clause (
1473+ ty:: ClauseKind :: WellFormed ( ty. into ( ) ) ,
1474+ ) )
1475+ } ) ,
1476+ term_location. to_locations ( ) ,
1477+ ConstraintCategory :: Boring ,
1478+ ) ;
1479+ }
1480+
14651481 self . check_call_dest ( body, term, & sig, * destination, * target, term_location) ;
14661482
14671483 // The ordinary liveness rules will ensure that all
0 commit comments