Skip to content

Commit

Permalink
nr2.0: Resolve lang item paths properly.
Browse files Browse the repository at this point in the history
gcc/rust/ChangeLog:

	* resolve/rust-late-name-resolver-2.0.cc (Late::visit): New.
	* resolve/rust-late-name-resolver-2.0.h: New.
  • Loading branch information
CohenArthur committed Dec 5, 2024
1 parent 12af06e commit 4119359
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
20 changes: 20 additions & 0 deletions gcc/rust/resolve/rust-late-name-resolver-2.0.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#include "optional.h"
#include "rust-ast-full.h"
#include "rust-diagnostics.h"
#include "rust-hir-map.h"
#include "rust-late-name-resolver-2.0.h"
#include "rust-default-resolver.h"
Expand Down Expand Up @@ -247,6 +248,25 @@ Late::visit (AST::PathInExpression &expr)
Definition (resolved->get_node_id ()));
}

void
Late::visit (AST::LangItemPath &type)
{
auto &mappings = Rust::Analysis::Mappings::get ();
auto lang_item = mappings.lookup_lang_item_node (type.get_lang_item_kind ());

if (!lang_item)
{
rust_fatal_error (
type.get_locus (), "use of undeclared lang item %qs",
LangItem::ToString (type.get_lang_item_kind ()).c_str ());
return;
}

ctx.map_usage (Usage (type.get_node_id ()), Definition (lang_item.value ()));

DefaultResolver::visit (type);
}

void
Late::visit (AST::TypePath &type)
{
Expand Down
1 change: 1 addition & 0 deletions gcc/rust/resolve/rust-late-name-resolver-2.0.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class Late : public DefaultResolver
// resolutions
void visit (AST::IdentifierExpr &) override;
void visit (AST::PathInExpression &) override;
void visit (AST::LangItemPath &) override;
void visit (AST::TypePath &) override;
void visit (AST::StructExprStruct &) override;
void visit (AST::StructExprStructBase &) override;
Expand Down

0 comments on commit 4119359

Please sign in to comment.