Skip to content

Commit 8bd12af

Browse files
Merge pull request #1011 from ehuss/hrtb-rearrange
Rearrange HRTB grammar.
2 parents af90bd4 + 33784fa commit 8bd12af

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

src/items/generics.md

+2-4
Original file line numberDiff line numberDiff line change
@@ -221,10 +221,7 @@ fn generic<const B: bool>() {
221221
> &nbsp;&nbsp; [_Lifetime_] `:` [_LifetimeBounds_]
222222
>
223223
> _TypeBoundWhereClauseItem_ :\
224-
> &nbsp;&nbsp; _ForLifetimes_<sup>?</sup> [_Type_] `:` [_TypeParamBounds_]<sup>?</sup>
225-
>
226-
> _ForLifetimes_ :\
227-
> &nbsp;&nbsp; `for` [_GenericParams_](#generic-parameters)
224+
> &nbsp;&nbsp; [_ForLifetimes_]<sup>?</sup> [_Type_] `:` [_TypeParamBounds_]<sup>?</sup>
228225
229226
*Where clauses* provide another way to specify bounds on type and lifetime
230227
parameters as well as a way to specify bounds on types that aren't type
@@ -277,6 +274,7 @@ struct Foo<#[my_flexible_clone(unbounded)] H> {
277274
[IDENTIFIER]: ../identifiers.md
278275
[LIFETIME_OR_LABEL]: ../tokens.md#lifetimes-and-loop-labels
279276

277+
[_ForLifetimes_]: ../trait-bounds.md#higher-ranked-trait-bounds
280278
[_LifetimeParam_]: #generic-parameters
281279
[_LifetimeBounds_]: ../trait-bounds.md
282280
[_Lifetime_]: ../trait-bounds.md

src/trait-bounds.md

+4
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,9 @@ fn f<'a, 'b>(x: &'a i32, mut y: &'b i32) where 'a: 'b {
100100

101101
## Higher-ranked trait bounds
102102

103+
> _ForLifetimes_ :\
104+
> &nbsp;&nbsp; `for` [_GenericParams_]
105+
103106
Type bounds may be *higher ranked* over lifetimes. These bounds specify a bound
104107
is true *for all* lifetimes. For example, a bound such as `for<'a> &'a T:
105108
PartialEq<i32>` would require an implementation like
@@ -137,6 +140,7 @@ fn call_on_ref_zero<F>(f: F) where F: for<'a> Fn(&'a i32) {
137140
```
138141

139142
[LIFETIME_OR_LABEL]: tokens.md#lifetimes-and-loop-labels
143+
[_GenericParams_]: items/generics.md
140144
[_TypePath_]: paths.md#paths-in-types
141145
[`Sized`]: special-types-and-traits.md#sized
142146

src/types/function-pointer.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ restrictions as [regular function parameters].
5454

5555
[IDENTIFIER]: ../identifiers.md
5656
[_Abi_]: ../items/functions.md
57-
[_ForLifetimes_]: ../items/generics.md#where-clauses
57+
[_ForLifetimes_]: ../trait-bounds.md#higher-ranked-trait-bounds
5858
[_TypeNoBounds_]: ../types.md#type-expressions
5959
[_Type_]: ../types.md#type-expressions
6060
[_OuterAttribute_]: ../attributes.md

0 commit comments

Comments
 (0)