]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: Use name resolution 2.0 in TraitItemReference
authorOwen Avery <powerboat9.gamer@gmail.com>
Sun, 27 Oct 2024 19:55:48 +0000 (15:55 -0400)
committerArthur Cohen <arthur.cohen@embecosm.com>
Fri, 21 Mar 2025 11:32:54 +0000 (12:32 +0100)
gcc/rust/ChangeLog:

* typecheck/rust-hir-type-check.cc: Add includes.
(TraitItemReference::get_type_from_fn): Use
ForeverStack::to_canonical_path when name resolution 2.0 is
enabled.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
gcc/rust/typecheck/rust-hir-type-check.cc

index 45cb75d87fe043d50322bba26a9f80e29ab4db27..51ab87d14b8ae9739baafefe5d82951ba4d149a0 100644 (file)
 #include "rust-hir-type-check-item.h"
 #include "rust-hir-type-check-pattern.h"
 #include "rust-hir-type-check-struct-field.h"
+#include "rust-immutable-name-resolution-context.h"
+
+// for flag_name_resolution_2_0
+#include "options.h"
 
 extern bool
 saw_errors (void);
@@ -299,8 +303,23 @@ TraitItemReference::get_type_from_fn (/*const*/ HIR::TraitItemFunc &fn) const
     }
 
   auto &mappings = Analysis::Mappings::get ();
-  auto canonical_path
-    = mappings.lookup_canonical_path (fn.get_mappings ().get_nodeid ());
+
+  tl::optional<CanonicalPath> canonical_path;
+  if (flag_name_resolution_2_0)
+    {
+      auto &nr_ctx
+       = Resolver2_0::ImmutableNameResolutionContext::get ().resolver ();
+
+      canonical_path
+       = nr_ctx.values.to_canonical_path (fn.get_mappings ().get_nodeid ());
+    }
+  else
+    {
+      canonical_path
+       = mappings.lookup_canonical_path (fn.get_mappings ().get_nodeid ());
+    }
+
+  rust_assert (canonical_path);
 
   RustIdent ident{*canonical_path, fn.get_locus ()};
   auto resolved = new TyTy::FnType (