aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc')
-rw-r--r--gcc/rust/typecheck/rust-tyty.cc30
-rw-r--r--gcc/rust/typecheck/rust-tyty.h23
2 files changed, 28 insertions, 25 deletions
diff --git a/gcc/rust/typecheck/rust-tyty.cc b/gcc/rust/typecheck/rust-tyty.cc
index f08d8cb..b6d88ee 100644
--- a/gcc/rust/typecheck/rust-tyty.cc
+++ b/gcc/rust/typecheck/rust-tyty.cc
@@ -329,6 +329,30 @@ StructFieldType::clone () const
}
void
+SubstitutionParamMapping::fill_param_ty (BaseType &type, Location locus)
+{
+ if (type.get_kind () == TyTy::TypeKind::INFER)
+ {
+ type.inherit_bounds (*param);
+ }
+ else
+ {
+ if (!param->bounds_compatible (type, locus, true))
+ return;
+ }
+
+ if (type.get_kind () == TypeKind::PARAM)
+ {
+ delete param;
+ param = static_cast<ParamType *> (type.clone ());
+ }
+ else
+ {
+ param->set_ty_ref (type.get_ref ());
+ }
+}
+
+void
SubstitutionParamMapping::override_context ()
{
if (!param->can_resolve ())
@@ -643,7 +667,7 @@ ADTType::handle_substitions (SubstitutionArgumentMappings subst_mappings)
bool ok
= subst_mappings.get_argument_for_symbol (sub.get_param_ty (), &arg);
if (ok)
- sub.fill_param_ty (arg.get_tyty (), subst_mappings.get_locus ());
+ sub.fill_param_ty (*arg.get_tyty (), subst_mappings.get_locus ());
}
adt->iterate_fields ([&] (StructFieldType *field) mutable -> bool {
@@ -924,7 +948,7 @@ FnType::handle_substitions (SubstitutionArgumentMappings subst_mappings)
= subst_mappings.get_argument_for_symbol (sub.get_param_ty (), &arg);
if (ok)
{
- sub.fill_param_ty (arg.get_tyty (), subst_mappings.get_locus ());
+ sub.fill_param_ty (*arg.get_tyty (), subst_mappings.get_locus ());
}
}
@@ -2275,7 +2299,7 @@ ProjectionType::handle_substitions (SubstitutionArgumentMappings subst_mappings)
bool ok
= subst_mappings.get_argument_for_symbol (sub.get_param_ty (), &arg);
if (ok)
- sub.fill_param_ty (arg.get_tyty (), subst_mappings.get_locus ());
+ sub.fill_param_ty (*arg.get_tyty (), subst_mappings.get_locus ());
}
auto fty = projection->base;
diff --git a/gcc/rust/typecheck/rust-tyty.h b/gcc/rust/typecheck/rust-tyty.h
index 8ab120e..0712c3c 100644
--- a/gcc/rust/typecheck/rust-tyty.h
+++ b/gcc/rust/typecheck/rust-tyty.h
@@ -626,28 +626,7 @@ public:
std::string as_string () const { return param->as_string (); }
- void fill_param_ty (BaseType *type, Location locus)
- {
- if (type->get_kind () == TyTy::TypeKind::INFER)
- {
- type->inherit_bounds (*param);
- }
- else
- {
- if (!param->bounds_compatible (*type, locus, true))
- return;
- }
-
- if (type->get_kind () == TypeKind::PARAM)
- {
- delete param;
- param = static_cast<ParamType *> (type->clone ());
- }
- else
- {
- param->set_ty_ref (type->get_ref ());
- }
- }
+ void fill_param_ty (BaseType &type, Location locus);
SubstitutionParamMapping clone () const
{