From: Muhammad Mahad Date: Tue, 29 Aug 2023 15:00:18 +0000 (+0500) Subject: gccrs: [E0599] Failed to resovle method implementation X-Git-Tag: basepoints/gcc-15~2136 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2b560b964d60e42ea4cc99118b786acb0d96db34;p=thirdparty%2Fgcc.git gccrs: [E0599] Failed to resovle method implementation gcc/rust/ChangeLog: * typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): Added new error message, rich location and error code. gcc/testsuite/ChangeLog: * rust/compile/cfg2.rs: Updated according to new message. * rust/compile/issue-2139.rs: likewise. * rust/compile/issue-2190-1.rs: likewise. * rust/compile/method1.rs: likewise. Signed-off-by: Muhammad Mahad --- diff --git a/gcc/rust/typecheck/rust-hir-type-check-expr.cc b/gcc/rust/typecheck/rust-hir-type-check-expr.cc index f09119674707..4ed84840e88f 100644 --- a/gcc/rust/typecheck/rust-hir-type-check-expr.cc +++ b/gcc/rust/typecheck/rust-hir-type-check-expr.cc @@ -1077,9 +1077,11 @@ TypeCheckExpr::visit (HIR::MethodCallExpr &expr) expr.get_method_name ().get_segment ()); if (candidates.empty ()) { + rich_location richloc (line_table, expr.get_method_name ().get_locus ()); + richloc.add_fixit_replace ("method not found"); rust_error_at ( - expr.get_method_name ().get_locus (), - "failed to resolve method for %<%s%>", + richloc, ErrorCode::E0599, + "no method named %qs found in the current scope", expr.get_method_name ().get_segment ().as_string ().c_str ()); return; } diff --git a/gcc/testsuite/rust/compile/cfg2.rs b/gcc/testsuite/rust/compile/cfg2.rs index e4c90d96dd49..ce1c5f96369a 100644 --- a/gcc/testsuite/rust/compile/cfg2.rs +++ b/gcc/testsuite/rust/compile/cfg2.rs @@ -8,5 +8,5 @@ impl Foo { fn main() { let a = Foo; a.test(); - // { dg-error "failed to resolve method for .test." "" { target *-*-* } .-1 } + // { dg-error "no method named .test. found in the current scope" "" { target *-*-* } .-1 } } diff --git a/gcc/testsuite/rust/compile/issue-2139.rs b/gcc/testsuite/rust/compile/issue-2139.rs index 3b9ad9546796..65f82f39f40a 100644 --- a/gcc/testsuite/rust/compile/issue-2139.rs +++ b/gcc/testsuite/rust/compile/issue-2139.rs @@ -14,5 +14,5 @@ impl Foo for u16 { fn main() { let a: u16 = 123; a.foo(); - // { dg-error "failed to resolve method for .foo." "" { target *-*-* } .-1 } + // { dg-error "no method named .foo. found in the current scope" "" { target *-*-* } .-1 } } diff --git a/gcc/testsuite/rust/compile/issue-2190-1.rs b/gcc/testsuite/rust/compile/issue-2190-1.rs index 057d7c71633e..927f90d6c9b0 100644 --- a/gcc/testsuite/rust/compile/issue-2190-1.rs +++ b/gcc/testsuite/rust/compile/issue-2190-1.rs @@ -9,5 +9,5 @@ trait Deref { fn foo>(t: &T) -> i32 { t.max(2) - // { dg-error "failed to resolve method for .max." "" { target *-*-* } .-1 } + // { dg-error "no method named .max. found in the current scope" "" { target *-*-* } .-1 } } diff --git a/gcc/testsuite/rust/compile/method1.rs b/gcc/testsuite/rust/compile/method1.rs index d371bf271f81..3741c61b0769 100644 --- a/gcc/testsuite/rust/compile/method1.rs +++ b/gcc/testsuite/rust/compile/method1.rs @@ -8,5 +8,5 @@ pub fn main() { a = Foo(123); a.test(); - // { dg-error "failed to resolve method for .test." "" { target *-*-* } .-1 } + // { dg-error "no method named .test. found in the current scope" "" { target *-*-* } .-1 } }