diff options
author | Philip Herron <philip.herron@embecosm.com> | 2021-06-05 16:37:29 +0100 |
---|---|---|
committer | Philip Herron <philip.herron@embecosm.com> | 2021-06-05 16:40:19 +0100 |
commit | 1c0f8d6d2a22ce498ef3f1bfd60a3867a90c8130 (patch) | |
tree | 4ac87f4d6dc73a876525a3dc3c280283f9baa1ea /gcc/rust/backend/rust-compile-item.h | |
parent | 69b3e488803f684d9d956223a7f410d219cced24 (diff) | |
download | gcc-1c0f8d6d2a22ce498ef3f1bfd60a3867a90c8130.zip gcc-1c0f8d6d2a22ce498ef3f1bfd60a3867a90c8130.tar.gz gcc-1c0f8d6d2a22ce498ef3f1bfd60a3867a90c8130.tar.bz2 |
This is the initial building blocks for Traits
We can compile TraitImpls, since before we can actually start checking
trait obligations we need to be able to implement the trait first.
More desugaring is needed in HIR to make TraitImpls contain normal impl
items to avoid seperation in how impl blocks are handled.
Fixes #395 #472
Diffstat (limited to 'gcc/rust/backend/rust-compile-item.h')
-rw-r--r-- | gcc/rust/backend/rust-compile-item.h | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/gcc/rust/backend/rust-compile-item.h b/gcc/rust/backend/rust-compile-item.h index e3b6d0f..e681652 100644 --- a/gcc/rust/backend/rust-compile-item.h +++ b/gcc/rust/backend/rust-compile-item.h @@ -290,6 +290,22 @@ public: compile_fns); } + void visit (HIR::TraitImpl &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); + } + private: CompileItem (Context *ctx, bool compile_fns, TyTy::BaseType *concrete) : HIRCompileBase (ctx), compile_fns (compile_fns), concrete (concrete) |