diff options
author | Owen Avery <powerboat9.gamer@gmail.com> | 2024-10-11 01:24:14 -0400 |
---|---|---|
committer | Arthur Cohen <arthur.cohen@embecosm.com> | 2025-03-19 15:32:17 +0100 |
commit | 0d88e726aa017db639fa8848d7ec5be2ecc13507 (patch) | |
tree | 95ceca5a2e742c30de3256b4bf1647800df18e9b /gcc/rust/backend | |
parent | b7f03bbd20d6aab28b85b8edb645ff20badd6d10 (diff) | |
download | gcc-0d88e726aa017db639fa8848d7ec5be2ecc13507.zip gcc-0d88e726aa017db639fa8848d7ec5be2ecc13507.tar.gz gcc-0d88e726aa017db639fa8848d7ec5be2ecc13507.tar.bz2 |
gccrs: Insert static items into the value namespace
gcc/rust/ChangeLog:
* backend/rust-compile-item.cc
(CompileItem::visit): Check canonical path of StaticItem
properly when name resolution 2.0 is enabled.
* resolve/rust-toplevel-name-resolver-2.0.cc
(TopLevel::visit): Insert static items into the value namespace.
gcc/testsuite/ChangeLog:
* rust/compile/nr2/exclude: Remove entries.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
Diffstat (limited to 'gcc/rust/backend')
-rw-r--r-- | gcc/rust/backend/rust-compile-item.cc | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/gcc/rust/backend/rust-compile-item.cc b/gcc/rust/backend/rust-compile-item.cc index c0cac68..0878716 100644 --- a/gcc/rust/backend/rust-compile-item.cc +++ b/gcc/rust/backend/rust-compile-item.cc @@ -42,8 +42,23 @@ CompileItem::visit (HIR::StaticItem &var) tree type = TyTyResolveCompile::compile (ctx, resolved_type); - auto canonical_path = ctx->get_mappings ().lookup_canonical_path ( - var.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 (var.get_mappings ().get_nodeid ()); + } + else + { + canonical_path = ctx->get_mappings ().lookup_canonical_path ( + var.get_mappings ().get_nodeid ()); + } + + rust_assert (canonical_path.has_value ()); HIR::Expr *const_value_expr = var.get_expr ().get (); ctx->push_const_context (); |