26
26
#include " rust-substitution-mapper.h"
27
27
#include " rust-type-util.h"
28
28
29
+ #include < rust-tyty-variance-analysis.h>
30
+
29
31
namespace Rust {
30
32
namespace Resolver {
31
33
@@ -204,7 +206,7 @@ TypeCheckItem::visit (HIR::TupleStruct &struct_decl)
204
206
TyTy::ADTType::ReprOptions repr
205
207
= parse_repr_options (attrs, struct_decl.get_locus ());
206
208
207
- TyTy::BaseType *type = new TyTy::ADTType (
209
+ auto *type = new TyTy::ADTType (
208
210
struct_decl.get_mappings ().get_hirid (), mappings->get_next_hir_id (),
209
211
struct_decl.get_identifier ().as_string (), ident,
210
212
TyTy::ADTType::ADTKind::TUPLE_STRUCT, std::move (variants),
@@ -215,6 +217,8 @@ TypeCheckItem::visit (HIR::TupleStruct &struct_decl)
215
217
216
218
context->insert_type (struct_decl.get_mappings (), type);
217
219
infered = type;
220
+
221
+ TyTy::VarianceAnalysis::add_type_constraints (*type);
218
222
}
219
223
220
224
void
@@ -266,7 +270,7 @@ TypeCheckItem::visit (HIR::StructStruct &struct_decl)
266
270
TyTy::ADTType::ReprOptions repr
267
271
= parse_repr_options (attrs, struct_decl.get_locus ());
268
272
269
- TyTy::BaseType *type = new TyTy::ADTType (
273
+ auto *type = new TyTy::ADTType (
270
274
struct_decl.get_mappings ().get_hirid (), mappings->get_next_hir_id (),
271
275
struct_decl.get_identifier ().as_string (), ident,
272
276
TyTy::ADTType::ADTKind::STRUCT_STRUCT, std::move (variants),
@@ -277,6 +281,8 @@ TypeCheckItem::visit (HIR::StructStruct &struct_decl)
277
281
278
282
context->insert_type (struct_decl.get_mappings (), type);
279
283
infered = type;
284
+
285
+ TyTy::VarianceAnalysis::add_type_constraints (*type);
280
286
}
281
287
282
288
void
@@ -307,7 +313,7 @@ TypeCheckItem::visit (HIR::Enum &enum_decl)
307
313
RustIdent ident{*canonical_path, enum_decl.get_locus ()};
308
314
309
315
// multi variant ADT
310
- TyTy::BaseType *type
316
+ auto *type
311
317
= new TyTy::ADTType (enum_decl.get_mappings ().get_hirid (),
312
318
mappings->get_next_hir_id (),
313
319
enum_decl.get_identifier ().as_string (), ident,
@@ -316,6 +322,8 @@ TypeCheckItem::visit (HIR::Enum &enum_decl)
316
322
317
323
context->insert_type (enum_decl.get_mappings (), type);
318
324
infered = type;
325
+
326
+ TyTy::VarianceAnalysis::add_type_constraints (*type);
319
327
}
320
328
321
329
void
@@ -363,7 +371,7 @@ TypeCheckItem::visit (HIR::Union &union_decl)
363
371
TyTy::VariantDef::VariantType::STRUCT, nullptr ,
364
372
std::move (fields)));
365
373
366
- TyTy::BaseType *type
374
+ auto *type
367
375
= new TyTy::ADTType (union_decl.get_mappings ().get_hirid (),
368
376
mappings->get_next_hir_id (),
369
377
union_decl.get_identifier ().as_string (), ident,
@@ -372,6 +380,8 @@ TypeCheckItem::visit (HIR::Union &union_decl)
372
380
373
381
context->insert_type (union_decl.get_mappings (), type);
374
382
infered = type;
383
+
384
+ TyTy::VarianceAnalysis::add_type_constraints (*type);
375
385
}
376
386
377
387
void
0 commit comments