]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: [E0425] Use of unresolved name
authorMuhammad Mahad <mahadtxt@gmail.com>
Thu, 6 Jul 2023 12:37:46 +0000 (17:37 +0500)
committerArthur Cohen <arthur.cohen@embecosm.com>
Tue, 16 Jan 2024 17:49:32 +0000 (18:49 +0100)
Refactored error message similiar to
rustc.

gcc/rust/ChangeLog:

* resolve/rust-ast-resolve-expr.cc (ResolveExpr::visit):
called error function and changed error message
similiar to rustc.

gcc/testsuite/ChangeLog:

* rust/compile/break-rust2.rs: Updated comment to pass testcase.
* rust/compile/const_generics_3.rs: likewise.
* rust/compile/const_generics_4.rs: likewise.
* rust/compile/not_find_value_in_scope.rs: New test.

Signed-off-by: Muhammad Mahad <mahadtxt@gmail.com>
gcc/rust/resolve/rust-ast-resolve-expr.cc
gcc/testsuite/rust/compile/break-rust2.rs
gcc/testsuite/rust/compile/const_generics_3.rs
gcc/testsuite/rust/compile/const_generics_4.rs
gcc/testsuite/rust/compile/not_find_value_in_scope.rs [new file with mode: 0644]

index a67fa307ed7e07b6b1b0af8de6d4b74dbad22c63..de93843e32f194ff3f2326046e975da95ffcb393 100644 (file)
@@ -173,7 +173,8 @@ ResolveExpr::visit (AST::IdentifierExpr &expr)
     }
   else
     {
-      rust_error_at (expr.get_locus (), "failed to find name: %s",
+      rust_error_at (expr.get_locus (), ErrorCode ("E0425"),
+                    "cannot find value %qs in this scope",
                     expr.as_string ().c_str ());
     }
 }
index d02589e6bccda3dc6e7198477eeb7bcda4908352..8a6218a4bd1aaeef044eeac2fd8435bcc75eff9a 100644 (file)
@@ -1,4 +1,4 @@
 fn main() {
     break (rust);
-    // { dg-error "failed to find name: rust" "" { target *-*-* } .-1 }
+    // { dg-error "cannot find value .rust. in this scope" "" { target *-*-* } .-1 }
 }
index 6a3a0fe27bf3ccdaed81abf8198bd7e7c57b4b62..e4e9008c4a694214492420f7afe32374afc98356 100644 (file)
@@ -4,7 +4,7 @@ const M: usize = 4;
 
 struct Foo<T, const N: usize = 1> {
     // FIXME: This error is bogus. But having it means parsing is valid!
-    value: [i32; N], // { dg-error "failed to find name: N" }
+    value: [i32; N], // { dg-error "cannot find value .N. in this scope" }
 }
 
 fn main() {
index 8a3754da433fe66105cc909db88783c5618df637..b364d3bb738af1afcdee637badeaa289303e66f0 100644 (file)
@@ -2,6 +2,6 @@
 
 const P: usize = 14;
 
-struct Foo<const N: usize = { M }>; // { dg-error "failed to find name: M" }
+struct Foo<const N: usize = { M }>; // { dg-error "cannot find value .M. in this scope" }
 struct Bar<const N: usize = { P }>;
 struct Baz<const N: NotAType = { P }>; // { dg-error "failed to resolve TypePath: NotAType in this scope" }
diff --git a/gcc/testsuite/rust/compile/not_find_value_in_scope.rs b/gcc/testsuite/rust/compile/not_find_value_in_scope.rs
new file mode 100644 (file)
index 0000000..f9f7eae
--- /dev/null
@@ -0,0 +1,7 @@
+// https://doc.rust-lang.org/error_codes/E0425.html
+fn main() {
+    let f = x * x * 3; // { dg-error "cannot find value .x. in this scope" }
+    let a = f(); // invalid, too few parameters
+    let b = f(4); // this works!
+    let c = f(2, 3); // invalid, too many parameters
+}