@@ -8,6 +8,8 @@ use crate::Lifetime;
88use crate :: LifetimeData ;
99use crate :: Parameter ;
1010use crate :: ParameterData ;
11+ use crate :: ProgramClause ;
12+ use crate :: ProgramClauseData ;
1113use crate :: ProgramClauseImplication ;
1214use crate :: SeparatorTraitRef ;
1315use crate :: StructId ;
@@ -94,6 +96,14 @@ pub trait Interner: Debug + Copy + Eq + Ord + Hash {
9496 /// converted back to its underlying data via `substitution_data`.
9597 type InternedSubstitution : Debug + Clone + Eq + Hash ;
9698
99+ /// "Interned" representation of a "program clause". In normal user code,
100+ /// `Self::InternedProgramClause` is not referenced. Instead, we refer to
101+ /// `ProgramClause<Self>`, which wraps this type.
102+ ///
103+ /// An `InternedProgramClause` is created by `intern_program_clause` and can be
104+ /// converted back to its underlying data via `program_clause_data`.
105+ type InternedProgramClause : Debug + Clone + Eq + Hash ;
106+
97107 /// The core "id" type used for struct-ids and the like.
98108 type DefId : Debug + Copy + Eq + Ord + Hash ;
99109
@@ -234,6 +244,21 @@ pub trait Interner: Debug + Copy + Eq + Ord + Hash {
234244 None
235245 }
236246
247+ /// Prints the debug representation of a ProgramClause. To get good
248+ /// results, this requires inspecting TLS, and is difficult to
249+ /// code without reference to a specific interner (and hence
250+ /// fully known types).
251+ ///
252+ /// Returns `None` to fallback to the default debug output (e.g.,
253+ /// if no info about current program is available from TLS).
254+ #[ allow( unused_variables) ]
255+ fn debug_program_clause (
256+ clause : & ProgramClause < Self > ,
257+ fmt : & mut fmt:: Formatter < ' _ > ,
258+ ) -> Option < fmt:: Result > {
259+ None
260+ }
261+
237262 /// Prints the debug representation of an ApplicationTy. To get good
238263 /// results, this requires inspecting TLS, and is difficult to
239264 /// code without reference to a specific interner (and hence
@@ -337,6 +362,18 @@ pub trait Interner: Debug + Copy + Eq + Ord + Hash {
337362 & self ,
338363 substitution : & ' a Self :: InternedSubstitution ,
339364 ) -> & ' a [ Parameter < Self > ] ;
365+
366+ /// Create an "interned" program clause from `data`. This is not
367+ /// normally invoked directly; instead, you invoke
368+ /// `ProgramClauseData::intern` (which will ultimately call this
369+ /// method).
370+ fn intern_program_clause ( & self , data : ProgramClauseData < Self > ) -> Self :: InternedProgramClause ;
371+
372+ /// Lookup the `ProgramClauseData` that was interned to create a `ProgramClause`.
373+ fn program_clause_data < ' a > (
374+ & self ,
375+ clause : & ' a Self :: InternedProgramClause ,
376+ ) -> & ' a ProgramClauseData < Self > ;
340377}
341378
342379pub trait TargetInterner < I : Interner > : Interner {
@@ -391,6 +428,7 @@ mod default {
391428 type InternedGoal = Arc < GoalData < ChalkIr > > ;
392429 type InternedGoals = Vec < Goal < ChalkIr > > ;
393430 type InternedSubstitution = Vec < Parameter < ChalkIr > > ;
431+ type InternedProgramClause = ProgramClauseData < ChalkIr > ;
394432 type DefId = RawId ;
395433 type Identifier = Identifier ;
396434
@@ -459,6 +497,13 @@ mod default {
459497 tls:: with_current_program ( |prog| Some ( prog?. debug_program_clause_implication ( pci, fmt) ) )
460498 }
461499
500+ fn debug_program_clause (
501+ clause : & ProgramClause < ChalkIr > ,
502+ fmt : & mut fmt:: Formatter < ' _ > ,
503+ ) -> Option < fmt:: Result > {
504+ tls:: with_current_program ( |prog| Some ( prog?. debug_program_clause ( clause, fmt) ) )
505+ }
506+
462507 fn debug_application_ty (
463508 application_ty : & ApplicationTy < ChalkIr > ,
464509 fmt : & mut fmt:: Formatter < ' _ > ,
@@ -544,6 +589,20 @@ mod default {
544589 ) -> & ' a [ Parameter < ChalkIr > ] {
545590 substitution
546591 }
592+
593+ fn intern_program_clause (
594+ & self ,
595+ data : ProgramClauseData < Self > ,
596+ ) -> ProgramClauseData < Self > {
597+ data
598+ }
599+
600+ fn program_clause_data < ' a > (
601+ & self ,
602+ clause : & ' a ProgramClauseData < Self > ,
603+ ) -> & ' a ProgramClauseData < Self > {
604+ clause
605+ }
547606 }
548607
549608 impl HasInterner for ChalkIr {
0 commit comments