Skip to content

Commit b5b4f9b

Browse files
authored
Rollup merge of #65855 - ObsidianMinor:extended_error/E0666, r=varkor
Add long error explaination for E0666 In the spirit of the month of spooks, here's a long explanation for E0666 for #61137.
2 parents dae8ded + 16547f5 commit b5b4f9b

File tree

4 files changed

+28
-3
lines changed

4 files changed

+28
-3
lines changed

src/librustc_passes/error_codes.rs

+24-1
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,30 @@ trait Foo {
552552
```
553553
"##,
554554

555+
E0666: r##"
556+
`impl Trait` types cannot appear nested in the
557+
generic arguments of other `impl Trait` types.
558+
559+
Example of erroneous code:
560+
561+
```compile_fail,E0666
562+
trait MyGenericTrait<T> {}
563+
trait MyInnerTrait {}
564+
565+
fn foo(bar: impl MyGenericTrait<impl MyInnerTrait>) {}
566+
```
567+
568+
Type parameters for `impl Trait` types must be
569+
explicitly defined as named generic parameters:
570+
571+
```
572+
trait MyGenericTrait<T> {}
573+
trait MyInnerTrait {}
574+
575+
fn foo<T: MyInnerTrait>(bar: impl MyGenericTrait<T>) {}
576+
```
577+
"##,
578+
555579
E0695: r##"
556580
A `break` statement without a label appeared inside a labeled block.
557581
@@ -605,7 +629,6 @@ Switch to the Rust 2018 edition to use `async fn`.
605629
;
606630
E0226, // only a single explicit lifetime bound is permitted
607631
E0472, // asm! is unsupported on this target
608-
E0666, // nested `impl Trait` is illegal
609632
E0667, // `impl Trait` in projections
610633
E0696, // `continue` pointing to a labeled block
611634
E0706, // `async fn` in trait

src/test/ui/impl-trait/issues/issue-57979-deeply-nested-impl-trait-in-assoc-proj.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,4 @@ LL | pub fn demo(_: impl Quux<Assoc=super::Deeper<impl Foo<impl Bar>>>) { }
2727

2828
error: aborting due to 3 previous errors
2929

30+
For more information about this error, try `rustc --explain E0666`.

src/test/ui/impl-trait/where-allowed.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -272,5 +272,5 @@ LL | type Out = impl Debug;
272272

273273
error: aborting due to 43 previous errors
274274

275-
Some errors have detailed explanations: E0282, E0562, E0658.
275+
Some errors have detailed explanations: E0282, E0562, E0658, E0666.
276276
For more information about an error, try `rustc --explain E0282`.

src/test/ui/nested_impl_trait.stderr

+2-1
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,5 @@ LL | fn allowed_in_ret_type() -> impl Fn() -> impl Into<u32> {
4848

4949
error: aborting due to 6 previous errors
5050

51-
For more information about this error, try `rustc --explain E0562`.
51+
Some errors have detailed explanations: E0562, E0666.
52+
For more information about an error, try `rustc --explain E0562`.

0 commit comments

Comments
 (0)