diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-06-16 16:50:03 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-16 16:50:03 +0000 |
commit | 350b0e595144cf7c6cf70807b429d87077173415 (patch) | |
tree | eb920e6388e9d782bab2efc195f9c15e6edab20b /gcc/rust/backend | |
parent | 59f09fd5a48046ceba064bde2f230386fbc3700f (diff) | |
parent | 9d9ba03360721158e2000f19f6f65896f5af88b0 (diff) | |
download | gcc-350b0e595144cf7c6cf70807b429d87077173415.zip gcc-350b0e595144cf7c6cf70807b429d87077173415.tar.gz gcc-350b0e595144cf7c6cf70807b429d87077173415.tar.bz2 |
Merge #495
495: HIR cleanup r=philberty a=philberty
The HIR implementation has been bootstrapped from the AST, this has lead to a lot of missed desugaring. This PR removes TraitImpls and refactors the InerhentImpls to be an ImplBlock. The class hierarchy has been simplified in tandem here such that all impl items are of the same base class.
More cleanup is required but this is an isolated change that can go in now.
Co-authored-by: Philip Herron <philip.herron@embecosm.com>
Diffstat (limited to 'gcc/rust/backend')
-rw-r--r-- | gcc/rust/backend/rust-compile-base.h | 5 | ||||
-rw-r--r-- | gcc/rust/backend/rust-compile-implitem.h | 13 | ||||
-rw-r--r-- | gcc/rust/backend/rust-compile-item.h | 18 | ||||
-rw-r--r-- | gcc/rust/backend/rust-compile-resolve-path.cc | 5 | ||||
-rw-r--r-- | gcc/rust/backend/rust-compile.cc | 5 |
5 files changed, 9 insertions, 37 deletions
diff --git a/gcc/rust/backend/rust-compile-base.h b/gcc/rust/backend/rust-compile-base.h index b071a30..232d5b9 100644 --- a/gcc/rust/backend/rust-compile-base.h +++ b/gcc/rust/backend/rust-compile-base.h @@ -147,9 +147,8 @@ public: virtual void visit (HIR::TraitItemConst &item) {} virtual void visit (HIR::TraitItemType &item) {} virtual void visit (HIR::Trait &trait) {} - virtual void visit (HIR::InherentImpl &impl) {} - virtual void visit (HIR::TraitImpl &impl) {} - // virtual void visit(ExternalItem& item) {} + virtual void visit (HIR::ImplBlock &impl) {} + virtual void visit (HIR::ExternalStaticItem &item) {} virtual void visit (HIR::ExternalFunctionItem &item) {} virtual void visit (HIR::ExternBlock &block) {} diff --git a/gcc/rust/backend/rust-compile-implitem.h b/gcc/rust/backend/rust-compile-implitem.h index a4fb6d1..d6698d1 100644 --- a/gcc/rust/backend/rust-compile-implitem.h +++ b/gcc/rust/backend/rust-compile-implitem.h @@ -34,17 +34,8 @@ class CompileInherentImplItem : public HIRCompileBase using Rust::Compile::HIRCompileBase::visit; public: - static void Compile (TyTy::BaseType *self, HIR::InherentImplItem *item, - Context *ctx, bool compile_fns, - TyTy::BaseType *concrete = nullptr) - { - CompileInherentImplItem compiler (self, ctx, compile_fns, concrete); - item->accept_vis (compiler); - } - - static void Compile (TyTy::BaseType *self, HIR::TraitImplItem *item, - Context *ctx, bool compile_fns, - TyTy::BaseType *concrete = nullptr) + static void Compile (TyTy::BaseType *self, HIR::ImplItem *item, Context *ctx, + bool compile_fns, TyTy::BaseType *concrete = nullptr) { CompileInherentImplItem compiler (self, ctx, compile_fns, concrete); item->accept_vis (compiler); diff --git a/gcc/rust/backend/rust-compile-item.h b/gcc/rust/backend/rust-compile-item.h index e681652..8a521e7 100644 --- a/gcc/rust/backend/rust-compile-item.h +++ b/gcc/rust/backend/rust-compile-item.h @@ -274,23 +274,7 @@ public: ctx->push_function (fndecl); } - void visit (HIR::InherentImpl &impl_block) override - { - TyTy::BaseType *self_lookup = nullptr; - if (!ctx->get_tyctx ()->lookup_type ( - impl_block.get_type ()->get_mappings ().get_hirid (), &self_lookup)) - { - rust_error_at (impl_block.get_locus (), - "failed to resolve type of impl"); - return; - } - - for (auto &impl_item : impl_block.get_impl_items ()) - CompileInherentImplItem::Compile (self_lookup, impl_item.get (), ctx, - compile_fns); - } - - void visit (HIR::TraitImpl &impl_block) override + void visit (HIR::ImplBlock &impl_block) override { TyTy::BaseType *self_lookup = nullptr; if (!ctx->get_tyctx ()->lookup_type ( diff --git a/gcc/rust/backend/rust-compile-resolve-path.cc b/gcc/rust/backend/rust-compile-resolve-path.cc index 90c4eeb..cb1cfcf 100644 --- a/gcc/rust/backend/rust-compile-resolve-path.cc +++ b/gcc/rust/backend/rust-compile-resolve-path.cc @@ -91,7 +91,7 @@ ResolvePathRef::visit (HIR::PathInExpression &expr) else { HirId parent_impl_id = UNKNOWN_HIRID; - HIR::InherentImplItem *resolved_item + HIR::ImplItem *resolved_item = ctx->get_mappings ()->lookup_hir_implitem ( expr.get_mappings ().get_crate_num (), ref, &parent_impl_id); if (resolved_item != nullptr) @@ -100,8 +100,7 @@ ResolvePathRef::visit (HIR::PathInExpression &expr) HIR::Item *impl_ref = ctx->get_mappings ()->lookup_hir_item ( expr.get_mappings ().get_crate_num (), parent_impl_id); rust_assert (impl_ref != nullptr); - HIR::InherentImpl *impl - = static_cast<HIR::InherentImpl *> (impl_ref); + HIR::ImplBlock *impl = static_cast<HIR::ImplBlock *> (impl_ref); TyTy::BaseType *self = nullptr; bool ok = ctx->get_tyctx ()->lookup_type ( diff --git a/gcc/rust/backend/rust-compile.cc b/gcc/rust/backend/rust-compile.cc index ea21ad3..77036b2 100644 --- a/gcc/rust/backend/rust-compile.cc +++ b/gcc/rust/backend/rust-compile.cc @@ -137,9 +137,8 @@ CompileExpr::visit (HIR::MethodCallExpr &expr) { // this might fail because its a forward decl so we can attempt to // resolve it now - HIR::InherentImplItem *resolved_item - = ctx->get_mappings ()->lookup_hir_implitem ( - expr.get_mappings ().get_crate_num (), ref, nullptr); + HIR::ImplItem *resolved_item = ctx->get_mappings ()->lookup_hir_implitem ( + expr.get_mappings ().get_crate_num (), ref, nullptr); if (resolved_item == nullptr) { rust_error_at (expr.get_locus (), "failed to lookup forward decl"); |