diff options
author | Owen Avery <powerboat9.gamer@gmail.com> | 2024-10-26 19:53:42 -0400 |
---|---|---|
committer | Arthur Cohen <arthur.cohen@embecosm.com> | 2025-03-21 12:32:54 +0100 |
commit | f86a35bb1729ada851ab8b79a3fcee8b091976f9 (patch) | |
tree | 6f7ddd05d89769f42a82047a46d9e3fd3dfb83da /gcc/rust/backend/rust-compile-implitem.cc | |
parent | a36220b6d31f68569c0c0de82ae5b6acfcd51a4a (diff) | |
download | gcc-f86a35bb1729ada851ab8b79a3fcee8b091976f9.zip gcc-f86a35bb1729ada851ab8b79a3fcee8b091976f9.tar.gz gcc-f86a35bb1729ada851ab8b79a3fcee8b091976f9.tar.bz2 |
gccrs: Use name resolver 2.0 in CompileTraitItem
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 <powerboat9.gamer@gmail.com>
Diffstat (limited to 'gcc/rust/backend/rust-compile-implitem.cc')
-rw-r--r-- | gcc/rust/backend/rust-compile-implitem.cc | 36 |
1 files changed, 32 insertions, 4 deletions
diff --git a/gcc/rust/backend/rust-compile-implitem.cc b/gcc/rust/backend/rust-compile-implitem.cc index 4c7d8e8..98337c8f 100644 --- a/gcc/rust/backend/rust-compile-implitem.cc +++ b/gcc/rust/backend/rust-compile-implitem.cc @@ -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 @@ -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); |