@@ -164,7 +164,13 @@ The [trait implementation] must also begin with the `unsafe` keyword.
164
164
165
165
## Parameter patterns
166
166
167
- The pattern for a trait function or method parameter is optional:
167
+ Function or method declarations without a body only allow [ IDENTIFIER] or
168
+ ` _ ` [ wild card] [ WildcardPattern ] patterns. ` mut ` [ IDENTIFIER] is currently
169
+ allowed, but it is deprecated and will become a hard error in the future.
170
+ <!-- https://github.com/rust-lang/rust/issues/35203 -->
171
+
172
+ In the 2015 edition, the pattern for a trait function or method parameter is
173
+ optional:
168
174
169
175
``` rust
170
176
trait T {
@@ -180,18 +186,16 @@ The kinds of patterns for parameters is limited to one of the following:
180
186
* ` & ` [ IDENTIFIER]
181
187
* ` && ` [ IDENTIFIER]
182
188
183
- Function or method declarations without a body only allow [ IDENTIFIER] or
184
- [ wild card] [ WildcardPattern ] patterns. ` mut ` [ IDENTIFIER] is currently
185
- allowed, but it is deprecated and will become a hard error in the future.
186
- <!-- https://github.com/rust-lang/rust/issues/35203 -->
187
-
188
- <!-- 2018 changes:
189
-
190
- Function or method parameter patterns are no longer optional, and are required.
191
-
192
- All irrefutable pattern kinds are allowed (as long as there is a body).
193
- -->
189
+ Beginning in the 2018 edition, function or method parameter patterns are no
190
+ longer optional. Also, all irrefutable patterns are allowed as long as there
191
+ is a body. Without a body, the limitations listed above are still in effect.
194
192
193
+ ``` rust,edition2018
194
+ trait T {
195
+ fn f1((a, b): (i32, i32)) {}
196
+ fn f2(_: (i32, i32)); // Cannot use tuple pattern without a body.
197
+ }
198
+ ```
195
199
196
200
[ IDENTIFIER ] : identifiers.html
197
201
[ WildcardPattern ] : patterns.html#wildcard-pattern
0 commit comments