diff options
author | Owen Avery <powerboat9.gamer@gmail.com> | 2024-10-15 15:33:46 -0400 |
---|---|---|
committer | CohenArthur <arthur.cohen@embecosm.com> | 2024-10-24 08:06:00 +0000 |
commit | 120b23495f5844e3b1a42f8f1c8b957325ceaec1 (patch) | |
tree | 42ebdc822ea46d94c99b21ac57e4e6d4d09c2fe4 | |
parent | bcc83c32a74b5bb3fd8c29a7ba15022d38c739e7 (diff) | |
download | gcc-120b23495f5844e3b1a42f8f1c8b957325ceaec1.zip gcc-120b23495f5844e3b1a42f8f1c8b957325ceaec1.tar.gz gcc-120b23495f5844e3b1a42f8f1c8b957325ceaec1.tar.bz2 |
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>
-rw-r--r-- | gcc/rust/checks/errors/rust-const-checker.cc | 16 | ||||
-rw-r--r-- | gcc/testsuite/rust/compile/nr2/exclude | 3 |
2 files changed, 15 insertions, 4 deletions
diff --git a/gcc/rust/checks/errors/rust-const-checker.cc b/gcc/rust/checks/errors/rust-const-checker.cc index 27b32b1..d3c25b5 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)) diff --git a/gcc/testsuite/rust/compile/nr2/exclude b/gcc/testsuite/rust/compile/nr2/exclude index a698164..ecef6d2 100644 --- a/gcc/testsuite/rust/compile/nr2/exclude +++ b/gcc/testsuite/rust/compile/nr2/exclude @@ -27,8 +27,6 @@ closure_no_type_anno.rs complex-path1.rs complex_qualified_path_in_expr.rs const-issue1440.rs -const1.rs -const3.rs const_generics_3.rs const_generics_4.rs const_generics_5.rs @@ -38,7 +36,6 @@ derive_macro1.rs derive_macro3.rs derive_macro4.rs derive_macro6.rs -diagnostic_underline.rs expected_type_args2.rs expected_type_args3.rs feature_rust_attri0.rs |