]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: nr2.0: late: Better format PathInExpression resolution
authorArthur Cohen <arthur.cohen@embecosm.com>
Wed, 15 Jan 2025 11:55:54 +0000 (11:55 +0000)
committerArthur Cohen <arthur.cohen@embecosm.com>
Fri, 21 Mar 2025 11:57:51 +0000 (12:57 +0100)
gcc/rust/ChangeLog:

* resolve/rust-late-name-resolver-2.0.cc (Late::visit): Improve formatting.

gcc/rust/resolve/rust-late-name-resolver-2.0.cc

index 9da56ea3214d341b49c7ac5b5e98b3b254f6d4c0..5aea6a43ed68d1b1d157231a7f60b2b06939acf1 100644 (file)
@@ -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",
@@ -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 ()));
 }