aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorPhilip Herron <philip.herron@embecosm.com>2021-05-12 17:50:57 +0100
committerPhilip Herron <philip.herron@embecosm.com>2021-05-12 17:50:57 +0100
commita1c148518de1cb8f60f779dc206f663e8593191a (patch)
tree268a9a1ad2ba21bd18ab61b0847e6a49c971b897 /gcc
parent17258c94f8c996c26ccde103afd1c0a8a343301b (diff)
downloadgcc-a1c148518de1cb8f60f779dc206f663e8593191a.zip
gcc-a1c148518de1cb8f60f779dc206f663e8593191a.tar.gz
gcc-a1c148518de1cb8f60f779dc206f663e8593191a.tar.bz2
Add the identifier to part of fntype signitures
Tracking the identifier helps ensure fntypes are distinct and do not overlap.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/rust/typecheck/rust-hir-type-check-implitem.h10
-rw-r--r--gcc/rust/typecheck/rust-hir-type-check-toplevel.h3
-rw-r--r--gcc/rust/typecheck/rust-tyty.cc10
-rw-r--r--gcc/rust/typecheck/rust-tyty.h13
4 files changed, 24 insertions, 12 deletions
diff --git a/gcc/rust/typecheck/rust-hir-type-check-implitem.h b/gcc/rust/typecheck/rust-hir-type-check-implitem.h
index f961bba..2f54d0c 100644
--- a/gcc/rust/typecheck/rust-hir-type-check-implitem.h
+++ b/gcc/rust/typecheck/rust-hir-type-check-implitem.h
@@ -112,7 +112,8 @@ public:
}
auto fnType = new TyTy::FnType (function.get_mappings ().get_hirid (),
- false, std::move (params), ret_type,
+ function.get_function_name (), false,
+ std::move (params), ret_type,
std::move (substitutions));
context->insert_type (function.get_mappings (), fnType);
}
@@ -189,9 +190,10 @@ public:
context->insert_type (param.get_mappings (), param_tyty);
}
- auto fnType = new TyTy::FnType (method.get_mappings ().get_hirid (), true,
- std::move (params), ret_type,
- std::move (substitutions));
+ auto fnType
+ = new TyTy::FnType (method.get_mappings ().get_hirid (),
+ method.get_method_name (), true, std::move (params),
+ ret_type, std::move (substitutions));
context->insert_type (method.get_mappings (), fnType);
}
diff --git a/gcc/rust/typecheck/rust-hir-type-check-toplevel.h b/gcc/rust/typecheck/rust-hir-type-check-toplevel.h
index ef940c1..e01b46f 100644
--- a/gcc/rust/typecheck/rust-hir-type-check-toplevel.h
+++ b/gcc/rust/typecheck/rust-hir-type-check-toplevel.h
@@ -229,7 +229,8 @@ public:
}
auto fnType = new TyTy::FnType (function.get_mappings ().get_hirid (),
- false, std::move (params), ret_type,
+ function.get_function_name (), false,
+ std::move (params), ret_type,
std::move (substitutions));
context->insert_type (function.get_mappings (), fnType);
}
diff --git a/gcc/rust/typecheck/rust-tyty.cc b/gcc/rust/typecheck/rust-tyty.cc
index 551042a..0859570 100644
--- a/gcc/rust/typecheck/rust-tyty.cc
+++ b/gcc/rust/typecheck/rust-tyty.cc
@@ -679,6 +679,9 @@ FnType::is_equal (const BaseType &other) const
return false;
auto other2 = static_cast<const FnType &> (other);
+ if (get_identifier ().compare (other2.get_identifier ()) != 0)
+ return false;
+
if (!get_return_type ()->is_equal (*other2.get_return_type ()))
return false;
@@ -712,9 +715,10 @@ FnType::clone ()
cloned_params.push_back (
std::pair<HIR::Pattern *, BaseType *> (p.first, p.second->clone ()));
- return new FnType (get_ref (), get_ty_ref (), is_method_flag,
- std::move (cloned_params), get_return_type ()->clone (),
- clone_substs (), get_combined_refs ());
+ return new FnType (get_ref (), get_ty_ref (), get_identifier (),
+ is_method_flag, std::move (cloned_params),
+ get_return_type ()->clone (), clone_substs (),
+ get_combined_refs ());
}
FnType *
diff --git a/gcc/rust/typecheck/rust-tyty.h b/gcc/rust/typecheck/rust-tyty.h
index aa709ec..5acc9e7 100644
--- a/gcc/rust/typecheck/rust-tyty.h
+++ b/gcc/rust/typecheck/rust-tyty.h
@@ -855,24 +855,26 @@ private:
class FnType : public BaseType, public SubstitutionRef
{
public:
- FnType (HirId ref, bool is_method,
+ FnType (HirId ref, std::string identifier, bool is_method,
std::vector<std::pair<HIR::Pattern *, BaseType *> > params,
BaseType *type, std::vector<SubstitutionParamMapping> subst_refs,
std::set<HirId> refs = std::set<HirId> ())
: BaseType (ref, ref, TypeKind::FNDEF, refs),
SubstitutionRef (std::move (subst_refs),
SubstitutionArgumentMappings::error ()),
- params (std::move (params)), type (type), is_method_flag (is_method)
+ params (std::move (params)), type (type), is_method_flag (is_method),
+ identifier (identifier)
{}
- FnType (HirId ref, HirId ty_ref, bool is_method,
+ FnType (HirId ref, HirId ty_ref, std::string identifier, bool is_method,
std::vector<std::pair<HIR::Pattern *, BaseType *> > params,
BaseType *type, std::vector<SubstitutionParamMapping> subst_refs,
std::set<HirId> refs = std::set<HirId> ())
: BaseType (ref, ty_ref, TypeKind::FNDEF, refs),
SubstitutionRef (std::move (subst_refs),
SubstitutionArgumentMappings::error ()),
- params (params), type (type), is_method_flag (is_method)
+ params (params), type (type), is_method_flag (is_method),
+ identifier (identifier)
{}
void accept_vis (TyVisitor &vis) override;
@@ -881,6 +883,8 @@ public:
std::string get_name () const override final { return as_string (); }
+ std::string get_identifier () const { return identifier; }
+
BaseType *unify (BaseType *other) override;
bool can_eq (BaseType *other) override;
@@ -947,6 +951,7 @@ private:
std::vector<std::pair<HIR::Pattern *, BaseType *> > params;
BaseType *type;
bool is_method_flag;
+ std::string identifier;
};
class FnPtr : public BaseType