]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: cleanup resolve method address code generation
authorPhilip Herron <herron.philip@googlemail.com>
Mon, 13 Mar 2023 21:43:27 +0000 (21:43 +0000)
committerArthur Cohen <arthur.cohen@embecosm.com>
Tue, 16 Jan 2024 17:21:12 +0000 (18:21 +0100)
gcc/rust/ChangeLog:

* backend/rust-compile-expr.cc (CompileExpr::resolve_method_address): remove unused code

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
gcc/rust/backend/rust-compile-expr.cc

index 8a0eadc8a02efaa27a7165ec81c489e5204b0700..e138e41e5593b3ffab00849bbc1764b00e5b1b30 100644 (file)
@@ -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