@@ -25,6 +25,7 @@ type OpaqueTyIds = BTreeMap<Ident, chalk_ir::OpaqueTyId<ChalkIr>>;
25
25
type AdtKinds = BTreeMap < chalk_ir:: AdtId < ChalkIr > , TypeKind > ;
26
26
type FnDefKinds = BTreeMap < chalk_ir:: FnDefId < ChalkIr > , TypeKind > ;
27
27
type TraitKinds = BTreeMap < chalk_ir:: TraitId < ChalkIr > , TypeKind > ;
28
+ type OpaqueTyKinds = BTreeMap < chalk_ir:: OpaqueTyId < ChalkIr > , TypeKind > ;
28
29
type AssociatedTyLookups = BTreeMap < ( chalk_ir:: TraitId < ChalkIr > , Ident ) , AssociatedTyLookup > ;
29
30
type AssociatedTyValueIds =
30
31
BTreeMap < ( chalk_ir:: ImplId < ChalkIr > , Ident ) , AssociatedTyValueId < ChalkIr > > ;
@@ -42,6 +43,7 @@ struct Env<'k> {
42
43
trait_ids : & ' k TraitIds ,
43
44
trait_kinds : & ' k TraitKinds ,
44
45
opaque_ty_ids : & ' k OpaqueTyIds ,
46
+ opaque_ty_kinds : & ' k OpaqueTyKinds ,
45
47
associated_ty_lookups : & ' k AssociatedTyLookups ,
46
48
/// GenericArg identifiers are used as keys, therefore
47
49
/// all identifiers in an environment must be unique (no shadowing).
@@ -76,6 +78,7 @@ struct AssociatedTyLookup {
76
78
enum ApplyTypeLookup {
77
79
Adt ( AdtId < ChalkIr > ) ,
78
80
FnDef ( FnDefId < ChalkIr > ) ,
81
+ Opaque ( OpaqueTyId < ChalkIr > ) ,
79
82
}
80
83
81
84
const SELF : & str = "Self" ;
@@ -158,10 +161,6 @@ impl<'k> Env<'k> {
158
161
return Err ( RustIrError :: CannotApplyTypeParameter ( name. clone ( ) ) ) ;
159
162
}
160
163
161
- if let Some ( _) = self . opaque_ty_ids . get ( & name. str ) {
162
- return Err ( RustIrError :: CannotApplyTypeParameter ( name. clone ( ) ) ) ;
163
- }
164
-
165
164
if let Some ( id) = self . adt_ids . get ( & name. str ) {
166
165
return Ok ( ApplyTypeLookup :: Adt ( * id) ) ;
167
166
}
@@ -170,6 +169,10 @@ impl<'k> Env<'k> {
170
169
return Ok ( ApplyTypeLookup :: FnDef ( * id) ) ;
171
170
}
172
171
172
+ if let Some ( id) = self . opaque_ty_ids . get ( & name. str ) {
173
+ return Ok ( ApplyTypeLookup :: Opaque ( * id) ) ;
174
+ }
175
+
173
176
Err ( RustIrError :: NotStruct ( name. clone ( ) ) )
174
177
}
175
178
@@ -201,6 +204,10 @@ impl<'k> Env<'k> {
201
204
& self . fn_def_kinds [ & id]
202
205
}
203
206
207
+ fn opaque_kind ( & self , id : chalk_ir:: OpaqueTyId < ChalkIr > ) -> & TypeKind {
208
+ & self . opaque_ty_kinds [ & id]
209
+ }
210
+
204
211
/// Introduces new parameters, shifting the indices of existing
205
212
/// parameters to accommodate them. The indices of the new binders
206
213
/// will be assigned in order as they are iterated.
@@ -369,6 +376,7 @@ impl LowerProgram for Program {
369
376
trait_ids : & trait_ids,
370
377
trait_kinds : & trait_kinds,
371
378
opaque_ty_ids : & opaque_ty_ids,
379
+ opaque_ty_kinds : & opaque_ty_kinds,
372
380
associated_ty_lookups : & associated_ty_lookups,
373
381
parameter_map : BTreeMap :: new ( ) ,
374
382
} ;
@@ -1311,6 +1319,9 @@ impl LowerTy for Ty {
1311
1319
ApplyTypeLookup :: FnDef ( id) => {
1312
1320
( chalk_ir:: TypeName :: FnDef ( id) , env. fn_def_kind ( id) )
1313
1321
}
1322
+ ApplyTypeLookup :: Opaque ( id) => {
1323
+ ( chalk_ir:: TypeName :: OpaqueType ( id) , env. opaque_kind ( id) )
1324
+ }
1314
1325
} ;
1315
1326
1316
1327
if k. binders . len ( interner) != args. len ( ) {
@@ -1658,6 +1669,7 @@ impl LowerGoal<LoweredProgram> for Goal {
1658
1669
adt_kinds : & program. adt_kinds ,
1659
1670
fn_def_kinds : & program. fn_def_kinds ,
1660
1671
trait_kinds : & program. trait_kinds ,
1672
+ opaque_ty_kinds : & program. opaque_ty_kinds ,
1661
1673
associated_ty_lookups : & associated_ty_lookups,
1662
1674
parameter_map : BTreeMap :: new ( ) ,
1663
1675
} ;
0 commit comments