Skip to content

Commit db4905a

Browse files
Tweak reference for precise capturing in traits
1 parent e95ebdf commit db4905a

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/types/impl-trait.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -132,14 +132,17 @@ fn capture<'a, 'b, T>(x: &'a (), y: T) -> impl Sized + use<'a, T> {
132132
```
133133

134134
r[type.impl-trait.generic-capture.precise.constraint-single]
135-
Currently, only one `use<..>` bound may be present in a bounds list, such bounds are not allowed in the signature of items of a trait definition, all in-scope type and const generic parameters must be included, and all lifetime parameters that appear in other bounds of the abstract type must be included.
135+
Currently, only one `use<..>` bound may be present in a bounds list, all in-scope type and const generic parameters must be included, and all lifetime parameters that appear in other bounds of the abstract type must be included.
136136

137137
r[type.impl-trait.generic-capture.precise.constraint-lifetime]
138138
Within the `use<..>` bound, any lifetime parameters present must appear before all type and const generic parameters, and the elided lifetime (`'_`) may be present if it is otherwise allowed to appear within the `impl Trait` return type.
139139

140140
r[type.impl-trait.generic-capture.precise.constraint-param-impl-trait]
141141
Because all in-scope type parameters must be included by name, a `use<..>` bound may not be used in the signature of items that use argument-position `impl Trait`, as those items have anonymous type parameters in scope.
142142

143+
r[type.impl-trait.generic-capture.precise.constraint-in-trait]
144+
Any `use<..>` bound that is present in an associated function in a trait definition must include all generic parameters of the trait, including the implicit `Self` generic type parameter of the trait.
145+
143146
## Differences between generics and `impl Trait` in return position
144147

145148
In argument position, `impl Trait` is very similar in semantics to a generic type parameter.

0 commit comments

Comments
 (0)