aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2022-01-21 21:59:42 +0000
committerGitHub <noreply@github.com>2022-01-21 21:59:42 +0000
commit8c96ccceb27e96246ff474800c3d7350445bd6e9 (patch)
tree7e2742b8b3d9711e5cbaea5283c9647febf8d042 /gcc
parentc11048a764d722894ee432466282cad8ae11b312 (diff)
parentd31c1bdaa8f0c08ec5517a0819b590e5650795ee (diff)
downloadgcc-8c96ccceb27e96246ff474800c3d7350445bd6e9.zip
gcc-8c96ccceb27e96246ff474800c3d7350445bd6e9.tar.gz
gcc-8c96ccceb27e96246ff474800c3d7350445bd6e9.tar.bz2
Merge #885
885: Improve error message for failure in Method resolution r=philberty a=philberty Use the locus for the method name segment and print its name as part of the error message improves the quality of the error handling in the method resolution. Fixes #861 Co-authored-by: Philip Herron <philip.herron@embecosm.com>
Diffstat (limited to 'gcc')
-rw-r--r--gcc/rust/typecheck/rust-hir-type-check-expr.h15
-rw-r--r--gcc/testsuite/rust/compile/method1.rs2
2 files changed, 5 insertions, 12 deletions
diff --git a/gcc/rust/typecheck/rust-hir-type-check-expr.h b/gcc/rust/typecheck/rust-hir-type-check-expr.h
index 1ac4946..0ac924f 100644
--- a/gcc/rust/typecheck/rust-hir-type-check-expr.h
+++ b/gcc/rust/typecheck/rust-hir-type-check-expr.h
@@ -299,17 +299,10 @@ public:
= MethodResolution::Select (candidates, receiver_tyty, adjustments);
if (resolved_candidate == nullptr)
{
- if (candidates.size () > 1)
- {
- // not sure if this is the correct error here
- ReportMultipleCandidateError::Report (
- candidates, expr.get_method_name ().get_segment (),
- expr.get_method_name ().get_locus ());
- }
- else
- {
- rust_error_at (expr.get_locus (), "failed to resolve method");
- }
+ rust_error_at (
+ expr.get_method_name ().get_locus (),
+ "failed to resolve method for %<%s%>",
+ expr.get_method_name ().get_segment ().as_string ().c_str ());
return;
}
diff --git a/gcc/testsuite/rust/compile/method1.rs b/gcc/testsuite/rust/compile/method1.rs
index cce4ecf..1865240 100644
--- a/gcc/testsuite/rust/compile/method1.rs
+++ b/gcc/testsuite/rust/compile/method1.rs
@@ -8,6 +8,6 @@ pub fn main() {
a = Foo(123);
a.test();
- // { dg-error "failed to resolve method" "" { target *-*-* } .-1 }
+ // { dg-error "failed to resolve method for .test." "" { target *-*-* } .-1 }
// { dg-error {failed to type resolve expression} "" { target *-*-* } .-2 }
}