Skip to content

Commit

Permalink
Use name resolution 2.0 in TraitItemReference
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
powerboat9 authored and CohenArthur committed Oct 28, 2024
1 parent 549fe6d commit f9f690f
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions gcc/rust/typecheck/rust-hir-type-check.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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 (
Expand Down

0 comments on commit f9f690f

Please sign in to comment.