@@ -2,8 +2,8 @@ use crate::interner::ChalkIr;
2
2
use chalk_ir:: cast:: { Cast , Caster } ;
3
3
use chalk_ir:: interner:: HasInterner ;
4
4
use 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 ,
7
7
} ;
8
8
use chalk_parse:: ast:: * ;
9
9
use chalk_rust_ir as rust_ir;
@@ -18,10 +18,10 @@ use crate::error::RustIrError;
18
18
use crate :: program:: Program as LoweredProgram ;
19
19
use crate :: { Identifier as Ident , RawId , TypeKind , TypeSort } ;
20
20
21
- type StructIds = BTreeMap < Ident , chalk_ir:: StructId < ChalkIr > > ;
21
+ type AdtIds = BTreeMap < Ident , chalk_ir:: AdtId < ChalkIr > > ;
22
22
type TraitIds = BTreeMap < Ident , chalk_ir:: TraitId < ChalkIr > > ;
23
23
type 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 > ;
25
25
type TraitKinds = BTreeMap < chalk_ir:: TraitId < ChalkIr > , TypeKind > ;
26
26
type AssociatedTyLookups = BTreeMap < ( chalk_ir:: TraitId < ChalkIr > , Ident ) , AssociatedTyLookup > ;
27
27
type AssociatedTyValueIds =
@@ -34,8 +34,8 @@ pub type LowerResult<T> = Result<T, RustIrError>;
34
34
35
35
#[ derive( Clone , Debug ) ]
36
36
struct Env < ' k > {
37
- struct_ids : & ' k StructIds ,
38
- struct_kinds : & ' k StructKinds ,
37
+ adt_ids : & ' k AdtIds ,
38
+ adt_kinds : & ' k AdtKinds ,
39
39
trait_ids : & ' k TraitIds ,
40
40
trait_kinds : & ' k TraitKinds ,
41
41
opaque_ty_ids : & ' k OpaqueTyIds ,
@@ -71,7 +71,7 @@ struct AssociatedTyLookup {
71
71
}
72
72
73
73
enum TypeLookup {
74
- Struct ( chalk_ir:: StructId < ChalkIr > ) ,
74
+ Adt ( chalk_ir:: AdtId < ChalkIr > ) ,
75
75
GenericArg ( BoundVar ) ,
76
76
Opaque ( chalk_ir:: OpaqueTyId < ChalkIr > ) ,
77
77
}
@@ -92,8 +92,8 @@ impl<'k> Env<'k> {
92
92
return Ok ( TypeLookup :: GenericArg ( * k) ) ;
93
93
}
94
94
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) ) ;
97
97
}
98
98
99
99
if let Some ( id) = self . opaque_ty_ids . get ( & name. str ) {
@@ -114,7 +114,7 @@ impl<'k> Env<'k> {
114
114
return Err ( RustIrError :: NotTrait ( name. clone ( ) ) ) ;
115
115
}
116
116
117
- if let Some ( _) = self . struct_ids . get ( & name. str ) {
117
+ if let Some ( _) = self . adt_ids . get ( & name. str ) {
118
118
return Err ( RustIrError :: NotTrait ( name. clone ( ) ) ) ;
119
119
}
120
120
@@ -136,8 +136,8 @@ impl<'k> Env<'k> {
136
136
Err ( RustIrError :: InvalidLifetimeName ( name. clone ( ) ) )
137
137
}
138
138
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]
141
141
}
142
142
143
143
fn trait_kind ( & self , id : chalk_ir:: TraitId < ChalkIr > ) -> & TypeKind {
@@ -239,20 +239,20 @@ impl LowerProgram for Program {
239
239
}
240
240
}
241
241
242
- let mut struct_ids = BTreeMap :: new ( ) ;
242
+ let mut adt_ids = BTreeMap :: new ( ) ;
243
243
let mut trait_ids = BTreeMap :: new ( ) ;
244
244
let mut opaque_ty_ids = BTreeMap :: new ( ) ;
245
- let mut struct_kinds = BTreeMap :: new ( ) ;
245
+ let mut adt_kinds = BTreeMap :: new ( ) ;
246
246
let mut trait_kinds = BTreeMap :: new ( ) ;
247
247
let mut opaque_ty_kinds = BTreeMap :: new ( ) ;
248
248
let mut object_safe_traits = HashSet :: new ( ) ;
249
249
for ( item, & raw_id) in self . items . iter ( ) . zip ( & raw_ids) {
250
250
match item {
251
251
Item :: StructDefn ( defn) => {
252
252
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) ;
256
256
}
257
257
Item :: TraitDefn ( defn) => {
258
258
let type_kind = defn. lower_type_kind ( ) ?;
@@ -275,7 +275,7 @@ impl LowerProgram for Program {
275
275
} ;
276
276
}
277
277
278
- let mut struct_data = BTreeMap :: new ( ) ;
278
+ let mut adt_data = BTreeMap :: new ( ) ;
279
279
let mut trait_data = BTreeMap :: new ( ) ;
280
280
let mut well_known_traits = BTreeMap :: new ( ) ;
281
281
let mut impl_data = BTreeMap :: new ( ) ;
@@ -285,8 +285,8 @@ impl LowerProgram for Program {
285
285
let mut custom_clauses = Vec :: new ( ) ;
286
286
for ( item, & raw_id) in self . items . iter ( ) . zip ( & raw_ids) {
287
287
let empty_env = Env {
288
- struct_ids : & struct_ids ,
289
- struct_kinds : & struct_kinds ,
288
+ adt_ids : & adt_ids ,
289
+ adt_kinds : & adt_kinds ,
290
290
trait_ids : & trait_ids,
291
291
trait_kinds : & trait_kinds,
292
292
opaque_ty_ids : & opaque_ty_ids,
@@ -296,8 +296,8 @@ impl LowerProgram for Program {
296
296
297
297
match * item {
298
298
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) ?) ) ;
301
301
}
302
302
Item :: TraitDefn ( ref trait_defn) => {
303
303
let trait_id = TraitId ( raw_id) ;
@@ -453,11 +453,11 @@ impl LowerProgram for Program {
453
453
}
454
454
455
455
let program = LoweredProgram {
456
- struct_ids ,
456
+ adt_ids ,
457
457
trait_ids,
458
- struct_kinds ,
458
+ adt_kinds ,
459
459
trait_kinds,
460
- struct_data ,
460
+ adt_data ,
461
461
trait_data,
462
462
well_known_traits,
463
463
impl_data,
@@ -807,20 +807,20 @@ impl LowerLeafGoal for LeafGoal {
807
807
}
808
808
}
809
809
810
- trait LowerStructDefn {
811
- fn lower_struct (
810
+ trait LowerAdtDefn {
811
+ fn lower_adt (
812
812
& self ,
813
- struct_id : chalk_ir:: StructId < ChalkIr > ,
813
+ adt_id : chalk_ir:: AdtId < ChalkIr > ,
814
814
env : & Env ,
815
- ) -> LowerResult < rust_ir:: StructDatum < ChalkIr > > ;
815
+ ) -> LowerResult < rust_ir:: AdtDatum < ChalkIr > > ;
816
816
}
817
817
818
- impl LowerStructDefn for StructDefn {
819
- fn lower_struct (
818
+ impl LowerAdtDefn for StructDefn {
819
+ fn lower_adt (
820
820
& self ,
821
- struct_id : chalk_ir:: StructId < ChalkIr > ,
821
+ adt_id : chalk_ir:: AdtId < ChalkIr > ,
822
822
env : & Env ,
823
- ) -> LowerResult < rust_ir:: StructDatum < ChalkIr > > {
823
+ ) -> LowerResult < rust_ir:: AdtDatum < ChalkIr > > {
824
824
if self . flags . fundamental && self . all_parameters ( ) . len ( ) != 1 {
825
825
Err ( RustIrError :: InvalidFundamentalTypesParameters (
826
826
self . name . clone ( ) ,
@@ -831,19 +831,19 @@ impl LowerStructDefn for StructDefn {
831
831
let fields: LowerResult < _ > = self . fields . iter ( ) . map ( |f| f. ty . lower ( env) ) . collect ( ) ;
832
832
let where_clauses = self . lower_where_clauses ( env) ?;
833
833
834
- Ok ( rust_ir:: StructDatumBound {
834
+ Ok ( rust_ir:: AdtDatumBound {
835
835
fields : fields?,
836
836
where_clauses,
837
837
} )
838
838
} ) ?;
839
839
840
- let flags = rust_ir:: StructFlags {
840
+ let flags = rust_ir:: AdtFlags {
841
841
upstream : self . flags . upstream ,
842
842
fundamental : self . flags . fundamental ,
843
843
} ;
844
844
845
- Ok ( rust_ir:: StructDatum {
846
- id : struct_id ,
845
+ Ok ( rust_ir:: AdtDatum {
846
+ id : adt_id ,
847
847
binders,
848
848
flags,
849
849
} )
@@ -1104,8 +1104,8 @@ impl LowerTy for Ty {
1104
1104
let interner = env. interner ( ) ;
1105
1105
match self {
1106
1106
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) ;
1109
1109
if k. binders . len ( interner) > 0 {
1110
1110
Err ( RustIrError :: IncorrectNumberOfTypeParameters {
1111
1111
identifier : name. clone ( ) ,
@@ -1114,7 +1114,7 @@ impl LowerTy for Ty {
1114
1114
} )
1115
1115
} else {
1116
1116
Ok ( chalk_ir:: TyData :: Apply ( chalk_ir:: ApplicationTy {
1117
- name : chalk_ir:: TypeName :: Struct ( id) ,
1117
+ name : chalk_ir:: TypeName :: Adt ( id) ,
1118
1118
substitution : chalk_ir:: Substitution :: empty ( interner) ,
1119
1119
} )
1120
1120
. intern ( interner) )
@@ -1158,13 +1158,13 @@ impl LowerTy for Ty {
1158
1158
1159
1159
Ty :: Apply { name, ref args } => {
1160
1160
let id = match env. lookup_type ( name) ? {
1161
- TypeLookup :: Struct ( id) => id,
1161
+ TypeLookup :: Adt ( id) => id,
1162
1162
TypeLookup :: GenericArg ( _) | TypeLookup :: Opaque ( _) => {
1163
1163
Err ( RustIrError :: CannotApplyTypeParameter ( name. clone ( ) ) ) ?
1164
1164
}
1165
1165
} ;
1166
1166
1167
- let k = env. struct_kind ( id) ;
1167
+ let k = env. adt_kind ( id) ;
1168
1168
if k. binders . len ( interner) != args. len ( ) {
1169
1169
Err ( RustIrError :: IncorrectNumberOfTypeParameters {
1170
1170
identifier : name. clone ( ) ,
@@ -1189,7 +1189,7 @@ impl LowerTy for Ty {
1189
1189
}
1190
1190
1191
1191
Ok ( chalk_ir:: TyData :: Apply ( chalk_ir:: ApplicationTy {
1192
- name : chalk_ir:: TypeName :: Struct ( id) ,
1192
+ name : chalk_ir:: TypeName :: Adt ( id) ,
1193
1193
substitution,
1194
1194
} )
1195
1195
. intern ( interner) )
@@ -1484,10 +1484,10 @@ impl LowerGoal<LoweredProgram> for Goal {
1484
1484
. collect ( ) ;
1485
1485
1486
1486
let env = Env {
1487
- struct_ids : & program. struct_ids ,
1487
+ adt_ids : & program. adt_ids ,
1488
1488
trait_ids : & program. trait_ids ,
1489
1489
opaque_ty_ids : & program. opaque_ty_ids ,
1490
- struct_kinds : & program. struct_kinds ,
1490
+ adt_kinds : & program. adt_kinds ,
1491
1491
trait_kinds : & program. trait_kinds ,
1492
1492
associated_ty_lookups : & associated_ty_lookups,
1493
1493
parameter_map : BTreeMap :: new ( ) ,
0 commit comments