@@ -24,11 +24,11 @@ StructExprField ->
24
24
StructBase -> `..` Expression
25
25
26
26
StructExprTuple ->
27
- PathInExpression `(`
27
+ PathExpression `(`
28
28
( Expression (`,` Expression)* `,`? )?
29
29
`)`
30
30
31
- StructExprUnit -> PathInExpression
31
+ StructExprUnit -> PathExpression
32
32
```
33
33
34
34
r[ expr.struct.intro]
@@ -129,6 +129,20 @@ let c = Position; // `c` is a function that takes 3 arguments.
129
129
let pos = c (8 , 6 , 7 ); // Creates a `Position` value.
130
130
```
131
131
132
+ > [ !NOTE]
133
+ > While the grammar permits qualified paths, the last segment can't be a type alias:
134
+ >
135
+ > ``` rust
136
+ > trait Tr { type T ; }
137
+ > impl <T > Tr for T { type T = T ; }
138
+ >
139
+ > struct Tuple ();
140
+ > enum Enum { Tuple () }
141
+ >
142
+ > // <Unit as Tr>::T(); // causes an error -- `::T` is a type, not a value
143
+ > <Enum as Tr >:: T :: Tuple (); // OK
144
+ > ```
145
+
132
146
r [expr . struct . unit]
133
147
## Unit struct expression
134
148
@@ -142,6 +156,20 @@ let a = Gamma; // Gamma unit value.
142
156
let b = Gamma {}; // Exact same value as `a`.
143
157
```
144
158
159
+ > [ !NOTE]
160
+ > While the grammar permits qualified paths, the last segment can't be a type alias:
161
+ >
162
+ > ``` rust
163
+ > trait Tr { type T ; }
164
+ > impl <T > Tr for T { type T = T ; }
165
+ >
166
+ > struct Unit ;
167
+ > enum Enum { Unit }
168
+ >
169
+ > // <Unit as Tr>::T; // causes an error -- `::T` is a type, not a value
170
+ > <Enum as Tr >:: T :: Unit ; // OK
171
+ > ```
172
+
145
173
[call expression ]: call - expr . md
146
174
[enum variant ]: .. / items / enumerations . md
147
175
[if let ]: if - expr . md#if - let - expressions
0 commit comments