Merge pull request #3510 from topecongiro/issue3509
Fix duplication of attributes on a match arm's body
This commit is contained in:
commit
760ec07978
@ -263,7 +263,7 @@ fn rewrite_match_arm(
|
||||
false,
|
||||
)?;
|
||||
|
||||
let arrow_span = mk_sp(arm.pats.last().unwrap().span.hi(), arm.body.span.lo());
|
||||
let arrow_span = mk_sp(arm.pats.last().unwrap().span.hi(), arm.body.span().lo());
|
||||
rewrite_match_body(
|
||||
context,
|
||||
&arm.body,
|
||||
@ -364,7 +364,8 @@ fn rewrite_match_body(
|
||||
shape.indent
|
||||
};
|
||||
|
||||
let forbid_same_line = has_guard && pats_str.contains('\n') && !is_empty_block;
|
||||
let forbid_same_line =
|
||||
(has_guard && pats_str.contains('\n') && !is_empty_block) || !body.attrs.is_empty();
|
||||
|
||||
// Look for comments between `=>` and the start of the body.
|
||||
let arrow_comment = {
|
||||
|
@ -217,3 +217,18 @@ fn stmt_expr_attributes() {
|
||||
#[must_use]
|
||||
foo = false ;
|
||||
}
|
||||
|
||||
// #3509
|
||||
fn issue3509() {
|
||||
match MyEnum {
|
||||
MyEnum::Option1 if cfg!(target_os = "windows") =>
|
||||
#[cfg(target_os = "windows")]{
|
||||
1
|
||||
}
|
||||
}
|
||||
match MyEnum {
|
||||
MyEnum::Option1 if cfg!(target_os = "windows") =>
|
||||
#[cfg(target_os = "windows")]
|
||||
1,
|
||||
}
|
||||
}
|
||||
|
@ -252,3 +252,21 @@ fn stmt_expr_attributes() {
|
||||
#[must_use]
|
||||
foo = false;
|
||||
}
|
||||
|
||||
// #3509
|
||||
fn issue3509() {
|
||||
match MyEnum {
|
||||
MyEnum::Option1 if cfg!(target_os = "windows") =>
|
||||
#[cfg(target_os = "windows")]
|
||||
{
|
||||
1
|
||||
}
|
||||
}
|
||||
match MyEnum {
|
||||
MyEnum::Option1 if cfg!(target_os = "windows") =>
|
||||
{
|
||||
#[cfg(target_os = "windows")]
|
||||
1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user