Skip to content

Commit c21d158

Browse files
authored
Merge pull request #1769 from compiler-errors/precise-capturing
Tweak reference for precise capturing in traits
2 parents 26ec2c3 + db4905a commit c21d158

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
@@ -133,14 +133,17 @@ fn capture<'a, 'b, T>(x: &'a (), y: T) -> impl Sized + use<'a, T> {
133133
```
134134

135135
r[type.impl-trait.generic-capture.precise.constraint-single]
136-
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.
136+
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.
137137

138138
r[type.impl-trait.generic-capture.precise.constraint-lifetime]
139139
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.
140140

141141
r[type.impl-trait.generic-capture.precise.constraint-param-impl-trait]
142142
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.
143143

144+
r[type.impl-trait.generic-capture.precise.constraint-in-trait]
145+
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.
146+
144147
## Differences between generics and `impl Trait` in return position
145148

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

0 commit comments

Comments
 (0)