Skip to content

Commit dafc29d

Browse files
authored
Rollup merge of #95364 - GuillaumeGomez:long-error-explanation-e0667, r=Dylan-DPC
Add long error explanation for E0667 Part of #61137.
2 parents a8be562 + 81f24c1 commit dafc29d

File tree

4 files changed

+22
-2
lines changed

4 files changed

+22
-2
lines changed

compiler/rustc_error_codes/src/error_codes.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,7 @@ E0663: include_str!("./error_codes/E0663.md"),
394394
E0664: include_str!("./error_codes/E0664.md"),
395395
E0665: include_str!("./error_codes/E0665.md"),
396396
E0666: include_str!("./error_codes/E0666.md"),
397+
E0667: include_str!("./error_codes/E0667.md"),
397398
E0668: include_str!("./error_codes/E0668.md"),
398399
E0669: include_str!("./error_codes/E0669.md"),
399400
E0670: include_str!("./error_codes/E0670.md"),
@@ -633,7 +634,6 @@ E0787: include_str!("./error_codes/E0787.md"),
633634
// attribute
634635
E0640, // infer outlives requirements
635636
// E0645, // trait aliases not finished
636-
E0667, // `impl Trait` in projections
637637
// E0694, // an unknown tool name found in scoped attributes
638638
// E0702, // replaced with a generic attribute input check
639639
// E0707, // multiple elided lifetimes used in arguments of `async fn`
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
`impl Trait` is not allowed in path parameters.
2+
3+
Erroneous code example:
4+
5+
```compile_fail,E0667
6+
fn some_fn(mut x: impl Iterator) -> <impl Iterator>::Item { // error!
7+
x.next().unwrap()
8+
}
9+
```
10+
11+
You cannot use `impl Trait` in path parameters. If you want something
12+
equivalent, you can do this instead:
13+
14+
```
15+
fn some_fn<T: Iterator>(mut x: T) -> T::Item { // ok!
16+
x.next().unwrap()
17+
}
18+
```

src/test/ui/impl-trait/impl_trait_projections.stderr

+2-1
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,5 @@ LL | fn projection_is_disallowed(x: impl Iterator) -> <impl Iterator>::Item {
3030

3131
error: aborting due to 5 previous errors
3232

33-
For more information about this error, try `rustc --explain E0223`.
33+
Some errors have detailed explanations: E0223, E0667.
34+
For more information about an error, try `rustc --explain E0223`.

src/test/ui/impl-trait/issues/issue-57979-impl-trait-in-path.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ LL | pub fn demo(_: impl Quux<(), Assoc=<() as Quux<impl Bar>>::Assoc>) { }
66

77
error: aborting due to previous error
88

9+
For more information about this error, try `rustc --explain E0667`.

0 commit comments

Comments
 (0)