Rollup merge of #144816 - Noratrieb:e0562-impl-trait, r=WaffleLapkin

Update E0562 to account for the new impl trait positions

fixes rust-lang/rust#142683
This commit is contained in:
Samuel Tardieu 2025-08-03 21:56:58 +02:00 committed by GitHub
commit 7100b2deec
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,5 +1,4 @@
Abstract return types (written `impl Trait` for some trait `Trait`) are only
allowed as function and inherent impl return types.
`impl Trait` is only allowed as a function return and argument type.
Erroneous code example:
@ -14,7 +13,7 @@ fn main() {
}
```
Make sure `impl Trait` only appears in return-type position.
Make sure `impl Trait` appears in a function signature.
```
fn count_to_n(n: usize) -> impl Iterator<Item=usize> {
@ -28,6 +27,6 @@ fn main() {
}
```
See [RFC 1522] for more details.
See the [reference] for more details on `impl Trait`.
[RFC 1522]: https://github.com/rust-lang/rfcs/blob/master/text/1522-conservative-impl-trait.md
[reference]: https://doc.rust-lang.org/stable/reference/types/impl-trait.html