Skip to content

Commit 57667f1

Browse files
committed
Fix generic args in path.
1 parent 9488446 commit 57667f1

File tree

1 file changed

+30
-6
lines changed

1 file changed

+30
-6
lines changed

src/paths.md

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,37 @@ mod m {
4242
> &nbsp;&nbsp; `::`<sup>?</sup> _PathExprSegment_ (`::` _PathExprSegment_)<sup>\*</sup>
4343
>
4444
> _PathExprSegment_ :\
45-
> &nbsp;&nbsp; _PathIdentSegment_ (`::` [_Generics_])<sup>?</sup>
45+
> &nbsp;&nbsp; _PathIdentSegment_ (`::` _GenericArgs_)<sup>?</sup>
4646
>
4747
> _PathIdentSegment_ :\
4848
> &nbsp;&nbsp; [IDENTIFIER] | `super` | `self` | `Self` | `$crate`
49+
>
50+
> _GenericArgs_ :\
51+
> &nbsp;&nbsp; &nbsp;&nbsp; `<` `>`\
52+
> &nbsp;&nbsp; | `<` _GenericArgsLifetimes_ `,`<sup>?</sup> `>`\
53+
> &nbsp;&nbsp; | `<` _GenericArgsTypes_ `,`<sup>?</sup> `>`\
54+
> &nbsp;&nbsp; | `<` _GenericArgsBindings_ `,`<sup>?</sup> `>`\
55+
> &nbsp;&nbsp; | `<` _GenericArgsTypes_ `,` _GenericArgsBindings_ `,`<sup>?</sup> `>`\
56+
> &nbsp;&nbsp; | `<` _GenericArgsLifetimes_ `,` _GenericArgsTypes_ `,`<sup>?</sup> `>`\
57+
> &nbsp;&nbsp; | `<` _GenericArgsLifetimes_ `,` _GenericArgsBindings_ `,`<sup>?</sup> `>`\
58+
> &nbsp;&nbsp; | `<` _GenericArgsLifetimes_ `,` _GenericArgsTypes_ `,` _GenericArgsBindings_ `,`<sup>?</sup> `>`
59+
>
60+
> _GenericArgsLifetimes_ :\
61+
> &nbsp;&nbsp; [_Lifetime_] (`,` [_Lifetime_])<sup>\*</sup>
62+
>
63+
> _GenericArgsTypes_ :\
64+
> &nbsp;&nbsp; [_Type_] (`,` [_Type_])<sup>\*</sup>
65+
>
66+
> _GenericArgsBindings_ :\
67+
> &nbsp;&nbsp; _GenericArgsBinding_ (`,` _GenericArgsBinding_)<sup>\*</sup>
68+
>
69+
> _GenericArgsBinding_ :\
70+
> &nbsp;&nbsp; [IDENTIFIER] `=` [_Type_]
4971
5072
Paths in expressions allow for paths with generic arguments to be specified. They are
5173
used in various places in [expressions] and [patterns].
5274

53-
The `::` token is required before the opening `<` for generic parameters to avoid
75+
The `::` token is required before the opening `<` for generic arguments to avoid
5476
ambiguity with the less-than operator. This is colloquially known as "turbofish" syntax.
5577

5678
```rust
@@ -99,7 +121,7 @@ S::f(); // Calls the inherent impl.
99121
> &nbsp;&nbsp; `::`<sup>?</sup> _TypePathSegment_ (`::` _TypePathSegment_)<sup>\*</sup>
100122
>
101123
> _TypePathSegment_ :\
102-
> &nbsp;&nbsp; _PathIdentSegment_ (`::`<sup>?</sup> ([_Generics_] | _TypePathFn_)<sup>?</sup>
124+
> &nbsp;&nbsp; _PathIdentSegment_ (`::`<sup>?</sup> ([_GenericArgs_] | _TypePathFn_)<sup>?</sup>
103125
>
104126
> _TypePathFn_ :\
105127
> `(` _TypePathFnInputs_<sup>?</sup> `)` (`->` [_Type_])<sup>?</sup>
@@ -110,7 +132,7 @@ S::f(); // Calls the inherent impl.
110132
Type paths are used within type definitions, trait bounds, type parameter bounds,
111133
and qualified paths.
112134

113-
Although the `::` token is allowed before the generics parameters, it is not required
135+
Although the `::` token is allowed before the generics arguments, it is not required
114136
because there is no ambiguity like there is in _PathInExpression_.
115137

116138
```rust,ignore
@@ -303,15 +325,17 @@ mod without { // ::without
303325

304326
# fn main() {}
305327
```
328+
329+
[_GenericArgs_]: #paths-in-expressions
330+
[_Lifetime_]: trait-bounds.html
331+
[_Type_]: types.html
306332
[item]: items.html
307333
[variable]: variables.html
308334
[identifiers]: identifiers.html
309335
[implementations]: items/implementations.html
310336
[modules]: items/modules.html
311337
[use declarations]: items/use-declarations.html
312338
[IDENTIFIER]: identifiers.html
313-
[_Generics_]: items/generics.html
314-
[_Type_]: types.html
315339
[`use`]: items/use-declarations.html
316340
[attributes]: attributes.html
317341
[enum]: items/enumerations.html

0 commit comments

Comments
 (0)