aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/checks/errors
diff options
context:
space:
mode:
authorOwen Avery <powerboat9.gamer@gmail.com>2024-10-15 15:33:46 -0400
committerArthur Cohen <arthur.cohen@embecosm.com>2025-03-19 15:32:18 +0100
commit7e4a3039c2485b6d34b06f3f01d93f6ee1b892d8 (patch)
treee4d6930cfe8ad2636f4a506790e4e0a0d12d2bb5 /gcc/rust/checks/errors
parent48bde05f60025df1b565ad5b7f492ac4cf24f1ad (diff)
downloadgcc-7e4a3039c2485b6d34b06f3f01d93f6ee1b892d8.zip
gcc-7e4a3039c2485b6d34b06f3f01d93f6ee1b892d8.tar.gz
gcc-7e4a3039c2485b6d34b06f3f01d93f6ee1b892d8.tar.bz2
gccrs: Use name resolver 2.0 in const checker
gcc/rust/ChangeLog: * checks/errors/rust-const-checker.cc: Add includes. (ConstChecker::visit): Use name resolver 2.0 to lookup function definitions when name resolution 2.0 is enabled. gcc/testsuite/ChangeLog: * rust/compile/nr2/exclude: Remove entries. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
Diffstat (limited to 'gcc/rust/checks/errors')
-rw-r--r--gcc/rust/checks/errors/rust-const-checker.cc16
1 files changed, 15 insertions, 1 deletions
diff --git a/gcc/rust/checks/errors/rust-const-checker.cc b/gcc/rust/checks/errors/rust-const-checker.cc
index 2beee21..84c09dd 100644
--- a/gcc/rust/checks/errors/rust-const-checker.cc
+++ b/gcc/rust/checks/errors/rust-const-checker.cc
@@ -22,6 +22,10 @@
#include "rust-hir-stmt.h"
#include "rust-hir-item.h"
#include "rust-system.h"
+#include "rust-immutable-name-resolution-context.h"
+
+// for flag_name_resolution_2_0
+#include "options.h"
namespace Rust {
namespace HIR {
@@ -354,8 +358,18 @@ ConstChecker::visit (CallExpr &expr)
NodeId ast_node_id = expr.get_fnexpr ()->get_mappings ().get_nodeid ();
NodeId 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;
+ }
// We don't care about types here
- if (!resolver.lookup_resolved_name (ast_node_id, &ref_node_id))
+ 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))