]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Use name resolution 2.0 in TraitResolver
authorOwen Avery <powerboat9.gamer@gmail.com>
Sat, 26 Oct 2024 23:43:11 +0000 (19:43 -0400)
committerP-E-P <32375388+P-E-P@users.noreply.github.com>
Tue, 29 Oct 2024 10:18:26 +0000 (10:18 +0000)
gcc/rust/ChangeLog:

* typecheck/rust-hir-trait-resolve.cc: Add includes.
(TraitResolver::resolve_path_to_trait):
Use name resolution 2.0 resolver when enabled.

gcc/testsuite/ChangeLog:

* rust/compile/nr2/exclude: Remove entries.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
gcc/rust/typecheck/rust-hir-trait-resolve.cc
gcc/testsuite/rust/compile/nr2/exclude

index 3e41d2f5a614a0b2ec737c5f3a98042f4cf22ef3..3e66e7591c7d909a0ff9a88b14e334c7b95126a1 100644 (file)
 #include "rust-hir-type-check-expr.h"
 #include "rust-substitution-mapper.h"
 #include "rust-type-util.h"
+#include "rust-immutable-name-resolution-context.h"
+
+// used for flag_name_resolution_2_0
+#include "options.h"
 
 namespace Rust {
 namespace Resolver {
@@ -110,8 +114,24 @@ TraitResolver::resolve_path_to_trait (const HIR::TypePath &path,
                                      HIR::Trait **resolved) const
 {
   NodeId ref;
-  if (!resolver->lookup_resolved_type (path.get_mappings ().get_nodeid (),
-                                      &ref))
+  bool ok;
+  if (flag_name_resolution_2_0)
+    {
+      auto &nr_ctx
+       = Resolver2_0::ImmutableNameResolutionContext::get ().resolver ();
+
+      auto ref_opt = nr_ctx.lookup (path.get_mappings ().get_nodeid ());
+
+      if ((ok = ref_opt.has_value ()))
+       ref = *ref_opt;
+    }
+  else
+    {
+      ok = resolver->lookup_resolved_type (path.get_mappings ().get_nodeid (),
+                                          &ref);
+    }
+
+  if (!ok)
     {
       rust_error_at (path.get_locus (), "Failed to resolve path to node-id");
       return false;
index 424ad686094546c7b651eac337cb2be4ec4ff06b..f4304dae1d857633f6b8e4cb698aaab421daacca 100644 (file)
@@ -65,7 +65,6 @@ issue-1272.rs
 issue-1289.rs
 issue-1447.rs
 issue-1483.rs
-issue-1589.rs
 issue-1725-1.rs
 issue-1725-2.rs
 issue-1786.rs
@@ -175,7 +174,6 @@ sizeof-stray-infer-var-bug.rs
 specify-crate-name.rs
 stmt_with_block_dot.rs
 struct-expr-parse.rs
-trait-cycle.rs
 traits1.rs
 traits10.rs
 traits11.rs