Skip to content

Commit

Permalink
Use name resolver 2.0 in CompileTraitItem
Browse files Browse the repository at this point in the history
gcc/rust/ChangeLog:

	* backend/rust-compile-implitem.cc
	(CompileTraitItem::visit): Use name resolver 2.0 (when enabled)
	to obtain canonical paths for instances of TraitItemConst and
	TraitItemFunc.

Signed-off-by: Owen Avery <[email protected]>
  • Loading branch information
powerboat9 authored and CohenArthur committed Oct 28, 2024
1 parent f9f690f commit 98f04ec
Showing 1 changed file with 32 additions and 4 deletions.
36 changes: 32 additions & 4 deletions gcc/rust/backend/rust-compile-implitem.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,22 @@ CompileTraitItem::visit (HIR::TraitItemConst &constant)
rust_assert (concrete != nullptr);
TyTy::BaseType *resolved_type = concrete;

auto canonical_path = ctx->get_mappings ().lookup_canonical_path (
constant.get_mappings ().get_nodeid ());
tl::optional<Resolver::CanonicalPath> canonical_path;
if (flag_name_resolution_2_0)
{
auto &nr_ctx
= Resolver2_0::ImmutableNameResolutionContext::get ().resolver ();

canonical_path = nr_ctx.values.to_canonical_path (
constant.get_mappings ().get_nodeid ());
}
else
{
canonical_path = ctx->get_mappings ().lookup_canonical_path (
constant.get_mappings ().get_nodeid ());
}

rust_assert (canonical_path);

HIR::Expr *const_value_expr = constant.get_expr ().get ();
tree const_expr
Expand Down Expand Up @@ -75,8 +89,22 @@ CompileTraitItem::visit (HIR::TraitItemFunc &func)
fntype->override_context ();
}

auto canonical_path = ctx->get_mappings ().lookup_canonical_path (
func.get_mappings ().get_nodeid ());
tl::optional<Resolver::CanonicalPath> canonical_path;
if (flag_name_resolution_2_0)
{
auto &nr_ctx
= Resolver2_0::ImmutableNameResolutionContext::get ().resolver ();

canonical_path
= nr_ctx.values.to_canonical_path (func.get_mappings ().get_nodeid ());
}
else
{
canonical_path = ctx->get_mappings ().lookup_canonical_path (
func.get_mappings ().get_nodeid ());
}

rust_assert (canonical_path);

// FIXME: How do we get the proper visibility here?
auto vis = HIR::Visibility (HIR::Visibility::VisType::PUBLIC);
Expand Down

0 comments on commit 98f04ec

Please sign in to comment.