}
tree
-HIRCompileBase::resolve_method_address (
- TyTy::FnType *fntype, HirId ref, TyTy::BaseType *receiver,
- const HIR::PathIdentSegment &segment,
- const Analysis::NodeMapping &expr_mappings, Location expr_locus)
+HIRCompileBase::resolve_method_address (TyTy::FnType *fntype,
+ TyTy::BaseType *receiver,
+ Location expr_locus)
{
+ DefId id = fntype->get_id ();
+ rust_assert (id != UNKNOWN_DEFID);
+
// 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
- HIR::ImplItem *resolved_item
- = ctx->get_mappings ()->lookup_hir_implitem (ref, nullptr);
+ HIR::Item *resolved_item = ctx->get_mappings ()->lookup_defid (id);
if (resolved_item != nullptr)
{
if (!fntype->has_subsititions_defined ())
- return CompileInherentImplItem::Compile (resolved_item, ctx);
+ return CompileItem::compile (resolved_item, ctx);
- return CompileInherentImplItem::Compile (resolved_item, ctx, fntype);
+ return CompileItem::compile (resolved_item, ctx, fntype);
}
// it might be resolved to a trait item
HIR::TraitItem *trait_item
- = ctx->get_mappings ()->lookup_hir_trait_item (ref);
+ = ctx->get_mappings ()->lookup_trait_item_defid (id);
HIR::Trait *trait = ctx->get_mappings ()->lookup_trait_item_mapping (
trait_item->get_mappings ().get_hirid ());
// item so its up to us to figure out if this path should resolve
// to an trait-impl-block-item or if it can be defaulted to the
// trait-impl-item's definition
-
+ const HIR::PathIdentSegment segment (trait_item->trait_identifier ());
auto root = receiver->get_root ();
auto candidates
= Resolver::PathProbeImplTrait::Probe (root, segment, trait_ref);
TyTy::BaseType *infer_impl_call
= candidate_call->infer_substitions (expr_locus);
monomorphized
- = Resolver::unify_site (ref, TyTy::TyWithLocation (infer_impl_call),
+ = Resolver::unify_site (fntype->get_ref (),
+ TyTy::TyWithLocation (infer_impl_call),
TyTy::TyWithLocation (fntype), expr_locus);
}
tree resolve_unsized_dyn_adjustment (Resolver::Adjustment &adjustment,
tree expression, Location locus);
- tree resolve_method_address (TyTy::FnType *fntype, HirId ref,
- TyTy::BaseType *receiver,
- const HIR::PathIdentSegment &segment,
- const Analysis::NodeMapping &expr_mappings,
+ tree resolve_method_address (TyTy::FnType *fntype, TyTy::BaseType *receiver,
Location expr_locus);
void compile_function_body (tree fndecl, HIR::BlockExpr &function_body,
// lookup compiled functions since it may have already been compiled
HIR::PathExprSegment method_name = expr.get_method_name ();
HIR::PathIdentSegment segment_name = method_name.get_segment ();
- fn_expr
- = resolve_method_address (fntype, ref, receiver, segment_name,
- expr.get_mappings (), expr.get_locus ());
+ fn_expr = resolve_method_address (fntype, receiver, expr.get_locus ());
}
// lookup the autoderef mappings
// lookup compiled functions since it may have already been compiled
HIR::PathIdentSegment segment_name (
Analysis::RustLangItem::ToString (lang_item_type));
- tree fn_expr
- = resolve_method_address (fntype, ref, receiver, segment_name,
- expr.get_mappings (), expr.get_locus ());
+ tree fn_expr = resolve_method_address (fntype, receiver, expr.get_locus ());
// lookup the autoderef mappings
std::vector<Resolver::Adjustment> *adjustments = nullptr;