Auto merge of #61822 - JohnTitor:add-long-e0592, r=GuillaumeGomez,Centril
Add explanation for E0592
This is a part of #61137
r? @GuillaumeGomez
diff --git a/src/librustc_typeck/error_codes.rs b/src/librustc_typeck/error_codes.rs
index b5b214d..115ee0f 100644
--- a/src/librustc_typeck/error_codes.rs
+++ b/src/librustc_typeck/error_codes.rs
@@ -3793,6 +3793,40 @@
[issue #33685]: https://github.com/rust-lang/rust/issues/33685
"##,
+E0592: r##"
+This error occurs when you defined methods or associated functions with same
+name.
+
+Erroneous code example:
+
+```compile_fail,E0592
+struct Foo;
+
+impl Foo {
+ fn bar() {} // previous definition here
+}
+
+impl Foo {
+ fn bar() {} // duplicate definition here
+}
+```
+
+A similar error is E0201. The difference is whether there is one declaration
+block or not. To avoid this error, you must give each `fn` a unique name.
+
+```
+struct Foo;
+
+impl Foo {
+ fn bar() {}
+}
+
+impl Foo {
+ fn baz() {} // define with different name
+}
+```
+"##,
+
E0599: r##"
This error occurs when a method is used on a type which doesn't implement it:
@@ -4771,7 +4805,6 @@
// but `{}` was found in the type `{}`
E0587, // type has conflicting packed and align representation hints
E0588, // packed type cannot transitively contain a `[repr(align)]` type
- E0592, // duplicate definitions with name `{}`
// E0611, // merged into E0616
// E0612, // merged into E0609
// E0613, // Removed (merged with E0609)
diff --git a/src/test/ui/codemap_tests/coherence-overlapping-inherent-impl-trait.stderr b/src/test/ui/codemap_tests/coherence-overlapping-inherent-impl-trait.stderr
index a97161b..a60be6f 100644
--- a/src/test/ui/codemap_tests/coherence-overlapping-inherent-impl-trait.stderr
+++ b/src/test/ui/codemap_tests/coherence-overlapping-inherent-impl-trait.stderr
@@ -8,3 +8,4 @@
error: aborting due to previous error
+For more information about this error, try `rustc --explain E0592`.
diff --git a/src/test/ui/codemap_tests/overlapping_inherent_impls.stderr b/src/test/ui/codemap_tests/overlapping_inherent_impls.stderr
index b16d284..70c1093 100644
--- a/src/test/ui/codemap_tests/overlapping_inherent_impls.stderr
+++ b/src/test/ui/codemap_tests/overlapping_inherent_impls.stderr
@@ -29,3 +29,4 @@
error: aborting due to 3 previous errors
+For more information about this error, try `rustc --explain E0592`.
diff --git a/src/test/ui/coherence/coherence-overlap-downstream-inherent.old.stderr b/src/test/ui/coherence/coherence-overlap-downstream-inherent.old.stderr
index 283d7a0..dcfc017 100644
--- a/src/test/ui/coherence/coherence-overlap-downstream-inherent.old.stderr
+++ b/src/test/ui/coherence/coherence-overlap-downstream-inherent.old.stderr
@@ -20,3 +20,4 @@
error: aborting due to 2 previous errors
+For more information about this error, try `rustc --explain E0592`.
diff --git a/src/test/ui/coherence/coherence-overlap-downstream-inherent.re.stderr b/src/test/ui/coherence/coherence-overlap-downstream-inherent.re.stderr
index 283d7a0..dcfc017 100644
--- a/src/test/ui/coherence/coherence-overlap-downstream-inherent.re.stderr
+++ b/src/test/ui/coherence/coherence-overlap-downstream-inherent.re.stderr
@@ -20,3 +20,4 @@
error: aborting due to 2 previous errors
+For more information about this error, try `rustc --explain E0592`.
diff --git a/src/test/ui/coherence/coherence-overlap-issue-23516-inherent.old.stderr b/src/test/ui/coherence/coherence-overlap-issue-23516-inherent.old.stderr
index 38df106..6fd9307 100644
--- a/src/test/ui/coherence/coherence-overlap-issue-23516-inherent.old.stderr
+++ b/src/test/ui/coherence/coherence-overlap-issue-23516-inherent.old.stderr
@@ -11,3 +11,4 @@
error: aborting due to previous error
+For more information about this error, try `rustc --explain E0592`.
diff --git a/src/test/ui/coherence/coherence-overlap-issue-23516-inherent.re.stderr b/src/test/ui/coherence/coherence-overlap-issue-23516-inherent.re.stderr
index 38df106..6fd9307 100644
--- a/src/test/ui/coherence/coherence-overlap-issue-23516-inherent.re.stderr
+++ b/src/test/ui/coherence/coherence-overlap-issue-23516-inherent.re.stderr
@@ -11,3 +11,4 @@
error: aborting due to previous error
+For more information about this error, try `rustc --explain E0592`.
diff --git a/src/test/ui/coherence/coherence-overlap-upstream-inherent.old.stderr b/src/test/ui/coherence/coherence-overlap-upstream-inherent.old.stderr
index 6716b71..928b65e 100644
--- a/src/test/ui/coherence/coherence-overlap-upstream-inherent.old.stderr
+++ b/src/test/ui/coherence/coherence-overlap-upstream-inherent.old.stderr
@@ -11,3 +11,4 @@
error: aborting due to previous error
+For more information about this error, try `rustc --explain E0592`.
diff --git a/src/test/ui/coherence/coherence-overlap-upstream-inherent.re.stderr b/src/test/ui/coherence/coherence-overlap-upstream-inherent.re.stderr
index 6716b71..928b65e 100644
--- a/src/test/ui/coherence/coherence-overlap-upstream-inherent.re.stderr
+++ b/src/test/ui/coherence/coherence-overlap-upstream-inherent.re.stderr
@@ -11,3 +11,4 @@
error: aborting due to previous error
+For more information about this error, try `rustc --explain E0592`.
diff --git a/src/test/ui/issues/issue-33140.stderr b/src/test/ui/issues/issue-33140.stderr
index dae9e02..6c3ba63 100644
--- a/src/test/ui/issues/issue-33140.stderr
+++ b/src/test/ui/issues/issue-33140.stderr
@@ -31,4 +31,5 @@
error: aborting due to 3 previous errors
-For more information about this error, try `rustc --explain E0119`.
+Some errors have detailed explanations: E0119, E0592.
+For more information about an error, try `rustc --explain E0119`.
diff --git a/src/test/ui/specialization/specialization-overlap-hygiene.stderr b/src/test/ui/specialization/specialization-overlap-hygiene.stderr
index ed99aa3..6adf16d 100644
--- a/src/test/ui/specialization/specialization-overlap-hygiene.stderr
+++ b/src/test/ui/specialization/specialization-overlap-hygiene.stderr
@@ -9,3 +9,4 @@
error: aborting due to previous error
+For more information about this error, try `rustc --explain E0592`.
diff --git a/src/test/ui/traits/trait-object-auto-dedup-in-impl.stderr b/src/test/ui/traits/trait-object-auto-dedup-in-impl.stderr
index 9cf3958..2570db0 100644
--- a/src/test/ui/traits/trait-object-auto-dedup-in-impl.stderr
+++ b/src/test/ui/traits/trait-object-auto-dedup-in-impl.stderr
@@ -9,3 +9,4 @@
error: aborting due to previous error
+For more information about this error, try `rustc --explain E0592`.