@@ -343,6 +343,24 @@ fn wf_clause_for_ref<'tcx>(
343
343
tcx. mk_clauses ( iter:: once ( wf_clause) )
344
344
}
345
345
346
+ fn wf_clause_for_fn_def < ' tcx > (
347
+ tcx : ty:: TyCtxt < ' _ , ' _ , ' tcx > ,
348
+ def_id : DefId
349
+ ) -> Clauses < ' tcx > {
350
+ let fn_def = generic_types:: fn_def ( tcx, def_id) ;
351
+
352
+ let wf_clause = ProgramClause {
353
+ goal : DomainGoal :: WellFormed ( WellFormed :: Ty ( fn_def) ) ,
354
+ hypotheses : ty:: List :: empty ( ) ,
355
+ category : ProgramClauseCategory :: WellFormed ,
356
+ } ;
357
+ let wf_clause = Clause :: ForAll ( ty:: Binder :: bind ( wf_clause) ) ;
358
+
359
+ // `forall <T1, ..., Tn+1> { WellFormed(fn some_fn(T1, ..., Tn) -> Tn+1). }`
360
+ // where `def_id` maps to the `some_fn` function definition
361
+ tcx. mk_clauses ( iter:: once ( wf_clause) )
362
+ }
363
+
346
364
impl ChalkInferenceContext < ' cx , ' gcx , ' tcx > {
347
365
pub ( super ) fn program_clauses_impl (
348
366
& self ,
@@ -506,6 +524,8 @@ impl ChalkInferenceContext<'cx, 'gcx, 'tcx> {
506
524
// WF if `sub_ty` outlives `region`.
507
525
ty:: Ref ( _, _, mutbl) => wf_clause_for_ref ( self . infcx . tcx , mutbl) ,
508
526
527
+ ty:: FnDef ( def_id, ..) => wf_clause_for_fn_def ( self . infcx . tcx , def_id) ,
528
+
509
529
ty:: Dynamic ( ..) => {
510
530
// FIXME: no rules yet for trait objects
511
531
ty:: List :: empty ( )
@@ -515,8 +535,8 @@ impl ChalkInferenceContext<'cx, 'gcx, 'tcx> {
515
535
self . infcx . tcx . program_clauses_for ( def. did )
516
536
}
517
537
538
+ // FIXME: these are probably wrong
518
539
ty:: Foreign ( def_id) |
519
- ty:: FnDef ( def_id, ..) |
520
540
ty:: Closure ( def_id, ..) |
521
541
ty:: Generator ( def_id, ..) |
522
542
ty:: Opaque ( def_id, ..) => {
0 commit comments