https://gcc.gnu.org/g:6736f9881ab92fb8143fe12e1ced30c266bbd999

commit r15-8862-g6736f9881ab92fb8143fe12e1ced30c266bbd999
Author: Owen Avery <powerboat9.ga...@gmail.com>
Date:   Tue Mar 18 20:28:25 2025 -0400

    gccrs: nr2.0: Adjust indentifier expression handling
    
    gcc/rust/ChangeLog:
    
            * resolve/rust-late-name-resolver-2.0.cc
            (Late::visit): Make sure to return early after a resolution
            error, improve the resolution error message, fix a typo, handle
            ambiguous resolutions, and remove an old comment.
    
    gcc/testsuite/ChangeLog:
    
            * rust/compile/nr2/exclude: Remove entries.
    
    Signed-off-by: Owen Avery <powerboat9.ga...@gmail.com>

Diff:
---
 gcc/rust/resolve/rust-late-name-resolver-2.0.cc | 26 ++++++++++++++++---------
 gcc/testsuite/rust/compile/nr2/exclude          |  3 ---
 2 files changed, 17 insertions(+), 12 deletions(-)

diff --git a/gcc/rust/resolve/rust-late-name-resolver-2.0.cc 
b/gcc/rust/resolve/rust-late-name-resolver-2.0.cc
index a8eb3b4fa12a..09aa5fc44e6e 100644
--- a/gcc/rust/resolve/rust-late-name-resolver-2.0.cc
+++ b/gcc/rust/resolve/rust-late-name-resolver-2.0.cc
@@ -232,21 +232,29 @@ Late::visit (AST::IdentifierExpr &expr)
     }
   else
     {
-      if (auto typ = ctx.types.get_prelude (expr.get_ident ()))
-       resolved = typ;
+      if (auto type = ctx.types.get_prelude (expr.get_ident ()))
+       {
+         resolved = type;
+       }
       else
-       rust_error_at (expr.get_locus (),
-                      "could not resolve identifier expression: %qs",
-                      expr.get_ident ().as_string ().c_str ());
+       {
+         rust_error_at (expr.get_locus (), ErrorCode::E0425,
+                        "cannot find value %qs in this scope",
+                        expr.get_ident ().as_string ().c_str ());
+         return;
+       }
+    }
+
+  if (resolved->is_ambiguous ())
+    {
+      rust_error_at (expr.get_locus (), ErrorCode::E0659, "%qs is ambiguous",
+                    expr.as_string ().c_str ());
+      return;
     }
 
   ctx.map_usage (Usage (expr.get_node_id ()),
                 Definition (resolved->get_node_id ()));
 
-  // in the old resolver, resolutions are kept in the resolver, not the 
mappings
-  // :/ how do we deal with that?
-  // ctx.mappings.insert_resolved_name(expr, resolved);
-
   // For empty types, do we perform a lookup in ctx.types or should the
   // toplevel instead insert a name in ctx.values? (like it currently does)
 }
diff --git a/gcc/testsuite/rust/compile/nr2/exclude 
b/gcc/testsuite/rust/compile/nr2/exclude
index de5824813b47..59964fc90e28 100644
--- a/gcc/testsuite/rust/compile/nr2/exclude
+++ b/gcc/testsuite/rust/compile/nr2/exclude
@@ -1,8 +1,6 @@
-break-rust2.rs
 canonical_paths1.rs
 cfg1.rs
 const_generics_3.rs
-const_generics_4.rs
 feature_rust_attri0.rs
 generics9.rs
 issue-1901.rs
@@ -19,7 +17,6 @@ macros/mbe/macro43.rs
 macros/mbe/macro6.rs
 multiple_bindings1.rs
 multiple_bindings2.rs
-not_find_value_in_scope.rs
 privacy5.rs
 privacy8.rs
 pub_restricted_1.rs

Reply via email to