@@ -1421,7 +1421,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
1421
1421
return ;
1422
1422
}
1423
1423
} ;
1424
- let ( sig , map) = tcx. instantiate_bound_regions ( sig, |br| {
1424
+ let ( unnormalized_sig , map) = tcx. instantiate_bound_regions ( sig, |br| {
1425
1425
use crate :: renumber:: RegionCtxt ;
1426
1426
1427
1427
let region_ctxt_fn = || {
@@ -1443,7 +1443,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
1443
1443
region_ctxt_fn,
1444
1444
)
1445
1445
} ) ;
1446
- debug ! ( ?sig ) ;
1446
+ debug ! ( ?unnormalized_sig ) ;
1447
1447
// IMPORTANT: We have to prove well formed for the function signature before
1448
1448
// we normalize it, as otherwise types like `<&'a &'b () as Trait>::Assoc`
1449
1449
// 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> {
1453
1453
//
1454
1454
// See #91068 for an example.
1455
1455
self . prove_predicates (
1456
- sig . inputs_and_output . iter ( ) . map ( |ty| {
1456
+ unnormalized_sig . inputs_and_output . iter ( ) . map ( |ty| {
1457
1457
ty:: Binder :: dummy ( ty:: PredicateKind :: Clause ( ty:: ClauseKind :: WellFormed (
1458
1458
ty. into ( ) ,
1459
1459
) ) )
1460
1460
} ) ,
1461
1461
term_location. to_locations ( ) ,
1462
1462
ConstraintCategory :: Boring ,
1463
1463
) ;
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
+
1465
1481
self . check_call_dest ( body, term, & sig, * destination, * target, term_location) ;
1466
1482
1467
1483
// The ordinary liveness rules will ensure that all
0 commit comments