File tree Expand file tree Collapse file tree 2 files changed +10
-5
lines changed Expand file tree Collapse file tree 2 files changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -223,7 +223,7 @@ fn rewrite_match_arm(
223223) -> Option < String > {
224224 let ( missing_span, attrs_str) = if !arm. attrs . is_empty ( ) {
225225 if contains_skip ( & arm. attrs ) {
226- let ( _, body) = flatten_arm_body ( context, & arm. body , None ) ;
226+ let ( _, body) = flatten_arm_body ( context, arm. body . as_deref ( ) ? , None ) ;
227227 // `arm.span()` does not include trailing comma, add it manually.
228228 return Some ( format ! (
229229 "{}{}" ,
@@ -246,7 +246,7 @@ fn rewrite_match_arm(
246246 } ;
247247
248248 // Patterns
249- let pat_shape = match & arm. body . kind {
249+ let pat_shape = match & arm. body . as_ref ( ) ? . kind {
250250 ast:: ExprKind :: Block ( _, Some ( label) ) => {
251251 // Some block with a label ` => 'label: {`
252252 // 7 = ` => : {`
@@ -280,10 +280,10 @@ fn rewrite_match_arm(
280280 false ,
281281 ) ?;
282282
283- let arrow_span = mk_sp ( arm. pat . span . hi ( ) , arm. body . span ( ) . lo ( ) ) ;
283+ let arrow_span = mk_sp ( arm. pat . span . hi ( ) , arm. body . as_ref ( ) ? . span ( ) . lo ( ) ) ;
284284 rewrite_match_body (
285285 context,
286- & arm. body ,
286+ arm. body . as_ref ( ) ? ,
287287 & lhs_str,
288288 shape,
289289 guard_str. contains ( '\n' ) ,
Original file line number Diff line number Diff line change @@ -97,7 +97,12 @@ impl Spanned for ast::Arm {
9797 } else {
9898 self . attrs [ 0 ] . span . lo ( )
9999 } ;
100- span_with_attrs_lo_hi ! ( self , lo, self . body. span. hi( ) )
100+ let hi = if let Some ( body) = & self . body {
101+ body. span . hi ( )
102+ } else {
103+ self . pat . span . hi ( )
104+ } ;
105+ span_with_attrs_lo_hi ! ( self , lo, hi)
101106 }
102107}
103108
You can’t perform that action at this time.
0 commit comments