@@ -42,15 +42,37 @@ mod m {
42
42
>   ;  ; ` :: ` <sup >?</sup > _ PathExprSegment_ (` :: ` _ PathExprSegment_ )<sup >\* </sup >
43
43
>
44
44
> _ PathExprSegment_ :\
45
- >   ;  ; _ PathIdentSegment_ (` :: ` [ _ Generics _ ] )<sup >?</sup >
45
+ >   ;  ; _ PathIdentSegment_ (` :: ` _ GenericArgs _ )<sup >?</sup >
46
46
>
47
47
> _ PathIdentSegment_ :\
48
48
>   ;  ; [ IDENTIFIER] | ` super ` | ` self ` | ` Self ` | ` $crate `
49
+ >
50
+ > _ GenericArgs_ :\
51
+ >   ;  ;   ;  ; ` < ` ` > ` \
52
+ >   ;  ; | ` < ` _ GenericArgsLifetimes_ ` , ` <sup >?</sup > ` > ` \
53
+ >   ;  ; | ` < ` _ GenericArgsTypes_ ` , ` <sup >?</sup > ` > ` \
54
+ >   ;  ; | ` < ` _ GenericArgsBindings_ ` , ` <sup >?</sup > ` > ` \
55
+ >   ;  ; | ` < ` _ GenericArgsTypes_ ` , ` _ GenericArgsBindings_ ` , ` <sup >?</sup > ` > ` \
56
+ >   ;  ; | ` < ` _ GenericArgsLifetimes_ ` , ` _ GenericArgsTypes_ ` , ` <sup >?</sup > ` > ` \
57
+ >   ;  ; | ` < ` _ GenericArgsLifetimes_ ` , ` _ GenericArgsBindings_ ` , ` <sup >?</sup > ` > ` \
58
+ >   ;  ; | ` < ` _ GenericArgsLifetimes_ ` , ` _ GenericArgsTypes_ ` , ` _ GenericArgsBindings_ ` , ` <sup >?</sup > ` > `
59
+ >
60
+ > _ GenericArgsLifetimes_ :\
61
+ >   ;  ; [ _ Lifetime_ ] (` , ` [ _ Lifetime_ ] )<sup >\* </sup >
62
+ >
63
+ > _ GenericArgsTypes_ :\
64
+ >   ;  ; [ _ Type_ ] (` , ` [ _ Type_ ] )<sup >\* </sup >
65
+ >
66
+ > _ GenericArgsBindings_ :\
67
+ >   ;  ; _ GenericArgsBinding_ (` , ` _ GenericArgsBinding_ )<sup >\* </sup >
68
+ >
69
+ > _ GenericArgsBinding_ :\
70
+ >   ;  ; [ IDENTIFIER] ` = ` [ _ Type_ ]
49
71
50
72
Paths in expressions allow for paths with generic arguments to be specified. They are
51
73
used in various places in [ expressions] and [ patterns] .
52
74
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
54
76
ambiguity with the less-than operator. This is colloquially known as "turbofish" syntax.
55
77
56
78
``` rust
@@ -99,7 +121,7 @@ S::f(); // Calls the inherent impl.
99
121
>   ;  ; ` :: ` <sup >?</sup > _ TypePathSegment_ (` :: ` _ TypePathSegment_ )<sup >\* </sup >
100
122
>
101
123
> _ TypePathSegment_ :\
102
- >   ;  ; _ PathIdentSegment_ (` :: ` <sup >?</sup > ([ _ Generics _ ] | _ TypePathFn_ )<sup >?</sup >
124
+ >   ;  ; _ PathIdentSegment_ (` :: ` <sup >?</sup > ([ _ GenericArgs _ ] | _ TypePathFn_ )<sup >?</sup >
103
125
>
104
126
> _ TypePathFn_ :\
105
127
> ` ( ` _ TypePathFnInputs_ <sup >?</sup > ` ) ` (` -> ` [ _ Type_ ] )<sup >?</sup >
@@ -110,7 +132,7 @@ S::f(); // Calls the inherent impl.
110
132
Type paths are used within type definitions, trait bounds, type parameter bounds,
111
133
and qualified paths.
112
134
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
114
136
because there is no ambiguity like there is in _ PathInExpression_ .
115
137
116
138
``` rust,ignore
@@ -303,15 +325,17 @@ mod without { // ::without
303
325
304
326
# fn main () {}
305
327
```
328
+
329
+ [ _GenericArgs_ ] : #paths-in-expressions
330
+ [ _Lifetime_ ] : trait-bounds.html
331
+ [ _Type_ ] : types.html
306
332
[ item ] : items.html
307
333
[ variable ] : variables.html
308
334
[ identifiers ] : identifiers.html
309
335
[ implementations ] : items/implementations.html
310
336
[ modules ] : items/modules.html
311
337
[ use declarations ] : items/use-declarations.html
312
338
[ IDENTIFIER ] : identifiers.html
313
- [ _Generics_ ] : items/generics.html
314
- [ _Type_ ] : types.html
315
339
[ `use` ] : items/use-declarations.html
316
340
[ attributes ] : attributes.html
317
341
[ enum ] : items/enumerations.html
0 commit comments