From d31c1bdaa8f0c08ec5517a0819b590e5650795ee Mon Sep 17 00:00:00 2001 From: Philip Herron Date: Fri, 21 Jan 2022 20:49:55 +0000 Subject: Improve error message for failure in Method resolution 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 method resolution. Fixes #861 --- gcc/rust/typecheck/rust-hir-type-check-expr.h | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) (limited to 'gcc/rust') 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; } -- cgit v1.1