Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Insert static items into the value namespace #3194

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions gcc/rust/backend/rust-compile-item.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 ();
Expand Down
3 changes: 3 additions & 0 deletions gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,9 @@ TopLevel::visit (AST::StaticItem &static_item)
= [this, &static_item] () { static_item.get_expr ().accept_vis (*this); };

ctx.scoped (Rib::Kind::Item, static_item.get_node_id (), sub_vis);

insert_or_error_out (static_item.get_identifier ().as_string (), static_item,
Namespace::Values);
}

void
Expand Down
2 changes: 0 additions & 2 deletions gcc/testsuite/rust/compile/nr2/exclude
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,6 @@ issue-2139.rs
issue-2142.rs
issue-2165.rs
issue-2166.rs
issue-2178.rs
issue-2188.rs
issue-2190-1.rs
issue-2190-2.rs
issue-2195.rs
Expand Down
Loading