@@ -2,8 +2,8 @@ use crate::interner::ChalkIr;
22use chalk_ir:: cast:: { Cast , Caster } ;
33use chalk_ir:: interner:: HasInterner ;
44use chalk_ir:: {
5- self , AssocTypeId , BoundVar , ClausePriority , DebruijnIndex , ImplId , OpaqueTyId ,
6- QuantifiedWhereClauses , StructId , Substitution , ToGenericArg , TraitId ,
5+ self , AdtId , AssocTypeId , BoundVar , ClausePriority , DebruijnIndex , ImplId , OpaqueTyId ,
6+ QuantifiedWhereClauses , Substitution , ToGenericArg , TraitId ,
77} ;
88use chalk_parse:: ast:: * ;
99use chalk_rust_ir as rust_ir;
@@ -18,10 +18,10 @@ use crate::error::RustIrError;
1818use crate :: program:: Program as LoweredProgram ;
1919use crate :: { Identifier as Ident , RawId , TypeKind , TypeSort } ;
2020
21- type StructIds = BTreeMap < Ident , chalk_ir:: StructId < ChalkIr > > ;
21+ type AdtIds = BTreeMap < Ident , chalk_ir:: AdtId < ChalkIr > > ;
2222type TraitIds = BTreeMap < Ident , chalk_ir:: TraitId < ChalkIr > > ;
2323type OpaqueTyIds = BTreeMap < Ident , chalk_ir:: OpaqueTyId < ChalkIr > > ;
24- type StructKinds = BTreeMap < chalk_ir:: StructId < ChalkIr > , TypeKind > ;
24+ type AdtKinds = BTreeMap < chalk_ir:: AdtId < ChalkIr > , TypeKind > ;
2525type TraitKinds = BTreeMap < chalk_ir:: TraitId < ChalkIr > , TypeKind > ;
2626type AssociatedTyLookups = BTreeMap < ( chalk_ir:: TraitId < ChalkIr > , Ident ) , AssociatedTyLookup > ;
2727type AssociatedTyValueIds =
@@ -34,8 +34,8 @@ pub type LowerResult<T> = Result<T, RustIrError>;
3434
3535#[ derive( Clone , Debug ) ]
3636struct Env < ' k > {
37- struct_ids : & ' k StructIds ,
38- struct_kinds : & ' k StructKinds ,
37+ adt_ids : & ' k AdtIds ,
38+ adt_kinds : & ' k AdtKinds ,
3939 trait_ids : & ' k TraitIds ,
4040 trait_kinds : & ' k TraitKinds ,
4141 opaque_ty_ids : & ' k OpaqueTyIds ,
@@ -71,7 +71,7 @@ struct AssociatedTyLookup {
7171}
7272
7373enum TypeLookup {
74- Struct ( chalk_ir:: StructId < ChalkIr > ) ,
74+ Adt ( chalk_ir:: AdtId < ChalkIr > ) ,
7575 GenericArg ( BoundVar ) ,
7676 Opaque ( chalk_ir:: OpaqueTyId < ChalkIr > ) ,
7777}
@@ -92,8 +92,8 @@ impl<'k> Env<'k> {
9292 return Ok ( TypeLookup :: GenericArg ( * k) ) ;
9393 }
9494
95- if let Some ( id) = self . struct_ids . get ( & name. str ) {
96- return Ok ( TypeLookup :: Struct ( * id) ) ;
95+ if let Some ( id) = self . adt_ids . get ( & name. str ) {
96+ return Ok ( TypeLookup :: Adt ( * id) ) ;
9797 }
9898
9999 if let Some ( id) = self . opaque_ty_ids . get ( & name. str ) {
@@ -114,7 +114,7 @@ impl<'k> Env<'k> {
114114 return Err ( RustIrError :: NotTrait ( name. clone ( ) ) ) ;
115115 }
116116
117- if let Some ( _) = self . struct_ids . get ( & name. str ) {
117+ if let Some ( _) = self . adt_ids . get ( & name. str ) {
118118 return Err ( RustIrError :: NotTrait ( name. clone ( ) ) ) ;
119119 }
120120
@@ -136,8 +136,8 @@ impl<'k> Env<'k> {
136136 Err ( RustIrError :: InvalidLifetimeName ( name. clone ( ) ) )
137137 }
138138
139- fn struct_kind ( & self , id : chalk_ir:: StructId < ChalkIr > ) -> & TypeKind {
140- & self . struct_kinds [ & id]
139+ fn adt_kind ( & self , id : chalk_ir:: AdtId < ChalkIr > ) -> & TypeKind {
140+ & self . adt_kinds [ & id]
141141 }
142142
143143 fn trait_kind ( & self , id : chalk_ir:: TraitId < ChalkIr > ) -> & TypeKind {
@@ -239,20 +239,20 @@ impl LowerProgram for Program {
239239 }
240240 }
241241
242- let mut struct_ids = BTreeMap :: new ( ) ;
242+ let mut adt_ids = BTreeMap :: new ( ) ;
243243 let mut trait_ids = BTreeMap :: new ( ) ;
244244 let mut opaque_ty_ids = BTreeMap :: new ( ) ;
245- let mut struct_kinds = BTreeMap :: new ( ) ;
245+ let mut adt_kinds = BTreeMap :: new ( ) ;
246246 let mut trait_kinds = BTreeMap :: new ( ) ;
247247 let mut opaque_ty_kinds = BTreeMap :: new ( ) ;
248248 let mut object_safe_traits = HashSet :: new ( ) ;
249249 for ( item, & raw_id) in self . items . iter ( ) . zip ( & raw_ids) {
250250 match item {
251251 Item :: StructDefn ( defn) => {
252252 let type_kind = defn. lower_type_kind ( ) ?;
253- let id = StructId ( raw_id) ;
254- struct_ids . insert ( type_kind. name . clone ( ) , id) ;
255- struct_kinds . insert ( id, type_kind) ;
253+ let id = AdtId ( raw_id) ;
254+ adt_ids . insert ( type_kind. name . clone ( ) , id) ;
255+ adt_kinds . insert ( id, type_kind) ;
256256 }
257257 Item :: TraitDefn ( defn) => {
258258 let type_kind = defn. lower_type_kind ( ) ?;
@@ -275,7 +275,7 @@ impl LowerProgram for Program {
275275 } ;
276276 }
277277
278- let mut struct_data = BTreeMap :: new ( ) ;
278+ let mut adt_data = BTreeMap :: new ( ) ;
279279 let mut trait_data = BTreeMap :: new ( ) ;
280280 let mut well_known_traits = BTreeMap :: new ( ) ;
281281 let mut impl_data = BTreeMap :: new ( ) ;
@@ -285,8 +285,8 @@ impl LowerProgram for Program {
285285 let mut custom_clauses = Vec :: new ( ) ;
286286 for ( item, & raw_id) in self . items . iter ( ) . zip ( & raw_ids) {
287287 let empty_env = Env {
288- struct_ids : & struct_ids ,
289- struct_kinds : & struct_kinds ,
288+ adt_ids : & adt_ids ,
289+ adt_kinds : & adt_kinds ,
290290 trait_ids : & trait_ids,
291291 trait_kinds : & trait_kinds,
292292 opaque_ty_ids : & opaque_ty_ids,
@@ -296,8 +296,8 @@ impl LowerProgram for Program {
296296
297297 match * item {
298298 Item :: StructDefn ( ref d) => {
299- let struct_id = StructId ( raw_id) ;
300- struct_data . insert ( struct_id , Arc :: new ( d. lower_struct ( struct_id , & empty_env) ?) ) ;
299+ let adt_id = AdtId ( raw_id) ;
300+ adt_data . insert ( adt_id , Arc :: new ( d. lower_adt ( adt_id , & empty_env) ?) ) ;
301301 }
302302 Item :: TraitDefn ( ref trait_defn) => {
303303 let trait_id = TraitId ( raw_id) ;
@@ -453,11 +453,11 @@ impl LowerProgram for Program {
453453 }
454454
455455 let program = LoweredProgram {
456- struct_ids ,
456+ adt_ids ,
457457 trait_ids,
458- struct_kinds ,
458+ adt_kinds ,
459459 trait_kinds,
460- struct_data ,
460+ adt_data ,
461461 trait_data,
462462 well_known_traits,
463463 impl_data,
@@ -807,20 +807,20 @@ impl LowerLeafGoal for LeafGoal {
807807 }
808808}
809809
810- trait LowerStructDefn {
811- fn lower_struct (
810+ trait LowerAdtDefn {
811+ fn lower_adt (
812812 & self ,
813- struct_id : chalk_ir:: StructId < ChalkIr > ,
813+ adt_id : chalk_ir:: AdtId < ChalkIr > ,
814814 env : & Env ,
815- ) -> LowerResult < rust_ir:: StructDatum < ChalkIr > > ;
815+ ) -> LowerResult < rust_ir:: AdtDatum < ChalkIr > > ;
816816}
817817
818- impl LowerStructDefn for StructDefn {
819- fn lower_struct (
818+ impl LowerAdtDefn for StructDefn {
819+ fn lower_adt (
820820 & self ,
821- struct_id : chalk_ir:: StructId < ChalkIr > ,
821+ adt_id : chalk_ir:: AdtId < ChalkIr > ,
822822 env : & Env ,
823- ) -> LowerResult < rust_ir:: StructDatum < ChalkIr > > {
823+ ) -> LowerResult < rust_ir:: AdtDatum < ChalkIr > > {
824824 if self . flags . fundamental && self . all_parameters ( ) . len ( ) != 1 {
825825 Err ( RustIrError :: InvalidFundamentalTypesParameters (
826826 self . name . clone ( ) ,
@@ -831,19 +831,19 @@ impl LowerStructDefn for StructDefn {
831831 let fields: LowerResult < _ > = self . fields . iter ( ) . map ( |f| f. ty . lower ( env) ) . collect ( ) ;
832832 let where_clauses = self . lower_where_clauses ( env) ?;
833833
834- Ok ( rust_ir:: StructDatumBound {
834+ Ok ( rust_ir:: AdtDatumBound {
835835 fields : fields?,
836836 where_clauses,
837837 } )
838838 } ) ?;
839839
840- let flags = rust_ir:: StructFlags {
840+ let flags = rust_ir:: AdtFlags {
841841 upstream : self . flags . upstream ,
842842 fundamental : self . flags . fundamental ,
843843 } ;
844844
845- Ok ( rust_ir:: StructDatum {
846- id : struct_id ,
845+ Ok ( rust_ir:: AdtDatum {
846+ id : adt_id ,
847847 binders,
848848 flags,
849849 } )
@@ -1104,8 +1104,8 @@ impl LowerTy for Ty {
11041104 let interner = env. interner ( ) ;
11051105 match self {
11061106 Ty :: Id { name } => match env. lookup_type ( name) ? {
1107- TypeLookup :: Struct ( id) => {
1108- let k = env. struct_kind ( id) ;
1107+ TypeLookup :: Adt ( id) => {
1108+ let k = env. adt_kind ( id) ;
11091109 if k. binders . len ( interner) > 0 {
11101110 Err ( RustIrError :: IncorrectNumberOfTypeParameters {
11111111 identifier : name. clone ( ) ,
@@ -1114,7 +1114,7 @@ impl LowerTy for Ty {
11141114 } )
11151115 } else {
11161116 Ok ( chalk_ir:: TyData :: Apply ( chalk_ir:: ApplicationTy {
1117- name : chalk_ir:: TypeName :: Struct ( id) ,
1117+ name : chalk_ir:: TypeName :: Adt ( id) ,
11181118 substitution : chalk_ir:: Substitution :: empty ( interner) ,
11191119 } )
11201120 . intern ( interner) )
@@ -1158,13 +1158,13 @@ impl LowerTy for Ty {
11581158
11591159 Ty :: Apply { name, ref args } => {
11601160 let id = match env. lookup_type ( name) ? {
1161- TypeLookup :: Struct ( id) => id,
1161+ TypeLookup :: Adt ( id) => id,
11621162 TypeLookup :: GenericArg ( _) | TypeLookup :: Opaque ( _) => {
11631163 Err ( RustIrError :: CannotApplyTypeParameter ( name. clone ( ) ) ) ?
11641164 }
11651165 } ;
11661166
1167- let k = env. struct_kind ( id) ;
1167+ let k = env. adt_kind ( id) ;
11681168 if k. binders . len ( interner) != args. len ( ) {
11691169 Err ( RustIrError :: IncorrectNumberOfTypeParameters {
11701170 identifier : name. clone ( ) ,
@@ -1189,7 +1189,7 @@ impl LowerTy for Ty {
11891189 }
11901190
11911191 Ok ( chalk_ir:: TyData :: Apply ( chalk_ir:: ApplicationTy {
1192- name : chalk_ir:: TypeName :: Struct ( id) ,
1192+ name : chalk_ir:: TypeName :: Adt ( id) ,
11931193 substitution,
11941194 } )
11951195 . intern ( interner) )
@@ -1484,10 +1484,10 @@ impl LowerGoal<LoweredProgram> for Goal {
14841484 . collect ( ) ;
14851485
14861486 let env = Env {
1487- struct_ids : & program. struct_ids ,
1487+ adt_ids : & program. adt_ids ,
14881488 trait_ids : & program. trait_ids ,
14891489 opaque_ty_ids : & program. opaque_ty_ids ,
1490- struct_kinds : & program. struct_kinds ,
1490+ adt_kinds : & program. adt_kinds ,
14911491 trait_kinds : & program. trait_kinds ,
14921492 associated_ty_lookups : & associated_ty_lookups,
14931493 parameter_map : BTreeMap :: new ( ) ,
0 commit comments