diff options
-rw-r--r-- | gcc/rust/resolve/rust-ast-resolve-expr.cc | 3 | ||||
-rw-r--r-- | gcc/testsuite/rust/compile/break-rust2.rs | 2 | ||||
-rw-r--r-- | gcc/testsuite/rust/compile/const_generics_3.rs | 2 | ||||
-rw-r--r-- | gcc/testsuite/rust/compile/const_generics_4.rs | 2 | ||||
-rw-r--r-- | gcc/testsuite/rust/compile/not_find_value_in_scope.rs | 7 |
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 +} |