public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r14-7930] gccrs: [E0034] found more than one items for method
@ 2024-01-16 18:08 Arthur Cohen
  0 siblings, 0 replies; only message in thread
From: Arthur Cohen @ 2024-01-16 18:08 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:b763d736a10793420945882436d7490385c7dc2d

commit r14-7930-gb763d736a10793420945882436d7490385c7dc2d
Author: Muhammad Mahad <mahadtxt@gmail.com>
Date:   Tue Aug 15 20:19:36 2023 +0500

    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>

Diff:
---
 gcc/rust/typecheck/rust-hir-path-probe.h       | 5 ++++-
 gcc/rust/typecheck/rust-hir-type-check-expr.cc | 9 ++++++++-
 gcc/testsuite/rust/compile/generics6.rs        | 2 +-
 gcc/testsuite/rust/compile/generics7.rs        | 2 +-
 gcc/testsuite/rust/compile/issue-925.rs        | 2 +-
 5 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/gcc/rust/typecheck/rust-hir-path-probe.h b/gcc/rust/typecheck/rust-hir-path-probe.h
index 3fd96e63105..b71d8c33fde 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 e8fbe34afd0..af350ed67d3 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;
     }
diff --git a/gcc/testsuite/rust/compile/generics6.rs b/gcc/testsuite/rust/compile/generics6.rs
index 00b93c33ebe..33093cf706b 100644
--- a/gcc/testsuite/rust/compile/generics6.rs
+++ b/gcc/testsuite/rust/compile/generics6.rs
@@ -26,7 +26,7 @@ impl Foo<f32> {
 }
 
 fn main() {
-    let a: i32 = Foo::test(); // { dg-error "multiple applicable items in scope for: test" }
+    let a: i32 = Foo::test(); // { dg-error "multiple applicable items in scope for: .test." }
     // { dg-error {Failed to resolve expression of function call} "" { target *-*-* } .-1 }
 }
 
diff --git a/gcc/testsuite/rust/compile/generics7.rs b/gcc/testsuite/rust/compile/generics7.rs
index f2cd607a330..ae0dc7e906a 100644
--- a/gcc/testsuite/rust/compile/generics7.rs
+++ b/gcc/testsuite/rust/compile/generics7.rs
@@ -26,5 +26,5 @@ impl<T> Foo<T> {
 fn main() {
     let a = Foo { a: 123 };
     a.bar();
-    // { dg-error "multiple candidates found for method .bar." "" { target *-*-* } .-1 }
+    // { dg-error "multiple applicable items in scope for method .bar." "" { target *-*-* } .-1 }
 }
diff --git a/gcc/testsuite/rust/compile/issue-925.rs b/gcc/testsuite/rust/compile/issue-925.rs
index 2d536a54725..d5eed7e7589 100644
--- a/gcc/testsuite/rust/compile/issue-925.rs
+++ b/gcc/testsuite/rust/compile/issue-925.rs
@@ -21,5 +21,5 @@ impl B for S {
 fn test() {
     let a = S;
     a.foo();
-    // { dg-error "multiple candidates found for method .foo." "" { target *-*-* } .-1 }
+    // { dg-error "multiple applicable items in scope for method .foo." "" { target *-*-* } .-1 }
 }

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-01-16 18:08 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-16 18:08 [gcc r14-7930] gccrs: [E0034] found more than one items for method Arthur Cohen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).