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<'_> {
274274 keywords,
275275 } )
276276 }
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+ }
277305}
278306
279307struct LinearLookaheadLocator < ' a , ' b > ( & ' b mut LinearLocator < ' a > ) ;
Original file line number Diff line number Diff line change @@ -370,13 +370,14 @@ MatchStatement: ast::Stmt = {
370370 .last()
371371 .unwrap()
372372 .end();
373+ let subject_range = (subjects.first().unwrap().start()..subjects.last().unwrap().end()).into();
373374 ast::Stmt::Match(
374375 ast::StmtMatch {
375376 subject: Box::new(ast::Expr::Tuple(
376377 ast::ExprTuple {
377378 elts: subjects,
378379 ctx: ast::ExprContext::Load,
379- range: (location..end_location).into()
380+ range: subject_range,
380381 },
381382 )),
382383 cases,
You can’t perform that action at this time.
0 commit comments