Skip to content

Commit

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

	* checks/errors/rust-hir-pattern-analysis.cc: Add includes.
	(PatternChecker::visit): Use name resolver 2.0 when enabled.

Signed-off-by: Owen Avery <[email protected]>
  • Loading branch information
powerboat9 authored and CohenArthur committed Oct 24, 2024
1 parent b7eb4b0 commit e7de54d
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion gcc/rust/checks/errors/rust-hir-pattern-analysis.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@
#include "rust-mapping-common.h"
#include "rust-system.h"
#include "rust-tyty.h"
#include "rust-immutable-name-resolution-context.h"

// for flag_name_resolution_2_0
#include "options.h"

namespace Rust {
namespace Analysis {
Expand Down Expand Up @@ -234,7 +238,17 @@ PatternChecker::visit (CallExpr &expr)

NodeId ast_node_id = expr.get_fnexpr ()->get_mappings ().get_nodeid ();
NodeId ref_node_id;
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
return;
}
else if (!resolver.lookup_resolved_name (ast_node_id, &ref_node_id))
return;

if (auto definition_id = mappings.lookup_node_to_hir (ref_node_id))
Expand Down

0 comments on commit e7de54d

Please sign in to comment.