aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/backend/rust-compile-expr.cc
diff options
context:
space:
mode:
authorPhilip Herron <herron.philip@googlemail.com>2023-03-13 21:43:27 +0000
committerArthur Cohen <arthur.cohen@embecosm.com>2024-01-16 18:21:12 +0100
commitac01179b4711efd702a9582fc142f584f660f588 (patch)
treeef1977cd7deaefbd2bf4d83b4c6a288c4cac33e8 /gcc/rust/backend/rust-compile-expr.cc
parentb134f7d50d7312a5cbc3c424c0b8c6c73b3b6028 (diff)
downloadgcc-ac01179b4711efd702a9582fc142f584f660f588.zip
gcc-ac01179b4711efd702a9582fc142f584f660f588.tar.gz
gcc-ac01179b4711efd702a9582fc142f584f660f588.tar.bz2
gccrs: cleanup resolve method address code generation
gcc/rust/ChangeLog: * backend/rust-compile-expr.cc (CompileExpr::resolve_method_address): remove unused code Signed-off-by: Philip Herron <herron.philip@googlemail.com>
Diffstat (limited to 'gcc/rust/backend/rust-compile-expr.cc')
-rw-r--r--gcc/rust/backend/rust-compile-expr.cc52
1 files changed, 20 insertions, 32 deletions
diff --git a/gcc/rust/backend/rust-compile-expr.cc b/gcc/rust/backend/rust-compile-expr.cc
index 8a0eadc..e138e41 100644
--- a/gcc/rust/backend/rust-compile-expr.cc
+++ b/gcc/rust/backend/rust-compile-expr.cc
@@ -1924,13 +1924,6 @@ CompileExpr::resolve_method_address (TyTy::FnType *fntype, HirId ref,
Analysis::NodeMapping expr_mappings,
Location expr_locus)
{
- // lookup compiled functions since it may have already been compiled
- tree fn = NULL_TREE;
- if (ctx->lookup_function_decl (fntype->get_ty_ref (), &fn))
- {
- return address_expression (fn, expr_locus);
- }
-
// Now we can try and resolve the address since this might be a forward
// declared function, generic function which has not be compiled yet or
// its an not yet trait bound function
@@ -1983,35 +1976,30 @@ CompileExpr::resolve_method_address (TyTy::FnType *fntype, HirId ref,
return CompileTraitItem::Compile (trait_item_ref->get_hir_trait_item (),
ctx, fntype, true, expr_locus);
}
- else
- {
- // FIXME this will be a case to return error_mark_node, there is
- // an error scenario where a Trait Foo has a method Bar, but this
- // receiver does not implement this trait or has an incompatible
- // implementation and we should just return error_mark_node
- rust_assert (candidates.size () == 1);
- auto &candidate = *candidates.begin ();
- rust_assert (candidate.is_impl_candidate ());
- rust_assert (candidate.ty->get_kind () == TyTy::TypeKind::FNDEF);
- TyTy::FnType *candidate_call = static_cast<TyTy::FnType *> (candidate.ty);
+ // FIXME this will be a case to return error_mark_node, there is
+ // an error scenario where a Trait Foo has a method Bar, but this
+ // receiver does not implement this trait or has an incompatible
+ // implementation and we should just return error_mark_node
- HIR::ImplItem *impl_item = candidate.item.impl.impl_item;
- if (!candidate_call->has_subsititions_defined ())
- return CompileInherentImplItem::Compile (impl_item, ctx);
+ rust_assert (candidates.size () == 1);
+ auto &candidate = *candidates.begin ();
+ rust_assert (candidate.is_impl_candidate ());
+ rust_assert (candidate.ty->get_kind () == TyTy::TypeKind::FNDEF);
+ TyTy::FnType *candidate_call = static_cast<TyTy::FnType *> (candidate.ty);
+ HIR::ImplItem *impl_item = candidate.item.impl.impl_item;
- TyTy::BaseType *monomorphized = candidate_call;
- if (candidate_call->needs_generic_substitutions ())
- {
- TyTy::BaseType *infer_impl_call
- = candidate_call->infer_substitions (expr_locus);
- monomorphized
- = Resolver::unify_site (ref, TyTy::TyWithLocation (infer_impl_call),
- TyTy::TyWithLocation (fntype), expr_locus);
- }
-
- return CompileInherentImplItem::Compile (impl_item, ctx, monomorphized);
+ TyTy::BaseType *monomorphized = candidate_call;
+ if (candidate_call->needs_generic_substitutions ())
+ {
+ TyTy::BaseType *infer_impl_call
+ = candidate_call->infer_substitions (expr_locus);
+ monomorphized
+ = Resolver::unify_site (ref, TyTy::TyWithLocation (infer_impl_call),
+ TyTy::TyWithLocation (fntype), expr_locus);
}
+
+ return CompileInherentImplItem::Compile (impl_item, ctx, monomorphized);
}
tree