]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: [E0599] Failed to resovle method implementation
authorMuhammad Mahad <mahadtxt@gmail.com>
Tue, 29 Aug 2023 15:00:18 +0000 (20:00 +0500)
committerArthur Cohen <arthur.cohen@embecosm.com>
Tue, 16 Jan 2024 18:04:35 +0000 (19:04 +0100)
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 <mahadtxt@gmail.com>
gcc/rust/typecheck/rust-hir-type-check-expr.cc
gcc/testsuite/rust/compile/cfg2.rs
gcc/testsuite/rust/compile/issue-2139.rs
gcc/testsuite/rust/compile/issue-2190-1.rs
gcc/testsuite/rust/compile/method1.rs

index f0911967470787a0bc70bd92c22a816bf1ad2b58..4ed84840e88f9691c73d5b62ae3e2695a2437231 100644 (file)
@@ -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;
     }
index e4c90d96dd492c24002e8750bf66687ca0220b9c..ce1c5f96369a23b65badfe1d87c2a9aec8a5c417 100644 (file)
@@ -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 }
 }
index 3b9ad95467967c4bd45d64244c4b6580868f36b3..65f82f39f40aff096796194c48c89f2ca1ffa10d 100644 (file)
@@ -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 }
 }
index 057d7c71633ec86ddc78feb08a5ae400006b3236..927f90d6c9b005223667a1f49a0e738b04209435 100644 (file)
@@ -9,5 +9,5 @@ trait Deref {
 
 fn foo<T: Deref<Target = i32>>(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 }
 }
index d371bf271f81677558b4c15b6e45bb3ac0a15fb8..3741c61b07693e44cca3177fd34b4049e9a69c70 100644 (file)
@@ -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 }
 }