Skip to content

Commit

Permalink
nr2.0: late: Better format PathInExpression resolution
Browse files Browse the repository at this point in the history
gcc/rust/ChangeLog:

	* resolve/rust-late-name-resolver-2.0.cc (Late::visit): Improve formatting.
  • Loading branch information
CohenArthur committed Jan 15, 2025
1 parent 6fad4b1 commit f9a15c5
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions gcc/rust/resolve/rust-late-name-resolver-2.0.cc
Original file line number Diff line number Diff line change
Expand Up @@ -218,19 +218,12 @@ Late::visit (AST::PathInExpression &expr)
// in a function item` error here?
// do we emit it in `get<Namespace::Labels>`?

rust_debug ("[ARTHUR]: %s", expr.as_simple_path ().as_string ().c_str ());
auto resolved
= ctx.values.resolve_path (expr.get_segments ()).or_else ([&] () {
return ctx.types.resolve_path (expr.get_segments ());
});

tl::optional<Rib::Definition> resolved = tl::nullopt;

if (auto value = ctx.values.resolve_path (expr.get_segments ()))
{
resolved = value;
}
else if (auto type = ctx.types.resolve_path (expr.get_segments ()))
{
resolved = type;
}
else
if (!resolved)
{
rust_error_at (expr.get_locus (),
"could not resolve path expression: %qs",
Expand All @@ -244,6 +237,7 @@ Late::visit (AST::PathInExpression &expr)
expr.as_string ().c_str ());
return;
}

ctx.map_usage (Usage (expr.get_node_id ()),
Definition (resolved->get_node_id ()));
}
Expand Down

0 comments on commit f9a15c5

Please sign in to comment.