@@ -63,12 +63,15 @@ TypeCheckItem::ResolveImplBlockSelf (HIR::ImplBlock &impl_block)
63
63
TypeCheckItem resolver;
64
64
65
65
bool failed_flag = false ;
66
- std::vector<TyTy::SubstitutionParamMapping> substitutions
66
+ auto result
67
67
= resolver.resolve_impl_block_substitutions (impl_block, failed_flag);
68
68
if (failed_flag)
69
69
{
70
70
return new TyTy::ErrorType (impl_block.get_mappings ().get_hirid ());
71
71
}
72
+ std::vector<TyTy::SubstitutionParamMapping> substitutions
73
+ = std::move (result.first );
74
+ TyTy::RegionConstraints region_constraints = std::move (result.second );
72
75
73
76
return resolver.resolve_impl_block_self (impl_block);
74
77
}
@@ -81,12 +84,14 @@ TypeCheckItem::ResolveImplBlockSelfWithInference (
81
84
TypeCheckItem resolver;
82
85
83
86
bool failed_flag = false ;
84
- std::vector<TyTy::SubstitutionParamMapping> substitutions
85
- = resolver.resolve_impl_block_substitutions (impl, failed_flag);
87
+ auto result = resolver.resolve_impl_block_substitutions (impl, failed_flag);
86
88
if (failed_flag)
87
89
{
88
90
return new TyTy::ErrorType (impl.get_mappings ().get_hirid ());
89
91
}
92
+ std::vector<TyTy::SubstitutionParamMapping> substitutions
93
+ = std::move (result.first );
94
+ TyTy::RegionConstraints region_constraints = std::move (result.second );
90
95
91
96
// now that we have the param mappings we need to query the self type
92
97
TyTy::BaseType *self = resolver.resolve_impl_block_self (impl);
@@ -140,9 +145,10 @@ TypeCheckItem::visit (HIR::TypeAlias &alias)
140
145
141
146
context->insert_type (alias.get_mappings (), actual_type);
142
147
148
+ TyTy::RegionConstraints region_constraints;
143
149
for (auto &where_clause_item : alias.get_where_clause ().get_items ())
144
150
{
145
- ResolveWhereClauseItem::Resolve (*where_clause_item);
151
+ ResolveWhereClauseItem::Resolve (*where_clause_item, region_constraints );
146
152
}
147
153
infered = actual_type;
148
154
}
@@ -156,9 +162,10 @@ TypeCheckItem::visit (HIR::TupleStruct &struct_decl)
156
162
if (struct_decl.has_generics ())
157
163
resolve_generic_params (struct_decl.get_generic_params (), substitutions);
158
164
165
+ TyTy::RegionConstraints region_constraints;
159
166
for (auto &where_clause_item : struct_decl.get_where_clause ().get_items ())
160
167
{
161
- ResolveWhereClauseItem::Resolve (*where_clause_item);
168
+ ResolveWhereClauseItem::Resolve (*where_clause_item, region_constraints );
162
169
}
163
170
164
171
std::vector<TyTy::StructFieldType *> fields;
@@ -203,7 +210,8 @@ TypeCheckItem::visit (HIR::TupleStruct &struct_decl)
203
210
TyTy::ADTType::ADTKind::TUPLE_STRUCT, std::move (variants),
204
211
std::move (substitutions), repr,
205
212
TyTy::SubstitutionArgumentMappings::empty (
206
- context->get_lifetime_resolver ().get_num_bound_regions ()));
213
+ context->get_lifetime_resolver ().get_num_bound_regions ()),
214
+ region_constraints);
207
215
208
216
context->insert_type (struct_decl.get_mappings (), type);
209
217
infered = type;
@@ -218,9 +226,10 @@ TypeCheckItem::visit (HIR::StructStruct &struct_decl)
218
226
if (struct_decl.has_generics ())
219
227
resolve_generic_params (struct_decl.get_generic_params (), substitutions);
220
228
229
+ TyTy::RegionConstraints region_constraints;
221
230
for (auto &where_clause_item : struct_decl.get_where_clause ().get_items ())
222
231
{
223
- ResolveWhereClauseItem::Resolve (*where_clause_item);
232
+ ResolveWhereClauseItem::Resolve (*where_clause_item, region_constraints );
224
233
}
225
234
226
235
std::vector<TyTy::StructFieldType *> fields;
@@ -263,7 +272,8 @@ TypeCheckItem::visit (HIR::StructStruct &struct_decl)
263
272
TyTy::ADTType::ADTKind::STRUCT_STRUCT, std::move (variants),
264
273
std::move (substitutions), repr,
265
274
TyTy::SubstitutionArgumentMappings::empty (
266
- context->get_lifetime_resolver ().get_num_bound_regions ()));
275
+ context->get_lifetime_resolver ().get_num_bound_regions ()),
276
+ region_constraints);
267
277
268
278
context->insert_type (struct_decl.get_mappings (), type);
269
279
infered = type;
@@ -316,9 +326,10 @@ TypeCheckItem::visit (HIR::Union &union_decl)
316
326
if (union_decl.has_generics ())
317
327
resolve_generic_params (union_decl.get_generic_params (), substitutions);
318
328
329
+ TyTy::RegionConstraints region_constraints;
319
330
for (auto &where_clause_item : union_decl.get_where_clause ().get_items ())
320
331
{
321
- ResolveWhereClauseItem::Resolve (*where_clause_item);
332
+ ResolveWhereClauseItem::Resolve (*where_clause_item, region_constraints );
322
333
}
323
334
324
335
std::vector<TyTy::StructFieldType *> fields;
@@ -401,13 +412,15 @@ TypeCheckItem::visit (HIR::ImplBlock &impl_block)
401
412
auto binder_pin = context->push_clean_lifetime_resolver (true );
402
413
403
414
bool failed_flag = false ;
404
- std::vector<TyTy::SubstitutionParamMapping> substitutions
405
- = resolve_impl_block_substitutions (impl_block, failed_flag);
415
+ auto result = resolve_impl_block_substitutions (impl_block, failed_flag);
406
416
if (failed_flag)
407
417
{
408
418
infered = new TyTy::ErrorType (impl_block.get_mappings ().get_hirid ());
409
419
return ;
410
420
}
421
+ std::vector<TyTy::SubstitutionParamMapping> substitutions
422
+ = std::move (result.first );
423
+ TyTy::RegionConstraints region_constraints = std::move (result.second );
411
424
412
425
TyTy::BaseType *self = resolve_impl_block_self (impl_block);
413
426
@@ -427,13 +440,16 @@ TypeCheckItem::resolve_impl_item (HIR::ImplBlock &impl_block,
427
440
HIR::ImplItem &item)
428
441
{
429
442
bool failed_flag = false ;
430
- std::vector<TyTy::SubstitutionParamMapping> substitutions
431
- = resolve_impl_block_substitutions (impl_block, failed_flag);
443
+ auto result = resolve_impl_block_substitutions (impl_block, failed_flag);
432
444
if (failed_flag)
433
445
{
434
446
return new TyTy::ErrorType (impl_block.get_mappings ().get_hirid ());
435
447
}
436
448
449
+ std::vector<TyTy::SubstitutionParamMapping> substitutions
450
+ = std::move (result.first );
451
+ TyTy::RegionConstraints region_constraints = std::move (result.second );
452
+
437
453
TyTy::BaseType *self = resolve_impl_block_self (impl_block);
438
454
439
455
return TypeCheckImplItem::Resolve (&impl_block, &item, self, substitutions);
@@ -445,11 +461,13 @@ TypeCheckItem::visit (HIR::Function &function)
445
461
auto lifetime_pin = context->push_clean_lifetime_resolver ();
446
462
std::vector<TyTy::SubstitutionParamMapping> substitutions;
447
463
if (function.has_generics ())
448
- resolve_generic_params (function.get_generic_params (), substitutions);
464
+ resolve_generic_params (function.get_generic_params (),
465
+ substitutions); // TODO resolve constraints
449
466
467
+ TyTy::RegionConstraints region_constraints;
450
468
for (auto &where_clause_item : function.get_where_clause ().get_items ())
451
469
{
452
- ResolveWhereClauseItem::Resolve (*where_clause_item);
470
+ ResolveWhereClauseItem::Resolve (*where_clause_item, region_constraints );
453
471
}
454
472
455
473
TyTy::BaseType *ret_type = nullptr ;
@@ -498,7 +516,8 @@ TypeCheckItem::visit (HIR::Function &function)
498
516
TyTy::FnType::FNTYPE_DEFAULT_FLAGS, ABI::RUST, std::move (params), ret_type,
499
517
std::move (substitutions),
500
518
TyTy::SubstitutionArgumentMappings::empty (
501
- context->get_lifetime_resolver ().get_num_bound_regions ()));
519
+ context->get_lifetime_resolver ().get_num_bound_regions ()),
520
+ region_constraints);
502
521
503
522
context->insert_type (function.get_mappings (), fn_type);
504
523
@@ -558,17 +577,18 @@ TypeCheckItem::visit (HIR::ExternBlock &extern_block)
558
577
}
559
578
}
560
579
561
- std::vector<TyTy::SubstitutionParamMapping>
580
+ std::pair<std:: vector<TyTy::SubstitutionParamMapping>, TyTy::RegionConstraints >
562
581
TypeCheckItem::resolve_impl_block_substitutions (HIR::ImplBlock &impl_block,
563
582
bool &failure_flag)
564
583
{
565
584
std::vector<TyTy::SubstitutionParamMapping> substitutions;
566
585
if (impl_block.has_generics ())
567
586
resolve_generic_params (impl_block.get_generic_params (), substitutions);
568
587
588
+ TyTy::RegionConstraints region_constraints;
569
589
for (auto &where_clause_item : impl_block.get_where_clause ().get_items ())
570
590
{
571
- ResolveWhereClauseItem::Resolve (*where_clause_item);
591
+ ResolveWhereClauseItem::Resolve (*where_clause_item, region_constraints );
572
592
}
573
593
574
594
auto specified_bound = TyTy::TypeBoundPredicate::error ();
@@ -600,7 +620,7 @@ TypeCheckItem::resolve_impl_block_substitutions (HIR::ImplBlock &impl_block,
600
620
failure_flag = check_for_unconstrained (substitutions, trait_constraints,
601
621
impl_constraints, self);
602
622
603
- return substitutions;
623
+ return { substitutions, region_constraints} ;
604
624
}
605
625
606
626
void
0 commit comments