File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -263,6 +263,38 @@ rules could require editing the affected patterns twice: once to desugar the
263
263
match ergonomics before adopting the new edition, and a second time to restore
264
264
match ergonomics after adoption of the new edition.
265
265
266
+ ## Macro subpatterns
267
+
268
+ Unfortunately, when a subpattern derives from a macro expansion, fully
269
+ desugaring the match ergonomics may not be possible. For example:
270
+
271
+ ``` rust
272
+ // ! crate foo (edition 2021)
273
+ #[macro_export]
274
+ macro_rules! foo {
275
+ ($ foo : ident ) => {
276
+ [$ foo ]
277
+ };
278
+ }
279
+ ```
280
+
281
+ ``` rust
282
+ // ! crate bar (edition 2021, want to migrate to 2024)
283
+ extern crate foo;
284
+ use foo :: * ;
285
+
286
+ fn main () {
287
+ let [[& x ], foo! (y )] = & [[& 0 ], [0 ]];
288
+ // ~^ WARN: the semantics of this pattern will change in edition 2024
289
+ let _ : i32 = x ;
290
+ let _ : & i32 = y ;
291
+ }
292
+ ```
293
+
294
+ In such cases, there is no possible machine-applicable suggstion we could emit
295
+ to produce code compatible with all editions (short of expanding the macro).
296
+ However, such code should be extremely rare in practice.
297
+
266
298
# Drawbacks
267
299
[ drawbacks ] : #drawbacks
268
300
You can’t perform that action at this time.
0 commit comments