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

Use name resolver 2.0 in VisibilityResolver #3239

Merged
merged 1 commit into from
Nov 5, 2024
Merged
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
21 changes: 20 additions & 1 deletion gcc/rust/checks/errors/privacy/rust-visibility-resolver.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
#include "rust-ast.h"
#include "rust-hir.h"
#include "rust-hir-item.h"
#include "rust-immutable-name-resolution-context.h"

// for flag_name_resolution_2_0
#include "options.h"

namespace Rust {
namespace Privacy {
Expand Down Expand Up @@ -61,7 +65,22 @@ VisibilityResolver::resolve_module_path (const HIR::SimplePath &restriction,
"cannot use non-module path as privacy restrictor");

NodeId ref_node_id = UNKNOWN_NODEID;
if (!resolver.lookup_resolved_name (ast_node_id, &ref_node_id))
if (flag_name_resolution_2_0)
{
auto &nr_ctx
= Resolver2_0::ImmutableNameResolutionContext::get ().resolver ();

if (auto id = nr_ctx.lookup (ast_node_id))
{
ref_node_id = *id;
}
else
{
invalid_path.emit ();
return false;
}
}
else if (!resolver.lookup_resolved_name (ast_node_id, &ref_node_id))
{
invalid_path.emit ();
return false;
Expand Down
Loading