aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust
diff options
context:
space:
mode:
authorPhilip Herron <philip.herron@embecosm.com>2021-04-29 18:30:16 +0100
committerPhilip Herron <philip.herron@embecosm.com>2021-04-29 18:32:15 +0100
commit5d9855c69a23278780bdbd64a14cc8073497f6e3 (patch)
tree08413a354ab59d8ad181bd662fb7037ca2ede929 /gcc/rust
parentc1296bc68e0b94285bbbab89a63ae44520d812ac (diff)
downloadgcc-5d9855c69a23278780bdbd64a14cc8073497f6e3.zip
gcc-5d9855c69a23278780bdbd64a14cc8073497f6e3.tar.gz
gcc-5d9855c69a23278780bdbd64a14cc8073497f6e3.tar.bz2
Refactor to GenericParam to TypeParam in parameter mappings
When we have Parameter mappings these _must_ be TypeParams this allows us to access the specified defaults if they exist.
Diffstat (limited to 'gcc/rust')
-rw-r--r--gcc/rust/typecheck/rust-hir-type-check-implitem.h8
-rw-r--r--gcc/rust/typecheck/rust-hir-type-check-toplevel.h16
-rw-r--r--gcc/rust/typecheck/rust-hir-type-check-type.h3
-rw-r--r--gcc/rust/typecheck/rust-tyty.h11
4 files changed, 19 insertions, 19 deletions
diff --git a/gcc/rust/typecheck/rust-hir-type-check-implitem.h b/gcc/rust/typecheck/rust-hir-type-check-implitem.h
index 7426a75..8ab20cf 100644
--- a/gcc/rust/typecheck/rust-hir-type-check-implitem.h
+++ b/gcc/rust/typecheck/rust-hir-type-check-implitem.h
@@ -63,8 +63,8 @@ public:
= TypeResolveGenericParam::Resolve (generic_param.get ());
context->insert_type (generic_param->get_mappings (), param_type);
- substitutions.push_back (
- TyTy::SubstitutionParamMapping (generic_param, param_type));
+ substitutions.push_back (TyTy::SubstitutionParamMapping (
+ static_cast<HIR::TypeParam &> (*generic_param), param_type));
}
}
@@ -115,8 +115,8 @@ public:
= TypeResolveGenericParam::Resolve (generic_param.get ());
context->insert_type (generic_param->get_mappings (), param_type);
- substitutions.push_back (
- TyTy::SubstitutionParamMapping (generic_param, param_type));
+ substitutions.push_back (TyTy::SubstitutionParamMapping (
+ static_cast<HIR::TypeParam &> (*generic_param), param_type));
}
}
diff --git a/gcc/rust/typecheck/rust-hir-type-check-toplevel.h b/gcc/rust/typecheck/rust-hir-type-check-toplevel.h
index d1d5681..1bfa7fb 100644
--- a/gcc/rust/typecheck/rust-hir-type-check-toplevel.h
+++ b/gcc/rust/typecheck/rust-hir-type-check-toplevel.h
@@ -59,8 +59,8 @@ public:
= TypeResolveGenericParam::Resolve (generic_param.get ());
context->insert_type (generic_param->get_mappings (), param_type);
- substitutions.push_back (
- TyTy::SubstitutionParamMapping (generic_param, param_type));
+ substitutions.push_back (TyTy::SubstitutionParamMapping (
+ static_cast<HIR::TypeParam &> (*generic_param), param_type));
}
}
@@ -99,8 +99,8 @@ public:
= TypeResolveGenericParam::Resolve (generic_param.get ());
context->insert_type (generic_param->get_mappings (), param_type);
- substitutions.push_back (
- TyTy::SubstitutionParamMapping (generic_param, param_type));
+ substitutions.push_back (TyTy::SubstitutionParamMapping (
+ static_cast<HIR::TypeParam &> (*generic_param), param_type));
}
}
@@ -156,8 +156,8 @@ public:
= TypeResolveGenericParam::Resolve (generic_param.get ());
context->insert_type (generic_param->get_mappings (), param_type);
- substitutions.push_back (
- TyTy::SubstitutionParamMapping (generic_param, param_type));
+ substitutions.push_back (TyTy::SubstitutionParamMapping (
+ static_cast<HIR::TypeParam &> (*generic_param), param_type));
}
}
@@ -209,8 +209,8 @@ public:
= TypeResolveGenericParam::Resolve (generic_param.get ());
context->insert_type (generic_param->get_mappings (), param_type);
- substitutions.push_back (
- TyTy::SubstitutionParamMapping (generic_param, param_type));
+ substitutions.push_back (TyTy::SubstitutionParamMapping (
+ static_cast<HIR::TypeParam &> (*generic_param), param_type));
}
}
diff --git a/gcc/rust/typecheck/rust-hir-type-check-type.h b/gcc/rust/typecheck/rust-hir-type-check-type.h
index 74e3ed3..d8a3f29 100644
--- a/gcc/rust/typecheck/rust-hir-type-check-type.h
+++ b/gcc/rust/typecheck/rust-hir-type-check-type.h
@@ -209,8 +209,7 @@ private:
{
std::string sym = mapping.get_param_ty ()->get_symbol ();
param_tys.insert (sym);
- param_location_map[sym]
- = mapping.get_generic_param ()->get_locus_slow ();
+ param_location_map[sym] = mapping.get_generic_param ().get_locus ();
}
std::set<std::string> args;
diff --git a/gcc/rust/typecheck/rust-tyty.h b/gcc/rust/typecheck/rust-tyty.h
index 91c3f06..ee13532 100644
--- a/gcc/rust/typecheck/rust-tyty.h
+++ b/gcc/rust/typecheck/rust-tyty.h
@@ -398,8 +398,7 @@ private:
class SubstitutionParamMapping
{
public:
- SubstitutionParamMapping (std::unique_ptr<HIR::GenericParam> &generic,
- ParamType *param)
+ SubstitutionParamMapping (const HIR::TypeParam &generic, ParamType *param)
: generic (generic), param (param)
{}
@@ -431,7 +430,7 @@ public:
const ParamType *get_param_ty () const { return param; }
- std::unique_ptr<HIR::GenericParam> &get_generic_param () { return generic; };
+ const HIR::TypeParam &get_generic_param () { return generic; };
void override_context ();
@@ -444,10 +443,12 @@ public:
return p->resolve ()->get_kind () == TypeKind::PARAM;
}
- Location get_param_locus () const { return generic->get_locus_slow (); }
+ Location get_param_locus () const { return generic.get_locus (); }
+
+ bool param_has_default_ty () const { return generic.has_type (); }
private:
- std::unique_ptr<HIR::GenericParam> &generic;
+ const HIR::TypeParam &generic;
ParamType *param;
};