diff options
author | Muhammad Mahad <mahadtxt@gmail.com> | 2023-08-15 20:19:36 +0500 |
---|---|---|
committer | Arthur Cohen <arthur.cohen@embecosm.com> | 2024-01-16 19:00:32 +0100 |
commit | b763d736a10793420945882436d7490385c7dc2d (patch) | |
tree | 049053f31205d4c5516fd8405aeed61b3a4143f3 /gcc/rust | |
parent | 6899eaa70f4fb95ef5b07ae5c073189593f0aa2a (diff) | |
download | gcc-b763d736a10793420945882436d7490385c7dc2d.zip gcc-b763d736a10793420945882436d7490385c7dc2d.tar.gz gcc-b763d736a10793420945882436d7490385c7dc2d.tar.bz2 |
gccrs: [E0034] found more than one items for method
Multiple items found with same prototype.
Fixes: https://github.com/Rust-GCC/gccrs/issues/2366
gcc/rust/ChangeLog:
* typecheck/rust-hir-path-probe.h:
Fixes issue & added rich location message.
* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit):
Added rich location and error code.
gcc/testsuite/ChangeLog:
* rust/compile/generics6.rs: Updated dejagnu comment.
* rust/compile/generics7.rs: likewise.
* rust/compile/issue-925.rs: likewise.
Signed-off-by: Muhammad Mahad <mahadtxt@gmail.com>
Diffstat (limited to 'gcc/rust')
-rw-r--r-- | gcc/rust/typecheck/rust-hir-path-probe.h | 5 | ||||
-rw-r--r-- | gcc/rust/typecheck/rust-hir-type-check-expr.cc | 9 |
2 files changed, 12 insertions, 2 deletions
diff --git a/gcc/rust/typecheck/rust-hir-path-probe.h b/gcc/rust/typecheck/rust-hir-path-probe.h index 3fd96e6..b71d8c3 100644 --- a/gcc/rust/typecheck/rust-hir-path-probe.h +++ b/gcc/rust/typecheck/rust-hir-path-probe.h @@ -165,8 +165,11 @@ public: for (auto &c : candidates) r.add_range (c.locus); + std::string rich_msg = "multiple " + query.as_string () + " found"; + r.add_fixit_replace (rich_msg.c_str ()); + rust_error_at (r, ErrorCode::E0034, - "multiple applicable items in scope for: %s", + "multiple applicable items in scope for: %qs", query.as_string ().c_str ()); } }; diff --git a/gcc/rust/typecheck/rust-hir-type-check-expr.cc b/gcc/rust/typecheck/rust-hir-type-check-expr.cc index e8fbe34..af350ed 100644 --- a/gcc/rust/typecheck/rust-hir-type-check-expr.cc +++ b/gcc/rust/typecheck/rust-hir-type-check-expr.cc @@ -1065,11 +1065,18 @@ TypeCheckExpr::visit (HIR::MethodCallExpr &expr) if (candidates.size () > 1) { rich_location r (line_table, expr.get_method_name ().get_locus ()); + std::string rich_msg + = "multiple " + expr.get_method_name ().get_segment ().as_string () + + " found"; + for (auto &c : candidates) r.add_range (c.candidate.locus); + r.add_fixit_replace (rich_msg.c_str ()); + rust_error_at ( - r, "multiple candidates found for method %<%s%>", + r, ErrorCode::E0034, + "multiple applicable items in scope for method %qs", expr.get_method_name ().get_segment ().as_string ().c_str ()); return; } |