Skip to content

Commit

Permalink
Merge pull request #1011 from ehuss/hrtb-rearrange
Browse files Browse the repository at this point in the history
Rearrange HRTB grammar.
  • Loading branch information
matthewjasper committed May 28, 2021
2 parents af90bd4 + 33784fa commit 8bd12af
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
6 changes: 2 additions & 4 deletions src/items/generics.md
Original file line number Diff line number Diff line change
Expand Up @@ -221,10 +221,7 @@ fn generic<const B: bool>() {
> &nbsp;&nbsp; [_Lifetime_] `:` [_LifetimeBounds_]
>
> _TypeBoundWhereClauseItem_ :\
> &nbsp;&nbsp; _ForLifetimes_<sup>?</sup> [_Type_] `:` [_TypeParamBounds_]<sup>?</sup>
>
> _ForLifetimes_ :\
> &nbsp;&nbsp; `for` [_GenericParams_](#generic-parameters)
> &nbsp;&nbsp; [_ForLifetimes_]<sup>?</sup> [_Type_] `:` [_TypeParamBounds_]<sup>?</sup>
*Where clauses* provide another way to specify bounds on type and lifetime
parameters as well as a way to specify bounds on types that aren't type
Expand Down Expand Up @@ -277,6 +274,7 @@ struct Foo<#[my_flexible_clone(unbounded)] H> {
[IDENTIFIER]: ../identifiers.md
[LIFETIME_OR_LABEL]: ../tokens.md#lifetimes-and-loop-labels

[_ForLifetimes_]: ../trait-bounds.md#higher-ranked-trait-bounds
[_LifetimeParam_]: #generic-parameters
[_LifetimeBounds_]: ../trait-bounds.md
[_Lifetime_]: ../trait-bounds.md
Expand Down
4 changes: 4 additions & 0 deletions src/trait-bounds.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ fn f<'a, 'b>(x: &'a i32, mut y: &'b i32) where 'a: 'b {

## Higher-ranked trait bounds

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

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

Expand Down
2 changes: 1 addition & 1 deletion src/types/function-pointer.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ restrictions as [regular function parameters].

[IDENTIFIER]: ../identifiers.md
[_Abi_]: ../items/functions.md
[_ForLifetimes_]: ../items/generics.md#where-clauses
[_ForLifetimes_]: ../trait-bounds.md#higher-ranked-trait-bounds
[_TypeNoBounds_]: ../types.md#type-expressions
[_Type_]: ../types.md#type-expressions
[_OuterAttribute_]: ../attributes.md
Expand Down

0 comments on commit 8bd12af

Please sign in to comment.