aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/backend
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/rust/backend')
-rw-r--r--gcc/rust/backend/rust-compile-context.h7
-rw-r--r--gcc/rust/backend/rust-compile-implitem.h8
-rw-r--r--gcc/rust/backend/rust-compile-resolve-path.cc49
3 files changed, 37 insertions, 27 deletions
diff --git a/gcc/rust/backend/rust-compile-context.h b/gcc/rust/backend/rust-compile-context.h
index 8a3d413..6356ccc 100644
--- a/gcc/rust/backend/rust-compile-context.h
+++ b/gcc/rust/backend/rust-compile-context.h
@@ -336,10 +336,13 @@ public:
void visit (TyTy::InferType &) override { gcc_unreachable (); }
- void visit (TyTy::PlaceholderType &) override { gcc_unreachable (); }
-
void visit (TyTy::ProjectionType &) override { gcc_unreachable (); }
+ void visit (TyTy::PlaceholderType &type) override
+ {
+ type.resolve ()->accept_vis (*this);
+ }
+
void visit (TyTy::ParamType &param) override
{
param.resolve ()->accept_vis (*this);
diff --git a/gcc/rust/backend/rust-compile-implitem.h b/gcc/rust/backend/rust-compile-implitem.h
index e446cf9..809cf56 100644
--- a/gcc/rust/backend/rust-compile-implitem.h
+++ b/gcc/rust/backend/rust-compile-implitem.h
@@ -319,15 +319,17 @@ public:
// items can be forward compiled which means we may not need to invoke this
// code. We might also have already compiled this generic function as well.
Bfunction *lookup = nullptr;
- if (ctx->lookup_function_decl (fntype->get_ty_ref (), &lookup, fntype))
+ if (ctx->lookup_function_decl (fntype->get_ty_ref (), &lookup))
{
// has this been added to the list then it must be finished
if (ctx->function_completed (lookup))
{
Bfunction *dummy = nullptr;
if (!ctx->lookup_function_decl (fntype->get_ty_ref (), &dummy))
- ctx->insert_function_decl (fntype->get_ty_ref (), lookup, fntype);
-
+ {
+ ctx->insert_function_decl (fntype->get_ty_ref (), lookup,
+ fntype);
+ }
return;
}
}
diff --git a/gcc/rust/backend/rust-compile-resolve-path.cc b/gcc/rust/backend/rust-compile-resolve-path.cc
index 97ba15d..1b892d2 100644
--- a/gcc/rust/backend/rust-compile-resolve-path.cc
+++ b/gcc/rust/backend/rust-compile-resolve-path.cc
@@ -76,6 +76,7 @@ ResolvePathRef::visit (HIR::PathInExpression &expr)
&lookup);
rust_assert (ok);
rust_assert (lookup->get_kind () == TyTy::TypeKind::FNDEF);
+ TyTy::FnType *fntype = static_cast<TyTy::FnType *> (lookup);
Bfunction *fn = nullptr;
if (!ctx->lookup_function_decl (lookup->get_ty_ref (), &fn))
@@ -145,28 +146,32 @@ ResolvePathRef::visit (HIR::PathInExpression &expr)
rust_assert (
trait_item_ref->is_optional ()); // has definition
- // FIXME
- // TyTy::BaseType *self_type = nullptr;
- // if (!ctx->get_tyctx ()->lookup_type (
- // expr.get_receiver ()->get_mappings ().get_hirid (),
- // &self_type))
- // {
- // rust_error_at (expr.get_locus (),
- // "failed to resolve type for self param");
- // return;
- // }
-
- // CompileTraitItem::Compile (
- // self_type, trait_item_ref->get_hir_trait_item (), ctx,
- // fntype);
- // if (!ctx->lookup_function_decl (fntype->get_ty_ref (),
- // &fn))
- // {
- // translated = ctx->get_backend ()->error_expression ();
- // rust_error_at (expr.get_locus (),
- // "forward declaration was not compiled");
- // return;
- // }
+ Analysis::NodeMapping trait_mappings
+ = trait_item_ref->get_parent_trait_mappings ();
+ auto associated_impl_id
+ = ctx->get_tyctx ()
+ ->lookup_associated_impl_mapping_for_self (
+ trait_mappings.get_hirid (), receiver);
+ rust_assert (associated_impl_id != UNKNOWN_HIRID);
+
+ Resolver::AssociatedImplTrait *associated = nullptr;
+ bool found_associated_trait_impl
+ = ctx->get_tyctx ()->lookup_associated_trait_impl (
+ associated_impl_id, &associated);
+ rust_assert (found_associated_trait_impl);
+ associated->setup_associated_types ();
+
+ CompileTraitItem::Compile (
+ receiver, trait_item_ref->get_hir_trait_item (), ctx,
+ fntype);
+
+ if (!ctx->lookup_function_decl (fntype->get_ty_ref (), &fn))
+ {
+ resolved = ctx->get_backend ()->error_expression ();
+ rust_error_at (expr.get_locus (),
+ "forward declaration was not compiled");
+ return;
+ }
}
else
{