File tree Expand file tree Collapse file tree 3 files changed +33
-3
lines changed Expand file tree Collapse file tree 3 files changed +33
-3
lines changed Original file line number Diff line number Diff line change @@ -274,6 +274,34 @@ impl crate::fold::Fold<TextRange> for LinearLocator<'_> {
274
274
keywords,
275
275
} )
276
276
}
277
+
278
+ fn fold_pattern_match_mapping (
279
+ & mut self ,
280
+ node : crate :: PatternMatchMapping < TextRange > ,
281
+ ) -> Result < crate :: PatternMatchMapping < Self :: TargetU > , Self :: Error > {
282
+ let crate :: PatternMatchMapping {
283
+ keys,
284
+ patterns,
285
+ rest,
286
+ range,
287
+ } = node;
288
+ let context = self . will_map_user ( & range) ;
289
+
290
+ let mut located_keys = Vec :: with_capacity ( keys. len ( ) ) ;
291
+ let mut located_patterns = Vec :: with_capacity ( patterns. len ( ) ) ;
292
+ for ( key, value) in keys. into_iter ( ) . zip ( patterns. into_iter ( ) ) {
293
+ located_keys. push ( self . fold ( key) ?) ;
294
+ located_patterns. push ( self . fold ( value) ?) ;
295
+ }
296
+ let rest = self . fold ( rest) ?;
297
+ let range = self . map_user ( range, context) ?;
298
+ Ok ( crate :: PatternMatchMapping {
299
+ keys : located_keys,
300
+ patterns : located_patterns,
301
+ rest,
302
+ range,
303
+ } )
304
+ }
277
305
}
278
306
279
307
struct LinearLookaheadLocator < ' a , ' b > ( & ' b mut LinearLocator < ' a > ) ;
Original file line number Diff line number Diff line change @@ -370,13 +370,14 @@ MatchStatement: ast::Stmt = {
370
370
.last()
371
371
.unwrap()
372
372
.end();
373
+ let subject_range = (subjects.first().unwrap().start()..subjects.last().unwrap().end()).into();
373
374
ast::Stmt::Match(
374
375
ast::StmtMatch {
375
376
subject: Box::new(ast::Expr::Tuple(
376
377
ast::ExprTuple {
377
378
elts: subjects,
378
379
ctx: ast::ExprContext::Load,
379
- range: (location..end_location).into()
380
+ range: subject_range,
380
381
},
381
382
)),
382
383
cases,
You can’t perform that action at this time.
0 commit comments