From: Owen Avery Date: Sun, 27 Oct 2024 19:55:48 +0000 (-0400) Subject: gccrs: Use name resolution 2.0 in TraitItemReference X-Git-Tag: basepoints/gcc-16~1053 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a36220b6d31f68569c0c0de82ae5b6acfcd51a4a;p=thirdparty%2Fgcc.git 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 --- diff --git a/gcc/rust/typecheck/rust-hir-type-check.cc b/gcc/rust/typecheck/rust-hir-type-check.cc index 45cb75d87fe..51ab87d14b8 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 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 (