aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMuhammad Mahad <mahadtxt@gmail.com>2023-07-06 17:37:46 +0500
committerArthur Cohen <arthur.cohen@embecosm.com>2024-01-16 18:49:32 +0100
commitf34d65dde655310a7a24bb290052d5180d49ce6d (patch)
tree4d47f96bdbf3c13eb36e9e6d1ec710a86afff552
parentfc0aa04839ebb8ca014b3ca3ca20b248c18f1073 (diff)
downloadgcc-f34d65dde655310a7a24bb290052d5180d49ce6d.zip
gcc-f34d65dde655310a7a24bb290052d5180d49ce6d.tar.gz
gcc-f34d65dde655310a7a24bb290052d5180d49ce6d.tar.bz2
gccrs: [E0425] Use of unresolved name
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>
-rw-r--r--gcc/rust/resolve/rust-ast-resolve-expr.cc3
-rw-r--r--gcc/testsuite/rust/compile/break-rust2.rs2
-rw-r--r--gcc/testsuite/rust/compile/const_generics_3.rs2
-rw-r--r--gcc/testsuite/rust/compile/const_generics_4.rs2
-rw-r--r--gcc/testsuite/rust/compile/not_find_value_in_scope.rs7
5 files changed, 12 insertions, 4 deletions
diff --git a/gcc/rust/resolve/rust-ast-resolve-expr.cc b/gcc/rust/resolve/rust-ast-resolve-expr.cc
index a67fa30..de93843 100644
--- a/gcc/rust/resolve/rust-ast-resolve-expr.cc
+++ b/gcc/rust/resolve/rust-ast-resolve-expr.cc
@@ -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 ());
}
}
diff --git a/gcc/testsuite/rust/compile/break-rust2.rs b/gcc/testsuite/rust/compile/break-rust2.rs
index d02589e..8a6218a 100644
--- a/gcc/testsuite/rust/compile/break-rust2.rs
+++ b/gcc/testsuite/rust/compile/break-rust2.rs
@@ -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 }
}
diff --git a/gcc/testsuite/rust/compile/const_generics_3.rs b/gcc/testsuite/rust/compile/const_generics_3.rs
index 6a3a0fe..e4e9008 100644
--- a/gcc/testsuite/rust/compile/const_generics_3.rs
+++ b/gcc/testsuite/rust/compile/const_generics_3.rs
@@ -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() {
diff --git a/gcc/testsuite/rust/compile/const_generics_4.rs b/gcc/testsuite/rust/compile/const_generics_4.rs
index 8a3754d..b364d3b 100644
--- a/gcc/testsuite/rust/compile/const_generics_4.rs
+++ b/gcc/testsuite/rust/compile/const_generics_4.rs
@@ -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
index 0000000..f9f7eae
--- /dev/null
+++ b/gcc/testsuite/rust/compile/not_find_value_in_scope.rs
@@ -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
+}