Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[E0592] method or associated functions already defined with same names #2555

Merged
merged 1 commit into from
Sep 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion gcc/rust/typecheck/rust-hir-inherent-impl-overlap.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,11 @@ class OverlappingImplItemPass : public TypeCheckBase
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:
Expand Down
3 changes: 1 addition & 2 deletions gcc/rust/typecheck/rust-hir-type-check-expr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions gcc/testsuite/rust/compile/generics7.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
}
2 changes: 1 addition & 1 deletion gcc/testsuite/rust/compile/generics8.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down
4 changes: 2 additions & 2 deletions gcc/testsuite/rust/compile/issue-925.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
}