Parse a pattern with no arm
This commit is contained in:
parent
1ab7fc99af
commit
a445ba8a9d
@ -223,7 +223,7 @@ fn rewrite_match_arm(
|
||||
) -> Option<String> {
|
||||
let (missing_span, attrs_str) = if !arm.attrs.is_empty() {
|
||||
if contains_skip(&arm.attrs) {
|
||||
let (_, body) = flatten_arm_body(context, &arm.body, None);
|
||||
let (_, body) = flatten_arm_body(context, arm.body.as_deref()?, None);
|
||||
// `arm.span()` does not include trailing comma, add it manually.
|
||||
return Some(format!(
|
||||
"{}{}",
|
||||
@ -246,7 +246,7 @@ fn rewrite_match_arm(
|
||||
};
|
||||
|
||||
// Patterns
|
||||
let pat_shape = match &arm.body.kind {
|
||||
let pat_shape = match &arm.body.as_ref()?.kind {
|
||||
ast::ExprKind::Block(_, Some(label)) => {
|
||||
// Some block with a label ` => 'label: {`
|
||||
// 7 = ` => : {`
|
||||
@ -280,10 +280,10 @@ fn rewrite_match_arm(
|
||||
false,
|
||||
)?;
|
||||
|
||||
let arrow_span = mk_sp(arm.pat.span.hi(), arm.body.span().lo());
|
||||
let arrow_span = mk_sp(arm.pat.span.hi(), arm.body.as_ref()?.span().lo());
|
||||
rewrite_match_body(
|
||||
context,
|
||||
&arm.body,
|
||||
arm.body.as_ref()?,
|
||||
&lhs_str,
|
||||
shape,
|
||||
guard_str.contains('\n'),
|
||||
|
@ -97,7 +97,12 @@ fn span(&self) -> Span {
|
||||
} else {
|
||||
self.attrs[0].span.lo()
|
||||
};
|
||||
span_with_attrs_lo_hi!(self, lo, self.body.span.hi())
|
||||
let hi = if let Some(body) = &self.body {
|
||||
body.span.hi()
|
||||
} else {
|
||||
self.pat.span.hi()
|
||||
};
|
||||
span_with_attrs_lo_hi!(self, lo, hi)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user