From 047f9bc94d46339032296cd872430cd71031bbbf Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Fri, 14 Jun 2019 10:54:27 +0900 Subject: [PATCH 1/3] Add explanation for E0592 --- src/librustc_typeck/error_codes.rs | 23 ++++++++++++++++++- ...nce-overlapping-inherent-impl-trait.stderr | 1 + .../overlapping_inherent_impls.stderr | 1 + ...nce-overlap-downstream-inherent.old.stderr | 1 + ...ence-overlap-downstream-inherent.re.stderr | 1 + ...ce-overlap-issue-23516-inherent.old.stderr | 1 + ...nce-overlap-issue-23516-inherent.re.stderr | 1 + ...rence-overlap-upstream-inherent.old.stderr | 1 + ...erence-overlap-upstream-inherent.re.stderr | 1 + src/test/ui/issues/issue-33140.stderr | 3 ++- .../specialization-overlap-hygiene.stderr | 1 + .../trait-object-auto-dedup-in-impl.stderr | 1 + 12 files changed, 34 insertions(+), 2 deletions(-) diff --git a/src/librustc_typeck/error_codes.rs b/src/librustc_typeck/error_codes.rs index 0b618cdf1dbb..c424388fb2eb 100644 --- a/src/librustc_typeck/error_codes.rs +++ b/src/librustc_typeck/error_codes.rs @@ -3793,6 +3793,28 @@ details. [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. + +For example, in the following code: + +```compile_fail,E0592 +struct Foo; + +impl Foo { + fn bar() {} +} + +impl Foo { + fn bar() {} +} +``` + +A similar error is E0201. The difference is whether there is one declaration +block or not. To avoid this error, you have to give them one name each. +"##, + E0599: r##" This error occurs when a method is used on a type which doesn't implement it: @@ -4771,7 +4793,6 @@ register_diagnostics! { // 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 a97161b131d4..a60be6f23c41 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 @@ LL | impl dyn C { fn f() {} } 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 b16d2849f196..70c1093e9ed4 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 @@ LL | fn baz(&self) {} 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 283d7a04d9bf..dcfc017f1b03 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 @@ LL | impl A { fn f(&self) {} } 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 283d7a04d9bf..dcfc017f1b03 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 @@ LL | impl A { fn f(&self) {} } 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 38df106cc887..6fd930775403 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 @@ LL | impl Cake> { fn dummy(&self) { } } 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 38df106cc887..6fd930775403 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 @@ LL | impl Cake> { fn dummy(&self) { } } 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 6716b71b25b5..928b65e00391 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 @@ LL | impl A { fn dummy(&self) { } } 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 6716b71b25b5..928b65e00391 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 @@ LL | impl A { fn dummy(&self) { } } 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 dae9e02633d0..6c3ba63e6f6f 100644 --- a/src/test/ui/issues/issue-33140.stderr +++ b/src/test/ui/issues/issue-33140.stderr @@ -31,4 +31,5 @@ LL | | } 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 ed99aa3102df..6adf16de4621 100644 --- a/src/test/ui/specialization/specialization-overlap-hygiene.stderr +++ b/src/test/ui/specialization/specialization-overlap-hygiene.stderr @@ -9,3 +9,4 @@ LL | fn f() {} 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 9cf39584a8c1..2570db0212aa 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 @@ LL | fn test(&self) { println!("two"); } error: aborting due to previous error +For more information about this error, try `rustc --explain E0592`. From e252aaec709cab0e460a70f616f49c6e61d7577d Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Fri, 14 Jun 2019 20:12:01 +0900 Subject: [PATCH 2/3] Fix examples --- src/librustc_typeck/error_codes.rs | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/librustc_typeck/error_codes.rs b/src/librustc_typeck/error_codes.rs index c424388fb2eb..9f8874f1ff6d 100644 --- a/src/librustc_typeck/error_codes.rs +++ b/src/librustc_typeck/error_codes.rs @@ -3797,22 +3797,34 @@ E0592: r##" This error occurs when you defined methods or associated functions with same name. -For example, in the following code: +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 have to give them one name each. + +``` +struct Foo; + impl Foo { fn bar() {} } impl Foo { - fn bar() {} + fn baz() {} // define with different name } ``` - -A similar error is E0201. The difference is whether there is one declaration -block or not. To avoid this error, you have to give them one name each. "##, E0599: r##" From 3d5ef11f1a64fe829e6e3306cdfc723eba1b0eab Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Tue, 18 Jun 2019 07:53:27 +0900 Subject: [PATCH 3/3] Improve wording --- src/librustc_typeck/error_codes.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustc_typeck/error_codes.rs b/src/librustc_typeck/error_codes.rs index 9f8874f1ff6d..8fb7049dea8d 100644 --- a/src/librustc_typeck/error_codes.rs +++ b/src/librustc_typeck/error_codes.rs @@ -3812,7 +3812,7 @@ impl Foo { ``` A similar error is E0201. The difference is whether there is one declaration -block or not. To avoid this error, you have to give them one name each. +block or not. To avoid this error, you must give each `fn` a unique name. ``` struct Foo;