From e4ea09d6b8e501dc7bd7046da641b70e02814b09 Mon Sep 17 00:00:00 2001 From: Philip Herron Date: Fri, 26 Mar 2021 15:23:57 +0000 Subject: Add Generic Impl block support This extends the support from #237 to extend this to MethodCallExpr, this now follows a similar path to normal CallExprs and ensures the used arguments in substitution are preserved during unification of types. Part of method resolution is fixed here by taking advantage if is_equal instead of unify calls which could result in bad errors which are just part of the probe process to lookup possible candidates for method resolution. Fixes #306 --- gcc/rust/backend/rust-compile-implitem.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'gcc/rust/backend/rust-compile-implitem.h') diff --git a/gcc/rust/backend/rust-compile-implitem.h b/gcc/rust/backend/rust-compile-implitem.h index 15aba9b..cee3a3b 100644 --- a/gcc/rust/backend/rust-compile-implitem.h +++ b/gcc/rust/backend/rust-compile-implitem.h @@ -272,6 +272,21 @@ public: } TyTy::FnType *fntype = static_cast (fntype_tyty); + if (fntype->has_subsititions_defined ()) + { + // we cant do anything for this only when it is used + if (concrete == nullptr) + return; + else + { + rust_assert (concrete->get_kind () == TyTy::TypeKind::FNDEF); + fntype = static_cast (concrete); + + // override the Hir Lookups for the substituions in this context + fntype->override_context (); + } + } + // convert to the actual function type ::Btype *compiled_fn_type = TyTyResolveCompile::compile (ctx, fntype); -- cgit v1.1