Skip to content

Commit 0b8c0c6

Browse files
committed
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 <[email protected]>
1 parent 3196ca3 commit 0b8c0c6

File tree

5 files changed

+8
-6
lines changed

5 files changed

+8
-6
lines changed

gcc/rust/typecheck/rust-hir-type-check-expr.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1055,9 +1055,11 @@ TypeCheckExpr::visit (HIR::MethodCallExpr &expr)
10551055
expr.get_method_name ().get_segment ());
10561056
if (candidates.empty ())
10571057
{
1058+
rich_location richloc (line_table, expr.get_method_name ().get_locus ());
1059+
richloc.add_fixit_replace ("method not found");
10581060
rust_error_at (
1059-
expr.get_method_name ().get_locus (),
1060-
"failed to resolve method for %<%s%>",
1061+
richloc, ErrorCode::E0599,
1062+
"no method named %qs found in the current scope",
10611063
expr.get_method_name ().get_segment ().as_string ().c_str ());
10621064
return;
10631065
}

gcc/testsuite/rust/compile/cfg2.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ impl Foo {
88
fn main() {
99
let a = Foo;
1010
a.test();
11-
// { dg-error "failed to resolve method for .test." "" { target *-*-* } .-1 }
11+
// { dg-error "no method .test. name found in the current scope" "" { target *-*-* } .-1 }
1212
}

gcc/testsuite/rust/compile/issue-2139.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@ impl Foo for u16 {
1414
fn main() {
1515
let a: u16 = 123;
1616
a.foo();
17-
// { dg-error "failed to resolve method for .foo." "" { target *-*-* } .-1 }
17+
// { dg-error "no method .foo. name found in the current scope" "" { target *-*-* } .-1 }
1818
}

gcc/testsuite/rust/compile/issue-2190-1.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ trait Deref {
99

1010
fn foo<T: Deref<Target = i32>>(t: &T) -> i32 {
1111
t.max(2)
12-
// { dg-error "failed to resolve method for .max." "" { target *-*-* } .-1 }
12+
// { dg-error "no method .max. name found in the current scope" "" { target *-*-* } .-1 }
1313
}

gcc/testsuite/rust/compile/method1.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ pub fn main() {
88
a = Foo(123);
99

1010
a.test();
11-
// { dg-error "failed to resolve method for .test." "" { target *-*-* } .-1 }
11+
// { dg-error "no method .test. name found in the current scope" "" { target *-*-* } .-1 }
1212
}

0 commit comments

Comments
 (0)