diff --git a/src/expressions/closure-expr.md b/src/expressions/closure-expr.md
index f49ae697e..f058f835b 100644
--- a/src/expressions/closure-expr.md
+++ b/src/expressions/closure-expr.md
@@ -4,10 +4,10 @@
> _ClosureExpression_ :\
> `move`?\
> ( `||` | `|` _ClosureParameters_? `|` )\
-> ([_Expression_] | `->` [_TypeNoBounds_] [_BlockExpression_])
+> ( [_Expression_] | `->` [_Type_] [_BlockExpression_] )
>
> _ClosureParameters_ :\
-> _ClosureParam_ (`,` _ClosureParam_)\* `,`?
+> _ClosureParam_ ( `,` _ClosureParam_ )\* `,`?
>
> _ClosureParam_ :\
> [_OuterAttribute_]\* [_Pattern_] ( `:` [_Type_] )?
@@ -79,7 +79,6 @@ Attributes on closure parameters follow the same rules and restrictions as
[_Expression_]: ../expressions.md
[_BlockExpression_]: block-expr.md
-[_TypeNoBounds_]: ../types.md#type-expressions
[_Pattern_]: ../patterns.md
[_Type_]: ../types.md#type-expressions
[`let` binding]: ../statements.md#let-statements
diff --git a/src/items/generics.md b/src/items/generics.md
index ba35e64d2..fa50f148f 100644
--- a/src/items/generics.md
+++ b/src/items/generics.md
@@ -2,20 +2,16 @@
> **Syntax**\
> _Generics_ :\
-> `<` _GenericParams_ `>`
+> `<` _GenericParams_? `>`
>
> _GenericParams_ :\
-> _LifetimeParams_\
-> | ( _LifetimeParam_ `,` )\* _TypeParams_
+> _GenericParam_ ( `,` _GenericParam_ )\* `,`?
>
-> _LifetimeParams_ :\
-> ( _LifetimeParam_ `,` )\* _LifetimeParam_?
+> _GenericParam_ :\
+> _LifetimeParam_ | _TypeParam_
>
> _LifetimeParam_ :\
-> [_OuterAttribute_]? [LIFETIME_OR_LABEL] ( `:` [_LifetimeBounds_] )?
->
-> _TypeParams_:\
-> ( _TypeParam_ `,` )\* _TypeParam_?
+> [_OuterAttribute_]? [LIFETIME_OR_LABEL] ( `:` [_LifetimeBounds_]? )?
>
> _TypeParam_ :\
> [_OuterAttribute_]? [IDENTIFIER] ( `:` [_TypeParamBounds_]? )? ( `=` [_Type_] )?
@@ -49,13 +45,13 @@ referred to with path syntax.
> | _TypeBoundWhereClauseItem_
>
> _LifetimeWhereClauseItem_ :\
-> [_Lifetime_] `:` [_LifetimeBounds_]
+> [_Lifetime_] `:` [_LifetimeBounds_]?
>
> _TypeBoundWhereClauseItem_ :\
> _ForLifetimes_? [_Type_] `:` [_TypeParamBounds_]?
>
> _ForLifetimes_ :\
-> `for` `<` [_LifetimeParams_](#type-and-lifetime-parameters) `>`
+> `for` `<` [_LifetimeParams_](#type-and-lifetime-parameters)? `>`
*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
diff --git a/src/items/use-declarations.md b/src/items/use-declarations.md
index 6de253a19..a4dcb9cb4 100644
--- a/src/items/use-declarations.md
+++ b/src/items/use-declarations.md
@@ -5,8 +5,8 @@
> `use` _UseTree_ `;`
>
> _UseTree_ :\
-> ([_SimplePath_]? `::`)? `*`\
-> | ([_SimplePath_]? `::`)? `{` (_UseTree_ ( `,` _UseTree_ )\* `,`?)? `}`\
+> ( [_SimplePath_]? `::` )? `*`\
+> | ( [_SimplePath_]? `::` )? `{` ( _UseTree_ ( `,` _UseTree_ )\* `,`? )? `}`\
> | [_SimplePath_] ( `as` ( [IDENTIFIER] | `_` ) )?
A _use declaration_ creates one or more local name bindings synonymous with
diff --git a/src/paths.md b/src/paths.md
index cdf8cc41a..1cfa936f0 100644
--- a/src/paths.md
+++ b/src/paths.md
@@ -20,7 +20,7 @@ x::y::z;
> **Syntax**\
> _SimplePath_ :\
-> `::`? _SimplePathSegment_ (`::` _SimplePathSegment_)\*
+> `::`? _SimplePathSegment_ ( `::` _SimplePathSegment_ )\*
>
> _SimplePathSegment_ :\
> [IDENTIFIER] | `super` | `self` | `crate` | `$crate`
@@ -40,35 +40,21 @@ mod m {
> **Syntax**\
> _PathInExpression_ :\
-> `::`? _PathExprSegment_ (`::` _PathExprSegment_)\*
+> `::`? _PathExprSegment_ ( `::` _PathExprSegment_ )\*
>
> _PathExprSegment_ :\
-> _PathIdentSegment_ (`::` _GenericArgs_)?
+> _PathIdentSegment_ ( `::` `<` _GenericArguments_? `>` )?
>
> _PathIdentSegment_ :\
> [IDENTIFIER] | `super` | `self` | `Self` | `crate` | `$crate`
>
-> _GenericArgs_ :\
-> `<` `>`\
-> | `<` _GenericArgsLifetimes_ `,`? `>`\
-> | `<` _GenericArgsTypes_ `,`? `>`\
-> | `<` _GenericArgsBindings_ `,`? `>`\
-> | `<` _GenericArgsTypes_ `,` _GenericArgsBindings_ `,`? `>`\
-> | `<` _GenericArgsLifetimes_ `,` _GenericArgsTypes_ `,`? `>`\
-> | `<` _GenericArgsLifetimes_ `,` _GenericArgsBindings_ `,`? `>`\
-> | `<` _GenericArgsLifetimes_ `,` _GenericArgsTypes_ `,` _GenericArgsBindings_ `,`? `>`
+> _GenericArguments_ :\
+> _GenericArgument_ ( `,` _GenericArgument_ )\* `,`?
>
-> _GenericArgsLifetimes_ :\
-> [_Lifetime_] (`,` [_Lifetime_])\*
->
-> _GenericArgsTypes_ :\
-> [_Type_] (`,` [_Type_])\*
->
-> _GenericArgsBindings_ :\
-> _GenericArgsBinding_ (`,` _GenericArgsBinding_)\*
->
-> _GenericArgsBinding_ :\
-> [IDENTIFIER] `=` [_Type_]
+> _GenericArgument_ :\
+> [_Lifetime_]\
+> | [_Type_]\
+> | [IDENTIFIER] `=` [_Type_]
Paths in expressions allow for paths with generic arguments to be specified. They are
used in various places in [expressions] and [patterns].
@@ -76,6 +62,12 @@ used in various places in [expressions] and [patterns].
The `::` token is required before the opening `<` for generic arguments to avoid
ambiguity with the less-than operator. This is colloquially known as "turbofish" syntax.
+Generic arguments are passed in the order that they're declared in. In particular,
+lifetime arguments must come before type arguments. The last kind of argument,
+`Ident = Type`, is for specifying [associated types] in [trait bounds].
+These arguments are not positional (i.e. their order does not matter), and they
+must come after all the other (positional) arguments.
+
```rust
(0..10).collect::>();
Vec::::with_capacity(1024);
@@ -85,13 +77,13 @@ Vec::::with_capacity(1024);
> **Syntax**\
> _QualifiedPathInExpression_ :\
-> _QualifiedPathType_ (`::` _PathExprSegment_)+
+> _QualifiedPathType_ ( `::` _PathExprSegment_ )+
>
> _QualifiedPathType_ :\
-> `<` [_Type_] (`as` _TypePath_)? `>`
+> `<` [_Type_] ( `as` _TypePath_ )? `>`
>
> _QualifiedPathInType_ :\
-> _QualifiedPathType_ (`::` _TypePathSegment_)+
+> _QualifiedPathType_ ( `::` _TypePathSegment_ )+
Fully qualified paths allow for disambiguating the path for [trait implementations] and
for specifying [canonical paths](#canonical-paths). When used in a type specification, it
@@ -119,13 +111,14 @@ S::f(); // Calls the inherent impl.
> **Syntax**\
> _TypePath_ :\
-> `::`? _TypePathSegment_ (`::` _TypePathSegment_)\*
+> `::`? _TypePathSegment_ ( `::` _TypePathSegment_ )\*
>
> _TypePathSegment_ :\
-> _PathIdentSegment_ `::`? ([_GenericArgs_] | _TypePathFn_)?
+> _PathIdentSegment_ ( `::`? _TypePathArguments_ )?
>
-> _TypePathFn_ :\
-> `(` _TypePathFnInputs_? `)` (`->` [_Type_])?
+> _TypePathArguments_ :\
+> `<` [_GenericArguments_]? `>`\
+> | `(` _TypePathFnInputs_? `)` [_FunctionReturnType_]?
>
> _TypePathFnInputs_ :\
> [_Type_] (`,` [_Type_])\* `,`?
@@ -364,9 +357,10 @@ mod without { // ::without
# fn main() {}
```
-[_GenericArgs_]: #paths-in-expressions
+[_GenericArguments_]: #paths-in-expressions
[_Lifetime_]: trait-bounds.md
[_Type_]: types.md#type-expressions
+[_FunctionReturnType_]: items/functions.md
[item]: items.md
[variable]: variables.md
[implementations]: items/implementations.md
@@ -381,3 +375,5 @@ mod without { // ::without
[trait implementations]: items/implementations.md#trait-implementations
[traits]: items/traits.md
[visibility]: visibility-and-privacy.md
+[associated types]: items/associated-items.md#associated-types
+[trait bounds]: trait-bounds.md
diff --git a/src/tokens.md b/src/tokens.md
index 3fda6cab7..3ae1561ff 100644
--- a/src/tokens.md
+++ b/src/tokens.md
@@ -28,14 +28,14 @@ evaluated (primarily) at compile time.
#### Characters and strings
-| | Example | `#` sets | Characters | Escapes |
+| | Example | `#` sets | Characters | Escapes |
|----------------------------------------------|-----------------|-------------|-------------|---------------------|
| [Character](#character-literals) | `'H'` | 0 | All Unicode | [Quote](#quote-escapes) & [ASCII](#ascii-escapes) & [Unicode](#unicode-escapes) |
| [String](#string-literals) | `"hello"` | 0 | All Unicode | [Quote](#quote-escapes) & [ASCII](#ascii-escapes) & [Unicode](#unicode-escapes) |
-| [Raw string](#raw-string-literals) | `r#"hello"#` | 0 or more\* | All Unicode | `N/A` |
-| [Byte](#byte-literals) | `b'H'` | 0 | All ASCII | [Quote](#quote-escapes) & [Byte](#byte-escapes) |
-| [Byte string](#byte-string-literals) | `b"hello"` | 0 | All ASCII | [Quote](#quote-escapes) & [Byte](#byte-escapes) |
-| [Raw byte string](#raw-byte-string-literals) | `br#"hello"#` | 0 or more\* | All ASCII | `N/A` |
+| [Raw string](#raw-string-literals) | `r#"hello"#` | 0 or more\* | All Unicode | `N/A` |
+| [Byte](#byte-literals) | `b'H'` | 0 | All ASCII | [Quote](#quote-escapes) & [Byte](#byte-escapes) |
+| [Byte string](#byte-string-literals) | `b"hello"` | 0 | All ASCII | [Quote](#quote-escapes) & [Byte](#byte-escapes) |
+| [Raw byte string](#raw-byte-string-literals) | `br#"hello"#` | 0 or more\* | All ASCII | `N/A` |
\* The number of `#`s on each side of the same literal must be equivalent
@@ -121,11 +121,11 @@ and numeric literal tokens are accepted only with suffixes from the list below.
> `\'` | `\"`
>
> ASCII_ESCAPE :\
-> `\x` OCT_DIGIT HEX_DIGIT\
+> `\x` [OCT_DIGIT](#integer-literals) [HEX_DIGIT](#integer-literals)\
> | `\n` | `\r` | `\t` | `\\` | `\0`
>
> UNICODE_ESCAPE :\
-> `\u{` ( HEX_DIGIT `_`\* )1..6 `}`
+> `\u{` ( [HEX_DIGIT](#integer-literals) `_`\* )1..6 `}`
A _character literal_ is a single Unicode character enclosed within two
`U+0027` (single-quote) characters, with the exception of `U+0027` itself,
@@ -136,10 +136,10 @@ which must be _escaped_ by a preceding `U+005C` character (`\`).
> **Lexer**\
> STRING_LITERAL :\
> `"` (\
-> ~[`"` `\` _IsolatedCR_]\
-> | QUOTE_ESCAPE\
-> | ASCII_ESCAPE\
-> | UNICODE_ESCAPE\
+> ~[`"` `\` [_IsolatedCR_][comments]]\
+> | [QUOTE_ESCAPE](#character-literals)\
+> | [ASCII_ESCAPE](#character-literals)\
+> | [UNICODE_ESCAPE](#character-literals)\
> | STRING_CONTINUE\
> )\* `"`
>
@@ -194,7 +194,7 @@ following forms:
> `r` RAW_STRING_CONTENT
>
> RAW_STRING_CONTENT :\
-> `"` ( ~ _IsolatedCR_ )* (non-greedy) `"`\
+> `"` ( ~ [_IsolatedCR_][comments] )* (non-greedy) `"`\
> | `#` RAW_STRING_CONTENT `#`
Raw string literals do not process any escapes. They start with the character
@@ -234,7 +234,7 @@ r##"foo #"# bar"##; // foo #"# bar
> _any ASCII (i.e. 0x00 to 0x7F), except_ `'`, `\`, \\n, \\r or \\t
>
> BYTE_ESCAPE :\
-> `\x` HEX_DIGIT HEX_DIGIT\
+> `\x` [HEX_DIGIT](#integer-literals) [HEX_DIGIT](#integer-literals)\
> | `\n` | `\r` | `\t` | `\\` | `\0`
A _byte literal_ is a single ASCII character (in the `U+0000` to `U+007F`
@@ -248,10 +248,10 @@ _number literal_.
> **Lexer**\
> BYTE_STRING_LITERAL :\
-> `b"` ( ASCII_FOR_STRING | BYTE_ESCAPE | STRING_CONTINUE )\* `"`
+> `b"` ( ASCII_FOR_STRING | [BYTE_ESCAPE](#byte-literals) | [STRING_CONTINUE](#string-literals) )\* `"`
>
> ASCII_FOR_STRING :\
-> _any ASCII (i.e 0x00 to 0x7F), except_ `"`, `\` _and IsolatedCR_
+> _any ASCII (i.e 0x00 to 0x7F), except_ `"`, `\` _and_ [_IsolatedCR_][comments]
A non-raw _byte string literal_ is a sequence of ASCII characters and _escapes_,
preceded by the characters `U+0062` (`b`) and `U+0022` (double-quote), and
@@ -283,7 +283,7 @@ following forms:
>
> RAW_BYTE_STRING_CONTENT :\
> `"` ASCII* (non-greedy) `"`\
-> | `#` RAW_STRING_CONTENT `#`
+> | `#` [RAW_STRING_CONTENT](#raw-string-literals) `#`
>
> ASCII :\
> _any ASCII (i.e. 0x00 to 0x7F)_
@@ -327,20 +327,20 @@ literal_. The grammar for recognizing the two kinds of literals is mixed.
> INTEGER_SUFFIX?
>
> DEC_LITERAL :\
-> DEC_DIGIT (DEC_DIGIT|`_`)\*
+> DEC_DIGIT ( DEC_DIGIT | `_` )\*
>
> TUPLE_INDEX :\
-> `0`
+> `0`\
> | NON_ZERO_DEC_DIGIT DEC_DIGIT\*
>
> BIN_LITERAL :\
-> `0b` (BIN_DIGIT|`_`)\* BIN_DIGIT (BIN_DIGIT|`_`)\*
+> `0b` ( BIN_DIGIT | `_` )\* BIN_DIGIT ( BIN_DIGIT | `_` )\*
>
> OCT_LITERAL :\
-> `0o` (OCT_DIGIT|`_`)\* OCT_DIGIT (OCT_DIGIT|`_`)\*
+> `0o` ( OCT_DIGIT | `_` )\* OCT_DIGIT ( OCT_DIGIT | `_` )\*
>
> HEX_LITERAL :\
-> `0x` (HEX_DIGIT|`_`)\* HEX_DIGIT (HEX_DIGIT|`_`)\*
+> `0x` ( HEX_DIGIT | `_` )\* HEX_DIGIT ( HEX_DIGIT | `_` )\*
>
> BIN_DIGIT : [`0`-`1`]
>
@@ -446,16 +446,16 @@ a single integer literal.
> **Lexer**\
> FLOAT_LITERAL :\
-> DEC_LITERAL `.`
-> _(not immediately followed by `.`, `_` or an [identifier]_)\
-> | DEC_LITERAL FLOAT_EXPONENT\
-> | DEC_LITERAL `.` DEC_LITERAL FLOAT_EXPONENT?\
-> | DEC_LITERAL (`.` DEC_LITERAL)?
+> [DEC_LITERAL](#integer-literals) `.`
+> _(not immediately followed by `.`, `_` or an [identifier])_\
+> | [DEC_LITERAL](#integer-literals) FLOAT_EXPONENT\
+> | [DEC_LITERAL](#integer-literals) `.` [DEC_LITERAL](#integer-literals) FLOAT_EXPONENT?\
+> | [DEC_LITERAL](#integer-literals) ( `.` [DEC_LITERAL](#integer-literals) )?
> FLOAT_EXPONENT? FLOAT_SUFFIX
>
> FLOAT_EXPONENT :\
-> (`e`|`E`) (`+`|`-`)?
-> (DEC_DIGIT|`_`)\* DEC_DIGIT (DEC_DIGIT|`_`)\*
+> ( `e` | `E` ) ( `+` | `-` )?
+> ( [DEC_DIGIT](#integer-literals) | `_` )\* [DEC_DIGIT](#integer-literals) ( [DEC_DIGIT](#integer-literals) | `_` )\*
>
> FLOAT_SUFFIX :\
> `f32` | `f64`
@@ -605,6 +605,7 @@ them are referred to as "token trees" in [macros]. The three types of brackets
[attributes]: attributes.md
[borrow]: expressions/operator-expr.md#borrow-operators
[closures]: expressions/closure-expr.md
+[comments]: comments.md
[comparison]: expressions/operator-expr.md#comparison-operators
[compound]: expressions/operator-expr.md#compound-assignment-expressions
[dereference]: expressions/operator-expr.md#the-dereference-operator
diff --git a/src/trait-bounds.md b/src/trait-bounds.md
index fe677a9a1..a48873d28 100644
--- a/src/trait-bounds.md
+++ b/src/trait-bounds.md
@@ -9,12 +9,12 @@
>
> _TraitBound_ :\
> `?`?
-> [_ForLifetimes_](#higher-ranked-trait-bounds)? [_TypePath_]\
+> [_ForLifetimes_]? [_TypePath_]\
> | `(` `?`?
-> [_ForLifetimes_](#higher-ranked-trait-bounds)? [_TypePath_] `)`
+> [_ForLifetimes_]? [_TypePath_] `)`
>
> _LifetimeBounds_ :\
-> ( _Lifetime_ `+` )\* _Lifetime_?
+> _Lifetime_ ( `+` _Lifetime_ )\* `+`?
>
> _Lifetime_ :\
> [LIFETIME_OR_LABEL]\
@@ -139,6 +139,7 @@ fn call_on_ref_zero(f: F) where F: for<'a> Fn(&'a i32) {
[LIFETIME_OR_LABEL]: tokens.md#lifetimes-and-loop-labels
[_TypePath_]: paths.md#paths-in-types
[`Sized`]: special-types-and-traits.md#sized
+[_ForLifetimes_]: items/generics.html#where-clauses
[associated types]: items/associated-items.md#associated-types
[supertraits]: items/traits.md#supertraits
diff --git a/src/types.md b/src/types.md
index 1a3fbab82..622a658ad 100644
--- a/src/types.md
+++ b/src/types.md
@@ -129,7 +129,7 @@ let a: List = List::Cons(7, Box::new(List::Cons(13, Box::new(List::Nil))));
[_ParenthesizedType_]: types.md#parenthesized-types
[_QualifiedPathInType_]: paths.md#qualified-paths
[_RawPointerType_]: types/pointer.md#raw-pointers-const-and-mut
-[_ReferenceType_]: types/pointer.md#shared-references-
+[_ReferenceType_]: types/pointer.md#references--and-mut
[_SliceType_]: types/slice.md
[_TraitObjectTypeOneBound_]: types/trait-object.md
[_TraitObjectType_]: types/trait-object.md