]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: gccrs:[E0592] methods or associated functions with same name already defined
authorMuhammad Mahad <mahadtxt@gmail.com>
Thu, 17 Aug 2023 05:42:52 +0000 (10:42 +0500)
committerArthur Cohen <arthur.cohen@embecosm.com>
Tue, 16 Jan 2024 18:04:31 +0000 (19:04 +0100)
gcc/rust/ChangeLog:

* typecheck/rust-hir-inherent-impl-overlap.h:
Added rich location and errorcode.
* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit):
likewise.

gcc/testsuite/ChangeLog:

* rust/compile/generics7.rs: Added Errorcode hint.
* rust/compile/generics8.rs: Updated dejagnu comment.
* rust/compile/issue-925.rs: Added Errorcode hint.

Signed-off-by: Muhammad Mahad <mahadtxt@gmail.com>
gcc/rust/typecheck/rust-hir-inherent-impl-overlap.h
gcc/rust/typecheck/rust-hir-type-check-expr.cc
gcc/testsuite/rust/compile/generics7.rs
gcc/testsuite/rust/compile/generics8.rs
gcc/testsuite/rust/compile/issue-925.rs

index ae5a5d57c8d21eec8e7db7f9178f17b9da76fa7c..abb93ca0e4af7d65d4cabb4f5f3ae3c995af1971 100644 (file)
@@ -129,8 +129,11 @@ public:
                           const std::string &name)
   {
     rich_location r (line_table, dup->get_locus ());
+    std::string msg = "duplicate definitions for " + name;
+    r.add_fixit_replace (query->get_locus (), msg.c_str ());
     r.add_range (query->get_locus ());
-    rust_error_at (r, "duplicate definitions with name %s", name.c_str ());
+    rust_error_at (r, ErrorCode::E0592, "duplicate definitions with name %qs",
+                  name.c_str ());
   }
 
 private:
index 898ea11733334f60ec7f563c309edcf1d04bf46e..f0911967470787a0bc70bd92c22a816bf1ad2b58 100644 (file)
@@ -1097,8 +1097,7 @@ TypeCheckExpr::visit (HIR::MethodCallExpr &expr)
       r.add_fixit_replace (rich_msg.c_str ());
 
       rust_error_at (
-       r, ErrorCode::E0034,
-       "multiple applicable items in scope for method %qs",
+       r, ErrorCode::E0592, "duplicate definitions with name %qs",
        expr.get_method_name ().get_segment ().as_string ().c_str ());
       return;
     }
index ae0dc7e906a5a2bc94f18a084d308b82bf2b08ed..dcedead4b9f32d0ff7f669da2eb53b3662c8c38c 100644 (file)
@@ -22,9 +22,9 @@ impl<T> Foo<T> {
         self.a
     }
 }
-
+// E0592
 fn main() {
     let a = Foo { a: 123 };
     a.bar();
-    // { dg-error "multiple applicable items in scope for method .bar." "" { target *-*-* } .-1 }
+    // { dg-error "duplicate definitions with name .bar." "" { target *-*-* } .-1 }
 }
index 99df0c9b58cc64c5937e737310f652c509f96e39..88c4bac1b076a73adaae2becdd5d7289dc881331 100644 (file)
@@ -10,7 +10,7 @@ impl<T> Foo<i32, T> {
 }
 
 impl Foo<i32, f32> {
-    fn test() -> f32 { // { dg-error "duplicate definitions with name test" }
+    fn test() -> f32 { // { dg-error "duplicate definitions with name .test." }
         123f32
     }
 }
index d5eed7e758989323d3d87eefb10988f63f1f2395..507fe9444e5fafd198901ae1132a9384057f4d89 100644 (file)
@@ -17,9 +17,9 @@ impl A for S {
 impl B for S {
     fn foo(&self) {}
 }
-
+// E0592
 fn test() {
     let a = S;
     a.foo();
-    // { dg-error "multiple applicable items in scope for method .foo." "" { target *-*-* } .-1 }
+    // { dg-error "duplicate definitions with name .foo." "" { target *-*-* } .-1 }
 }