aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorOwen Avery <powerboat9.gamer@gmail.com>2024-10-27 15:55:48 -0400
committerArthur Cohen <arthur.cohen@embecosm.com>2025-03-21 12:32:54 +0100
commita36220b6d31f68569c0c0de82ae5b6acfcd51a4a (patch)
tree5b75ec333509080df54b888543db47415fdab19f /gcc
parent3fe905ebf21a67a63d70a336ef87ae06fd8d5e63 (diff)
downloadgcc-a36220b6d31f68569c0c0de82ae5b6acfcd51a4a.zip
gcc-a36220b6d31f68569c0c0de82ae5b6acfcd51a4a.tar.gz
gcc-a36220b6d31f68569c0c0de82ae5b6acfcd51a4a.tar.bz2
gccrs: Use name resolution 2.0 in TraitItemReference
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>
Diffstat (limited to 'gcc')
-rw-r--r--gcc/rust/typecheck/rust-hir-type-check.cc23
1 files changed, 21 insertions, 2 deletions
diff --git a/gcc/rust/typecheck/rust-hir-type-check.cc b/gcc/rust/typecheck/rust-hir-type-check.cc
index 45cb75d..51ab87d 100644
--- a/gcc/rust/typecheck/rust-hir-type-check.cc
+++ b/gcc/rust/typecheck/rust-hir-type-check.cc
@@ -23,6 +23,10 @@
#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 (