diff --git a/compiler/rustc_error_codes/src/error_codes.rs b/compiler/rustc_error_codes/src/error_codes.rs index a185902123d8a..61a177f291ba0 100644 --- a/compiler/rustc_error_codes/src/error_codes.rs +++ b/compiler/rustc_error_codes/src/error_codes.rs @@ -394,6 +394,7 @@ E0663: include_str!("./error_codes/E0663.md"), E0664: include_str!("./error_codes/E0664.md"), E0665: include_str!("./error_codes/E0665.md"), E0666: include_str!("./error_codes/E0666.md"), +E0667: include_str!("./error_codes/E0667.md"), E0668: include_str!("./error_codes/E0668.md"), E0669: include_str!("./error_codes/E0669.md"), E0670: include_str!("./error_codes/E0670.md"), @@ -633,7 +634,6 @@ E0787: include_str!("./error_codes/E0787.md"), // attribute E0640, // infer outlives requirements // E0645, // trait aliases not finished - E0667, // `impl Trait` in projections // E0694, // an unknown tool name found in scoped attributes // E0702, // replaced with a generic attribute input check // E0707, // multiple elided lifetimes used in arguments of `async fn` diff --git a/compiler/rustc_error_codes/src/error_codes/E0667.md b/compiler/rustc_error_codes/src/error_codes/E0667.md new file mode 100644 index 0000000000000..0709a24c43312 --- /dev/null +++ b/compiler/rustc_error_codes/src/error_codes/E0667.md @@ -0,0 +1,18 @@ +`impl Trait` is not allowed in path parameters. + +Erroneous code example: + +```compile_fail,E0667 +fn some_fn(mut x: impl Iterator) -> ::Item { // error! + x.next().unwrap() +} +``` + +You cannot use `impl Trait` in path parameters. If you want something +equivalent, you can do this instead: + +``` +fn some_fn(mut x: T) -> T::Item { // ok! + x.next().unwrap() +} +``` diff --git a/src/test/ui/impl-trait/impl_trait_projections.stderr b/src/test/ui/impl-trait/impl_trait_projections.stderr index e85ed0eda5215..82d2422c40779 100644 --- a/src/test/ui/impl-trait/impl_trait_projections.stderr +++ b/src/test/ui/impl-trait/impl_trait_projections.stderr @@ -30,4 +30,5 @@ LL | fn projection_is_disallowed(x: impl Iterator) -> ::Item { error: aborting due to 5 previous errors -For more information about this error, try `rustc --explain E0223`. +Some errors have detailed explanations: E0223, E0667. +For more information about an error, try `rustc --explain E0223`. diff --git a/src/test/ui/impl-trait/issues/issue-57979-impl-trait-in-path.stderr b/src/test/ui/impl-trait/issues/issue-57979-impl-trait-in-path.stderr index f64545d83b8d6..e31393181d734 100644 --- a/src/test/ui/impl-trait/issues/issue-57979-impl-trait-in-path.stderr +++ b/src/test/ui/impl-trait/issues/issue-57979-impl-trait-in-path.stderr @@ -6,3 +6,4 @@ LL | pub fn demo(_: impl Quux<(), Assoc=<() as Quux>::Assoc>) { } error: aborting due to previous error +For more information about this error, try `rustc --explain E0667`.