Skip to content

Commit

Permalink
gccrs: [E0599] Failed to resovle method implementation
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
MahadMuhammad committed Aug 19, 2023
1 parent 79a7f07 commit fdb5466
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 6 deletions.
6 changes: 4 additions & 2 deletions gcc/rust/typecheck/rust-hir-type-check-expr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1055,9 +1055,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 %qs name found in the current scope",
expr.get_method_name ().get_segment ().as_string ().c_str ());
return;
}
Expand Down
2 changes: 1 addition & 1 deletion gcc/testsuite/rust/compile/cfg2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 .test. name found in the current scope" "" { target *-*-* } .-1 }
}
2 changes: 1 addition & 1 deletion gcc/testsuite/rust/compile/issue-2139.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 .foo. name found in the current scope" "" { target *-*-* } .-1 }
}
2 changes: 1 addition & 1 deletion gcc/testsuite/rust/compile/issue-2190-1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 .max. name found in the current scope" "" { target *-*-* } .-1 }
}
2 changes: 1 addition & 1 deletion gcc/testsuite/rust/compile/method1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 .test. name found in the current scope" "" { target *-*-* } .-1 }
}

0 comments on commit fdb5466

Please sign in to comment.