From 4b2b23cc078c144a77a34711a20aee3faebbaf0e Mon Sep 17 00:00:00 2001 From: Sydney Acksman Date: Sat, 26 Oct 2019 17:44:23 -0500 Subject: [PATCH 1/2] Add detailed explaination for E0666 --- src/librustc_passes/error_codes.rs | 25 ++++++++++++++++++- ...ply-nested-impl-trait-in-assoc-proj.stderr | 1 + src/test/ui/impl-trait/where-allowed.stderr | 2 +- src/test/ui/nested_impl_trait.stderr | 3 ++- 4 files changed, 28 insertions(+), 3 deletions(-) diff --git a/src/librustc_passes/error_codes.rs b/src/librustc_passes/error_codes.rs index a2626617afec3..e409871c4e93c 100644 --- a/src/librustc_passes/error_codes.rs +++ b/src/librustc_passes/error_codes.rs @@ -552,6 +552,30 @@ trait Foo { ``` "##, +E0666: r##" +`impl Trait` types cannot appear nested in the +generic types of other `impl Trait` types. + +Example of erroneous code: + +```compile_fail,E0666 +trait MyGenericTrait {} +trait MyInnerTrait {} + +fn foo(bar: impl MyGenericTrait) {} +``` + +Type parameters for `impl Trait` types must be +explicitly defined as named generic parameters: + +``` +trait MyGenericTrait {} +trait MyInnerTrait {} + +fn foo(bar: impl MyGenericTrait) {} +``` +"##, + E0695: r##" A `break` statement without a label appeared inside a labeled block. @@ -605,7 +629,6 @@ Switch to the Rust 2018 edition to use `async fn`. ; E0226, // only a single explicit lifetime bound is permitted E0472, // asm! is unsupported on this target - E0666, // nested `impl Trait` is illegal E0667, // `impl Trait` in projections E0696, // `continue` pointing to a labeled block E0706, // `async fn` in trait diff --git a/src/test/ui/impl-trait/issues/issue-57979-deeply-nested-impl-trait-in-assoc-proj.stderr b/src/test/ui/impl-trait/issues/issue-57979-deeply-nested-impl-trait-in-assoc-proj.stderr index b9a1a4fa80a2b..2b6f15e6d3eb2 100644 --- a/src/test/ui/impl-trait/issues/issue-57979-deeply-nested-impl-trait-in-assoc-proj.stderr +++ b/src/test/ui/impl-trait/issues/issue-57979-deeply-nested-impl-trait-in-assoc-proj.stderr @@ -27,3 +27,4 @@ LL | pub fn demo(_: impl Quux>>) { } error: aborting due to 3 previous errors +For more information about this error, try `rustc --explain E0666`. diff --git a/src/test/ui/impl-trait/where-allowed.stderr b/src/test/ui/impl-trait/where-allowed.stderr index dfb6e6524d9a5..b01095f15a978 100644 --- a/src/test/ui/impl-trait/where-allowed.stderr +++ b/src/test/ui/impl-trait/where-allowed.stderr @@ -272,5 +272,5 @@ LL | type Out = impl Debug; error: aborting due to 43 previous errors -Some errors have detailed explanations: E0282, E0562, E0658. +Some errors have detailed explanations: E0282, E0562, E0658, E0666. For more information about an error, try `rustc --explain E0282`. diff --git a/src/test/ui/nested_impl_trait.stderr b/src/test/ui/nested_impl_trait.stderr index bf853d30fab46..3749c268a68b3 100644 --- a/src/test/ui/nested_impl_trait.stderr +++ b/src/test/ui/nested_impl_trait.stderr @@ -48,4 +48,5 @@ LL | fn allowed_in_ret_type() -> impl Fn() -> impl Into { error: aborting due to 6 previous errors -For more information about this error, try `rustc --explain E0562`. +Some errors have detailed explanations: E0562, E0666. +For more information about an error, try `rustc --explain E0562`. From 16547f5025dd9420dc0a3b8bffd5a96f35e8df35 Mon Sep 17 00:00:00 2001 From: ObsidianMinor Date: Sat, 26 Oct 2019 18:42:31 -0500 Subject: [PATCH 2/2] Update with word change suggestion Co-Authored-By: varkor --- src/librustc_passes/error_codes.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustc_passes/error_codes.rs b/src/librustc_passes/error_codes.rs index e409871c4e93c..e22e69a069737 100644 --- a/src/librustc_passes/error_codes.rs +++ b/src/librustc_passes/error_codes.rs @@ -554,7 +554,7 @@ trait Foo { E0666: r##" `impl Trait` types cannot appear nested in the -generic types of other `impl Trait` types. +generic arguments of other `impl Trait` types. Example of erroneous code: