aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorPhilip Herron <philip.herron@embecosm.com>2021-10-20 16:28:50 +0100
committerPhilip Herron <philip.herron@embecosm.com>2021-10-22 10:49:14 +0100
commit3f67bb999b5e4457f434844cb16a21d6fc5694e1 (patch)
tree65020c1f323aabf9308cac9645482d93cc6f79dc /gcc
parent649e3e074bf8306bf0eb042f10483dbd61cd040b (diff)
downloadgcc-3f67bb999b5e4457f434844cb16a21d6fc5694e1.zip
gcc-3f67bb999b5e4457f434844cb16a21d6fc5694e1.tar.gz
gcc-3f67bb999b5e4457f434844cb16a21d6fc5694e1.tar.bz2
Refactor fill_param_ty into cc file
This also changes the signiture to take a fat pointer instead of raw pointer for the substitution.
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
{