@@ -25,6 +25,7 @@ type OpaqueTyIds = BTreeMap<Ident, chalk_ir::OpaqueTyId<ChalkIr>>;
2525type AdtKinds = BTreeMap < chalk_ir:: AdtId < ChalkIr > , TypeKind > ;
2626type FnDefKinds = BTreeMap < chalk_ir:: FnDefId < ChalkIr > , TypeKind > ;
2727type TraitKinds = BTreeMap < chalk_ir:: TraitId < ChalkIr > , TypeKind > ;
28+ type OpaqueTyKinds = BTreeMap < chalk_ir:: OpaqueTyId < ChalkIr > , TypeKind > ;
2829type AssociatedTyLookups = BTreeMap < ( chalk_ir:: TraitId < ChalkIr > , Ident ) , AssociatedTyLookup > ;
2930type AssociatedTyValueIds =
3031 BTreeMap < ( chalk_ir:: ImplId < ChalkIr > , Ident ) , AssociatedTyValueId < ChalkIr > > ;
@@ -42,6 +43,7 @@ struct Env<'k> {
4243 trait_ids : & ' k TraitIds ,
4344 trait_kinds : & ' k TraitKinds ,
4445 opaque_ty_ids : & ' k OpaqueTyIds ,
46+ opaque_ty_kinds : & ' k OpaqueTyKinds ,
4547 associated_ty_lookups : & ' k AssociatedTyLookups ,
4648 /// GenericArg identifiers are used as keys, therefore
4749 /// all identifiers in an environment must be unique (no shadowing).
@@ -76,6 +78,7 @@ struct AssociatedTyLookup {
7678enum ApplyTypeLookup {
7779 Adt ( AdtId < ChalkIr > ) ,
7880 FnDef ( FnDefId < ChalkIr > ) ,
81+ Opaque ( OpaqueTyId < ChalkIr > ) ,
7982}
8083
8184const SELF : & str = "Self" ;
@@ -158,10 +161,6 @@ impl<'k> Env<'k> {
158161 return Err ( RustIrError :: CannotApplyTypeParameter ( name. clone ( ) ) ) ;
159162 }
160163
161- if let Some ( _) = self . opaque_ty_ids . get ( & name. str ) {
162- return Err ( RustIrError :: CannotApplyTypeParameter ( name. clone ( ) ) ) ;
163- }
164-
165164 if let Some ( id) = self . adt_ids . get ( & name. str ) {
166165 return Ok ( ApplyTypeLookup :: Adt ( * id) ) ;
167166 }
@@ -170,6 +169,10 @@ impl<'k> Env<'k> {
170169 return Ok ( ApplyTypeLookup :: FnDef ( * id) ) ;
171170 }
172171
172+ if let Some ( id) = self . opaque_ty_ids . get ( & name. str ) {
173+ return Ok ( ApplyTypeLookup :: Opaque ( * id) ) ;
174+ }
175+
173176 Err ( RustIrError :: NotStruct ( name. clone ( ) ) )
174177 }
175178
@@ -201,6 +204,10 @@ impl<'k> Env<'k> {
201204 & self . fn_def_kinds [ & id]
202205 }
203206
207+ fn opaque_kind ( & self , id : chalk_ir:: OpaqueTyId < ChalkIr > ) -> & TypeKind {
208+ & self . opaque_ty_kinds [ & id]
209+ }
210+
204211 /// Introduces new parameters, shifting the indices of existing
205212 /// parameters to accommodate them. The indices of the new binders
206213 /// will be assigned in order as they are iterated.
@@ -369,6 +376,7 @@ impl LowerProgram for Program {
369376 trait_ids : & trait_ids,
370377 trait_kinds : & trait_kinds,
371378 opaque_ty_ids : & opaque_ty_ids,
379+ opaque_ty_kinds : & opaque_ty_kinds,
372380 associated_ty_lookups : & associated_ty_lookups,
373381 parameter_map : BTreeMap :: new ( ) ,
374382 } ;
@@ -1311,6 +1319,9 @@ impl LowerTy for Ty {
13111319 ApplyTypeLookup :: FnDef ( id) => {
13121320 ( chalk_ir:: TypeName :: FnDef ( id) , env. fn_def_kind ( id) )
13131321 }
1322+ ApplyTypeLookup :: Opaque ( id) => {
1323+ ( chalk_ir:: TypeName :: OpaqueType ( id) , env. opaque_kind ( id) )
1324+ }
13141325 } ;
13151326
13161327 if k. binders . len ( interner) != args. len ( ) {
@@ -1658,6 +1669,7 @@ impl LowerGoal<LoweredProgram> for Goal {
16581669 adt_kinds : & program. adt_kinds ,
16591670 fn_def_kinds : & program. fn_def_kinds ,
16601671 trait_kinds : & program. trait_kinds ,
1672+ opaque_ty_kinds : & program. opaque_ty_kinds ,
16611673 associated_ty_lookups : & associated_ty_lookups,
16621674 parameter_map : BTreeMap :: new ( ) ,
16631675 } ;
0 commit comments