@@ -10,6 +10,7 @@ use crate::OpaqueTy;
10
10
use crate :: OpaqueTyId ;
11
11
use crate :: Parameter ;
12
12
use crate :: ParameterData ;
13
+ use crate :: ParameterKind ;
13
14
use crate :: ProgramClause ;
14
15
use crate :: ProgramClauseData ;
15
16
use crate :: ProgramClauseImplication ;
@@ -23,6 +24,7 @@ use crate::Substitution;
23
24
use crate :: TraitId ;
24
25
use crate :: Ty ;
25
26
use crate :: TyData ;
27
+ use crate :: UniverseIndex ;
26
28
use chalk_engine:: context:: Context ;
27
29
use chalk_engine:: ExClause ;
28
30
use std:: fmt:: { self , Debug } ;
@@ -126,6 +128,23 @@ pub trait Interner: Debug + Copy + Eq + Ord + Hash {
126
128
/// and can be converted back to its underlying data via `quantified_where_clauses_data`.
127
129
type InternedQuantifiedWhereClauses : Debug + Clone + Eq + Hash ;
128
130
131
+ /// "Interned" representation of a list of parameter kind.
132
+ /// In normal user code, `Self::InternedParameterKinds` is not referenced.
133
+ /// Instead, we refer to `ParameterKinds<Self>`, which wraps this type.
134
+ ///
135
+ /// An `InternedParameterKinds` is created by `intern_parameter_kinds`
136
+ /// and can be converted back to its underlying data via `parameter_kinds_data`.
137
+ type InternedParameterKinds : Debug + Clone + Eq + Hash ;
138
+
139
+ /// "Interned" representation of a list of parameter kind with universe index.
140
+ /// In normal user code, `Self::InternedParameterKindsWithUniverseIndex` is not referenced.
141
+ /// Instead, we refer to `ParameterKindsWithUniverseIndex<Self>`, which wraps this type.
142
+ ///
143
+ /// An `InternedParameterKindsWithUniverseIndex` is created by
144
+ /// `intern_parameter_kinds_with_universe_index` and can be converted back
145
+ /// to its underlying data via `parameter_kinds_with_universe_index_data`.
146
+ type InternedParameterKindsWithUniverseIndex : Debug + Clone + Eq + Hash ;
147
+
129
148
/// The core "id" type used for struct-ids and the like.
130
149
type DefId : Debug + Copy + Eq + Ord + Hash ;
131
150
@@ -493,6 +512,38 @@ pub trait Interner: Debug + Copy + Eq + Ord + Hash {
493
512
& self ,
494
513
clauses : & ' a Self :: InternedQuantifiedWhereClauses ,
495
514
) -> & ' a [ QuantifiedWhereClause < Self > ] ;
515
+
516
+ /// Create an "interned" parameter kinds from `data`. This is not
517
+ /// normally invoked directly; instead, you invoke
518
+ /// `ParameterKinds::from` (which will ultimately call this
519
+ /// method).
520
+ fn intern_parameter_kinds (
521
+ & self ,
522
+ data : impl IntoIterator < Item = ParameterKind < ( ) > > ,
523
+ ) -> Self :: InternedParameterKinds ;
524
+
525
+ /// Lookup the slice of `ParameterKind` that was interned to
526
+ /// create a `ParameterKinds`.
527
+ fn parameter_kinds_data < ' a > (
528
+ & self ,
529
+ parameter_kinds : & ' a Self :: InternedParameterKinds ,
530
+ ) -> & ' a [ ParameterKind < ( ) > ] ;
531
+
532
+ /// Create an "interned" parameter kinds with universe index from `data`. This is not
533
+ /// normally invoked directly; instead, you invoke
534
+ /// `ParameterKindsWithUniverseIndex::from` (which will ultimately call this
535
+ /// method).
536
+ fn intern_parameter_kinds_with_universe_index (
537
+ & self ,
538
+ data : impl IntoIterator < Item = ParameterKind < UniverseIndex > > ,
539
+ ) -> Self :: InternedParameterKindsWithUniverseIndex ;
540
+
541
+ /// Lookup the slice of `ParameterKind` that was interned to
542
+ /// create a `ParameterKinds`.
543
+ fn parameter_kinds_with_universe_index_data < ' a > (
544
+ & self ,
545
+ parameter_kinds_with_universe_index : & ' a Self :: InternedParameterKindsWithUniverseIndex ,
546
+ ) -> & ' a [ ParameterKind < UniverseIndex > ] ;
496
547
}
497
548
498
549
pub trait TargetInterner < I : Interner > : Interner {
@@ -550,6 +601,8 @@ mod default {
550
601
type InternedProgramClause = ProgramClauseData < ChalkIr > ;
551
602
type InternedProgramClauses = Vec < ProgramClause < ChalkIr > > ;
552
603
type InternedQuantifiedWhereClauses = Vec < QuantifiedWhereClause < ChalkIr > > ;
604
+ type InternedParameterKinds = Vec < ParameterKind < ( ) > > ;
605
+ type InternedParameterKindsWithUniverseIndex = Vec < ParameterKind < UniverseIndex > > ;
553
606
type DefId = RawId ;
554
607
type Identifier = Identifier ;
555
608
@@ -786,6 +839,30 @@ mod default {
786
839
) -> & ' a [ QuantifiedWhereClause < Self > ] {
787
840
clauses
788
841
}
842
+ fn intern_parameter_kinds (
843
+ & self ,
844
+ data : impl IntoIterator < Item = ParameterKind < ( ) > > ,
845
+ ) -> Self :: InternedParameterKinds {
846
+ data. into_iter ( ) . collect ( )
847
+ }
848
+ fn parameter_kinds_data < ' a > (
849
+ & self ,
850
+ parameter_kinds : & ' a Self :: InternedParameterKinds ,
851
+ ) -> & ' a [ ParameterKind < ( ) > ] {
852
+ parameter_kinds
853
+ }
854
+ fn intern_parameter_kinds_with_universe_index (
855
+ & self ,
856
+ data : impl IntoIterator < Item = ParameterKind < UniverseIndex > > ,
857
+ ) -> Self :: InternedParameterKindsWithUniverseIndex {
858
+ data. into_iter ( ) . collect ( )
859
+ }
860
+ fn parameter_kinds_with_universe_index_data < ' a > (
861
+ & self ,
862
+ parameter_kinds_with_universe_index : & ' a Self :: InternedParameterKindsWithUniverseIndex ,
863
+ ) -> & ' a [ ParameterKind < UniverseIndex > ] {
864
+ parameter_kinds_with_universe_index
865
+ }
789
866
}
790
867
791
868
impl HasInterner for ChalkIr {
0 commit comments