diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-07-15 21:05:42 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-15 21:05:42 +0000 |
commit | 41a6819f7f66363e7aa043fab1829f0bc0c3888c (patch) | |
tree | d32de459923c7b0d04c2049731188e42b9362b7d /gcc | |
parent | b322f221ce0564b082ba011e570f76c318d013a4 (diff) | |
parent | ea04a9ff1d0ed60332298ee07d94c1c73384b21f (diff) | |
download | gcc-41a6819f7f66363e7aa043fab1829f0bc0c3888c.zip gcc-41a6819f7f66363e7aa043fab1829f0bc0c3888c.tar.gz gcc-41a6819f7f66363e7aa043fab1829f0bc0c3888c.tar.bz2 |
Merge #568
568: Add missing DefId mappings r=philberty a=philberty
DefIds need to be managed for fntypes which will help in the compilation
of optional traitt functions
Co-authored-by: Philip Herron <philip.herron@embecosm.com>
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/rust/hir/rust-ast-lower-implitem.h | 24 | ||||
-rw-r--r-- | gcc/rust/hir/rust-ast-lower-stmt.h | 2 | ||||
-rw-r--r-- | gcc/rust/typecheck/rust-hir-type-check-implitem.h | 1 | ||||
-rw-r--r-- | gcc/rust/typecheck/rust-hir-type-check-stmt.h | 1 | ||||
-rw-r--r-- | gcc/rust/typecheck/rust-hir-type-check-toplevel.h | 1 | ||||
-rw-r--r-- | gcc/rust/typecheck/rust-hir-type-check.cc | 1 | ||||
-rw-r--r-- | gcc/rust/typecheck/rust-tyty.cc | 2 | ||||
-rw-r--r-- | gcc/rust/typecheck/rust-tyty.h | 22 |
8 files changed, 36 insertions, 18 deletions
diff --git a/gcc/rust/hir/rust-ast-lower-implitem.h b/gcc/rust/hir/rust-ast-lower-implitem.h index b08a166..6e4c0b1 100644 --- a/gcc/rust/hir/rust-ast-lower-implitem.h +++ b/gcc/rust/hir/rust-ast-lower-implitem.h @@ -70,13 +70,14 @@ public: mappings->get_next_hir_id (crate_num), mappings->get_next_localdef_id (crate_num)); - translated = new HIR::TypeAlias (mapping, alias.get_new_type_name (), - std::move (generic_params), - std::move (where_clause), - std::unique_ptr<HIR::Type> (existing_type), - std::move (vis), alias.get_outer_attrs (), - alias.get_locus ()); + auto type_alias = new HIR::TypeAlias ( + mapping, alias.get_new_type_name (), std::move (generic_params), + std::move (where_clause), std::unique_ptr<HIR::Type> (existing_type), + std::move (vis), alias.get_outer_attrs (), alias.get_locus ()); + translated = type_alias; + + mappings->insert_defid_mapping (mapping.get_defid (), type_alias); mappings->insert_hir_implitem (mapping.get_crate_num (), mapping.get_hirid (), parent_impl_id, translated); @@ -104,6 +105,7 @@ public: constant.get_locus ()); translated = translated_constant; + mappings->insert_defid_mapping (mapping.get_defid (), translated_constant); mappings->insert_hir_implitem (mapping.get_crate_num (), mapping.get_hirid (), parent_impl_id, translated); @@ -177,6 +179,7 @@ public: std::move (vis), function.get_outer_attrs (), HIR::SelfParam::error (), locus); + mappings->insert_defid_mapping (mapping.get_defid (), fn); mappings->insert_hir_implitem (mapping.get_crate_num (), mapping.get_hirid (), parent_impl_id, fn); mappings->insert_location (crate_num, mapping.get_hirid (), @@ -257,6 +260,7 @@ public: std::move (vis), method.get_outer_attrs (), std::move (self_param), locus); + mappings->insert_defid_mapping (mapping.get_defid (), mth); mappings->insert_hir_implitem (mapping.get_crate_num (), mapping.get_hirid (), parent_impl_id, mth); mappings->insert_location (crate_num, mapping.get_hirid (), @@ -358,7 +362,7 @@ public: auto crate_num = mappings->get_current_crate (); Analysis::NodeMapping mapping (crate_num, func.get_node_id (), mappings->get_next_hir_id (crate_num), - UNKNOWN_LOCAL_DEFID); + mappings->get_next_localdef_id (crate_num)); translated = new HIR::TraitItemFunc (mapping, std::move (decl), @@ -422,7 +426,7 @@ public: auto crate_num = mappings->get_current_crate (); Analysis::NodeMapping mapping (crate_num, method.get_node_id (), mappings->get_next_hir_id (crate_num), - UNKNOWN_LOCAL_DEFID); + mappings->get_next_localdef_id (crate_num)); translated = new HIR::TraitItemFunc (mapping, std::move (decl), @@ -441,7 +445,7 @@ public: auto crate_num = mappings->get_current_crate (); Analysis::NodeMapping mapping (crate_num, constant.get_node_id (), mappings->get_next_hir_id (crate_num), - UNKNOWN_LOCAL_DEFID); + mappings->get_next_localdef_id (crate_num)); translated = new HIR::TraitItemConst (mapping, constant.get_identifier (), std::unique_ptr<HIR::Type> (type), @@ -457,7 +461,7 @@ public: auto crate_num = mappings->get_current_crate (); Analysis::NodeMapping mapping (crate_num, type.get_node_id (), mappings->get_next_hir_id (crate_num), - UNKNOWN_LOCAL_DEFID); + mappings->get_next_localdef_id (crate_num)); translated = new HIR::TraitItemType (mapping, type.get_identifier (), diff --git a/gcc/rust/hir/rust-ast-lower-stmt.h b/gcc/rust/hir/rust-ast-lower-stmt.h index 771c3ad..9df6b74 100644 --- a/gcc/rust/hir/rust-ast-lower-stmt.h +++ b/gcc/rust/hir/rust-ast-lower-stmt.h @@ -283,7 +283,7 @@ public: auto crate_num = mappings->get_current_crate (); Analysis::NodeMapping mapping (crate_num, function.get_node_id (), mappings->get_next_hir_id (crate_num), - UNKNOWN_LOCAL_DEFID); + mappings->get_next_localdef_id (crate_num)); mappings->insert_location (crate_num, function_body->get_mappings ().get_hirid (), diff --git a/gcc/rust/typecheck/rust-hir-type-check-implitem.h b/gcc/rust/typecheck/rust-hir-type-check-implitem.h index d6c3aed..5f6fcd9 100644 --- a/gcc/rust/typecheck/rust-hir-type-check-implitem.h +++ b/gcc/rust/typecheck/rust-hir-type-check-implitem.h @@ -135,6 +135,7 @@ public: } auto fnType = new TyTy::FnType (function.get_mappings ().get_hirid (), + function.get_mappings ().get_defid (), function.get_function_name (), function.is_method (), std::move (params), ret_type, std::move (substitutions)); diff --git a/gcc/rust/typecheck/rust-hir-type-check-stmt.h b/gcc/rust/typecheck/rust-hir-type-check-stmt.h index 3655d96..ba821ca 100644 --- a/gcc/rust/typecheck/rust-hir-type-check-stmt.h +++ b/gcc/rust/typecheck/rust-hir-type-check-stmt.h @@ -276,6 +276,7 @@ public: } auto fnType = new TyTy::FnType (function.get_mappings ().get_hirid (), + function.get_mappings ().get_defid (), function.get_function_name (), false, std::move (params), ret_type, std::move (substitutions)); diff --git a/gcc/rust/typecheck/rust-hir-type-check-toplevel.h b/gcc/rust/typecheck/rust-hir-type-check-toplevel.h index 45bf6f3..dd3dd75 100644 --- a/gcc/rust/typecheck/rust-hir-type-check-toplevel.h +++ b/gcc/rust/typecheck/rust-hir-type-check-toplevel.h @@ -229,6 +229,7 @@ public: } auto fnType = new TyTy::FnType (function.get_mappings ().get_hirid (), + function.get_mappings ().get_defid (), function.get_function_name (), false, std::move (params), ret_type, std::move (substitutions)); diff --git a/gcc/rust/typecheck/rust-hir-type-check.cc b/gcc/rust/typecheck/rust-hir-type-check.cc index acfc022..cb2896c 100644 --- a/gcc/rust/typecheck/rust-hir-type-check.cc +++ b/gcc/rust/typecheck/rust-hir-type-check.cc @@ -498,6 +498,7 @@ TraitItemReference::get_type_from_fn (/*const*/ HIR::TraitItemFunc &fn) const } return new TyTy::FnType (fn.get_mappings ().get_hirid (), + fn.get_mappings ().get_defid (), function.get_function_name (), function.is_method (), std::move (params), ret_type, substitutions); } diff --git a/gcc/rust/typecheck/rust-tyty.cc b/gcc/rust/typecheck/rust-tyty.cc index ba98212..ab47310 100644 --- a/gcc/rust/typecheck/rust-tyty.cc +++ b/gcc/rust/typecheck/rust-tyty.cc @@ -715,7 +715,7 @@ FnType::clone () cloned_params.push_back ( std::pair<HIR::Pattern *, BaseType *> (p.first, p.second->clone ())); - return new FnType (get_ref (), get_ty_ref (), get_identifier (), + return new FnType (get_ref (), get_ty_ref (), get_id (), get_identifier (), is_method_flag, std::move (cloned_params), get_return_type ()->clone (), clone_substs (), get_combined_refs ()); diff --git a/gcc/rust/typecheck/rust-tyty.h b/gcc/rust/typecheck/rust-tyty.h index d85b8a8..e2f1595 100644 --- a/gcc/rust/typecheck/rust-tyty.h +++ b/gcc/rust/typecheck/rust-tyty.h @@ -929,7 +929,7 @@ private: class FnType : public BaseType, public SubstitutionRef { public: - FnType (HirId ref, std::string identifier, bool is_method, + FnType (HirId ref, DefId id, 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> ()) @@ -937,10 +937,14 @@ public: SubstitutionRef (std::move (subst_refs), SubstitutionArgumentMappings::error ()), params (std::move (params)), type (type), is_method_flag (is_method), - identifier (identifier) - {} + identifier (identifier), id (id) + { + LocalDefId local_def_id = id & DEF_ID_LOCAL_DEF_MASK; + rust_assert (local_def_id != UNKNOWN_LOCAL_DEFID); + } - FnType (HirId ref, HirId ty_ref, std::string identifier, bool is_method, + FnType (HirId ref, HirId ty_ref, DefId id, 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> ()) @@ -948,8 +952,11 @@ public: SubstitutionRef (std::move (subst_refs), SubstitutionArgumentMappings::error ()), params (params), type (type), is_method_flag (is_method), - identifier (identifier) - {} + identifier (identifier), id (id) + { + LocalDefId local_def_id = id & DEF_ID_LOCAL_DEF_MASK; + rust_assert (local_def_id != UNKNOWN_LOCAL_DEFID); + } void accept_vis (TyVisitor &vis) override; @@ -974,6 +981,8 @@ public: return is_method_flag; } + DefId get_id () const { return id; } + // get the Self type for the method BaseType *get_self_type () const { @@ -1026,6 +1035,7 @@ private: BaseType *type; bool is_method_flag; std::string identifier; + DefId id; }; class FnPtr : public BaseType |