@@ -12,6 +12,8 @@ use crate::ProgramClause;
1212use crate :: ProgramClauseData ;
1313use crate :: ProgramClauseImplication ;
1414use crate :: ProgramClauses ;
15+ use crate :: QuantifiedWhereClause ;
16+ use crate :: QuantifiedWhereClauses ;
1517use crate :: SeparatorTraitRef ;
1618use crate :: StructId ;
1719use crate :: Substitution ;
@@ -113,6 +115,14 @@ pub trait Interner: Debug + Copy + Eq + Ord + Hash {
113115 /// converted back to its underlying data via `program_clause_data`.
114116 type InternedProgramClause : Debug + Clone + Eq + Hash ;
115117
118+ /// "Interned" representation of a list of quantified where clauses.
119+ /// In normal user code, `Self::InternedQuantifiedWhereClauses` is not referenced.
120+ /// Instead, we refer to `QuantifiedWhereClauses<Self>`, which wraps this type.
121+ ///
122+ /// An `InternedQuantifiedWhereClauses` is created by `intern_quantified_where_clauses`
123+ /// and can be converted back to its underlying data via `quantified_where_clauses_data`.
124+ type InternedQuantifiedWhereClauses : Debug + Clone + Eq + Hash ;
125+
116126 /// The core "id" type used for struct-ids and the like.
117127 type DefId : Debug + Copy + Eq + Ord + Hash ;
118128
@@ -328,6 +338,21 @@ pub trait Interner: Debug + Copy + Eq + Ord + Hash {
328338 None
329339 }
330340
341+ /// Prints the debug representation of a QuantifiedWhereClauses. To get good
342+ /// results, this requires inspecting TLS, and is difficult to
343+ /// code without reference to a specific interner (and hence
344+ /// fully known types).
345+ ///
346+ /// Returns `None` to fallback to the default debug output (e.g.,
347+ /// if no info about current program is available from TLS).
348+ #[ allow( unused_variables) ]
349+ fn debug_quantified_where_clauses (
350+ clauses : & QuantifiedWhereClauses < Self > ,
351+ fmt : & mut fmt:: Formatter < ' _ > ,
352+ ) -> Option < fmt:: Result > {
353+ None
354+ }
355+
331356 /// Create an "interned" type from `ty`. This is not normally
332357 /// invoked directly; instead, you invoke `TyData::intern` (which
333358 /// will ultimately call this method).
@@ -413,6 +438,22 @@ pub trait Interner: Debug + Copy + Eq + Ord + Hash {
413438 & self ,
414439 clauses : & ' a Self :: InternedProgramClauses ,
415440 ) -> & ' a [ ProgramClause < Self > ] ;
441+
442+ /// Create an "interned" quantified where clauses from `data`. This is not
443+ /// normally invoked directly; instead, you invoke
444+ /// `QuantifiedWhereClauses::from` (which will ultimately call this
445+ /// method).
446+ fn intern_quantified_where_clauses (
447+ & self ,
448+ data : impl IntoIterator < Item = QuantifiedWhereClause < Self > > ,
449+ ) -> Self :: InternedQuantifiedWhereClauses ;
450+
451+ /// Lookup the slice of `QuantifiedWhereClause` that was interned to
452+ /// create a `QuantifiedWhereClauses`.
453+ fn quantified_where_clauses_data < ' a > (
454+ & self ,
455+ clauses : & ' a Self :: InternedQuantifiedWhereClauses ,
456+ ) -> & ' a [ QuantifiedWhereClause < Self > ] ;
416457}
417458
418459pub trait TargetInterner < I : Interner > : Interner {
@@ -469,6 +510,7 @@ mod default {
469510 type InternedSubstitution = Vec < Parameter < ChalkIr > > ;
470511 type InternedProgramClause = ProgramClauseData < ChalkIr > ;
471512 type InternedProgramClauses = Vec < ProgramClause < ChalkIr > > ;
513+ type InternedQuantifiedWhereClauses = Vec < QuantifiedWhereClause < ChalkIr > > ;
472514 type DefId = RawId ;
473515 type Identifier = Identifier ;
474516
@@ -574,6 +616,15 @@ mod default {
574616 } )
575617 }
576618
619+ fn debug_quantified_where_clauses (
620+ clauses : & QuantifiedWhereClauses < Self > ,
621+ fmt : & mut fmt:: Formatter < ' _ > ,
622+ ) -> Option < fmt:: Result > {
623+ tls:: with_current_program ( |prog| {
624+ Some ( prog?. debug_quantified_where_clauses ( clauses, fmt) )
625+ } )
626+ }
627+
577628 fn intern_ty ( & self , ty : TyData < ChalkIr > ) -> Arc < TyData < ChalkIr > > {
578629 Arc :: new ( ty)
579630 }
@@ -661,6 +712,20 @@ mod default {
661712 ) -> & ' a [ ProgramClause < Self > ] {
662713 clauses
663714 }
715+
716+ fn intern_quantified_where_clauses (
717+ & self ,
718+ data : impl IntoIterator < Item = QuantifiedWhereClause < Self > > ,
719+ ) -> Self :: InternedQuantifiedWhereClauses {
720+ data. into_iter ( ) . collect ( )
721+ }
722+
723+ fn quantified_where_clauses_data < ' a > (
724+ & self ,
725+ clauses : & ' a Self :: InternedQuantifiedWhereClauses ,
726+ ) -> & ' a [ QuantifiedWhereClause < Self > ] {
727+ clauses
728+ }
664729 }
665730
666731 impl HasInterner for ChalkIr {
0 commit comments