@@ -343,6 +343,24 @@ fn wf_clause_for_ref<'tcx>(
343343 tcx. mk_clauses ( iter:: once ( wf_clause) )
344344}
345345
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+
346364impl ChalkInferenceContext < ' cx , ' gcx , ' tcx > {
347365 pub ( super ) fn program_clauses_impl (
348366 & self ,
@@ -506,6 +524,8 @@ impl ChalkInferenceContext<'cx, 'gcx, 'tcx> {
506524 // WF if `sub_ty` outlives `region`.
507525 ty:: Ref ( _, _, mutbl) => wf_clause_for_ref ( self . infcx . tcx , mutbl) ,
508526
527+ ty:: FnDef ( def_id, ..) => wf_clause_for_fn_def ( self . infcx . tcx , def_id) ,
528+
509529 ty:: Dynamic ( ..) => {
510530 // FIXME: no rules yet for trait objects
511531 ty:: List :: empty ( )
@@ -515,8 +535,8 @@ impl ChalkInferenceContext<'cx, 'gcx, 'tcx> {
515535 self . infcx . tcx . program_clauses_for ( def. did )
516536 }
517537
538+ // FIXME: these are probably wrong
518539 ty:: Foreign ( def_id) |
519- ty:: FnDef ( def_id, ..) |
520540 ty:: Closure ( def_id, ..) |
521541 ty:: Generator ( def_id, ..) |
522542 ty:: Opaque ( def_id, ..) => {
0 commit comments