Skip to content

Commit 0376941

Browse files
committed
Auto merge of #61822 - JohnTitor:add-long-e0592, r=GuillaumeGomez,Centril
Add explanation for E0592 This is a part of #61137 r? @GuillaumeGomez
2 parents a6a8f6c + 3d5ef11 commit 0376941

12 files changed

+46
-2
lines changed

src/librustc_typeck/error_codes.rs

+34-1
Original file line numberDiff line numberDiff line change
@@ -3793,6 +3793,40 @@ details.
37933793
[issue #33685]: https://github.com/rust-lang/rust/issues/33685
37943794
"##,
37953795

3796+
E0592: r##"
3797+
This error occurs when you defined methods or associated functions with same
3798+
name.
3799+
3800+
Erroneous code example:
3801+
3802+
```compile_fail,E0592
3803+
struct Foo;
3804+
3805+
impl Foo {
3806+
fn bar() {} // previous definition here
3807+
}
3808+
3809+
impl Foo {
3810+
fn bar() {} // duplicate definition here
3811+
}
3812+
```
3813+
3814+
A similar error is E0201. The difference is whether there is one declaration
3815+
block or not. To avoid this error, you must give each `fn` a unique name.
3816+
3817+
```
3818+
struct Foo;
3819+
3820+
impl Foo {
3821+
fn bar() {}
3822+
}
3823+
3824+
impl Foo {
3825+
fn baz() {} // define with different name
3826+
}
3827+
```
3828+
"##,
3829+
37963830
E0599: r##"
37973831
This error occurs when a method is used on a type which doesn't implement it:
37983832
@@ -4771,7 +4805,6 @@ register_diagnostics! {
47714805
// but `{}` was found in the type `{}`
47724806
E0587, // type has conflicting packed and align representation hints
47734807
E0588, // packed type cannot transitively contain a `[repr(align)]` type
4774-
E0592, // duplicate definitions with name `{}`
47754808
// E0611, // merged into E0616
47764809
// E0612, // merged into E0609
47774810
// E0613, // Removed (merged with E0609)

src/test/ui/codemap_tests/coherence-overlapping-inherent-impl-trait.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ LL | impl dyn C { fn f() {} }
88

99
error: aborting due to previous error
1010

11+
For more information about this error, try `rustc --explain E0592`.

src/test/ui/codemap_tests/overlapping_inherent_impls.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,4 @@ LL | fn baz(&self) {}
2929

3030
error: aborting due to 3 previous errors
3131

32+
For more information about this error, try `rustc --explain E0592`.

src/test/ui/coherence/coherence-overlap-downstream-inherent.old.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,4 @@ LL | impl<X> A<i32, X> { fn f(&self) {} }
2020

2121
error: aborting due to 2 previous errors
2222

23+
For more information about this error, try `rustc --explain E0592`.

src/test/ui/coherence/coherence-overlap-downstream-inherent.re.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,4 @@ LL | impl<X> A<i32, X> { fn f(&self) {} }
2020

2121
error: aborting due to 2 previous errors
2222

23+
For more information about this error, try `rustc --explain E0592`.

src/test/ui/coherence/coherence-overlap-issue-23516-inherent.old.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ LL | impl<U:Sugar> Cake<Box<U>> { fn dummy(&self) { } }
1111

1212
error: aborting due to previous error
1313

14+
For more information about this error, try `rustc --explain E0592`.

src/test/ui/coherence/coherence-overlap-issue-23516-inherent.re.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ LL | impl<U:Sugar> Cake<Box<U>> { fn dummy(&self) { } }
1111

1212
error: aborting due to previous error
1313

14+
For more information about this error, try `rustc --explain E0592`.

src/test/ui/coherence/coherence-overlap-upstream-inherent.old.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ LL | impl A<i16> { fn dummy(&self) { } }
1111

1212
error: aborting due to previous error
1313

14+
For more information about this error, try `rustc --explain E0592`.

src/test/ui/coherence/coherence-overlap-upstream-inherent.re.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ LL | impl A<i16> { fn dummy(&self) { } }
1111

1212
error: aborting due to previous error
1313

14+
For more information about this error, try `rustc --explain E0592`.

src/test/ui/issues/issue-33140.stderr

+2-1
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,5 @@ LL | | }
3131

3232
error: aborting due to 3 previous errors
3333

34-
For more information about this error, try `rustc --explain E0119`.
34+
Some errors have detailed explanations: E0119, E0592.
35+
For more information about an error, try `rustc --explain E0119`.

src/test/ui/specialization/specialization-overlap-hygiene.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ LL | fn f() {}
99

1010
error: aborting due to previous error
1111

12+
For more information about this error, try `rustc --explain E0592`.

src/test/ui/traits/trait-object-auto-dedup-in-impl.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ LL | fn test(&self) { println!("two"); }
99

1010
error: aborting due to previous error
1111

12+
For more information about this error, try `rustc --explain E0592`.

0 commit comments

Comments
 (0)