add test and simplify code
This commit is contained in:
parent
22a4306a7e
commit
3854ce9aca
@ -103,12 +103,9 @@ pub(crate) fn rewrite_match(
|
||||
let inner_attrs_str = if inner_attrs.is_empty() {
|
||||
String::new()
|
||||
} else {
|
||||
shape.indent.block_indent(context.config);
|
||||
let result = inner_attrs
|
||||
.rewrite(context, shape)
|
||||
.map(|s| format!("{}{}\n", nested_indent_str, s))?;
|
||||
shape.indent.block_unindent(context.config);
|
||||
result
|
||||
inner_attrs
|
||||
.rewrite(context, shape.block_indent(context.config.tab_spaces()))
|
||||
.map(|s| format!("{}{}\n", nested_indent_str, s))?
|
||||
};
|
||||
|
||||
let open_brace_pos = if inner_attrs.is_empty() {
|
||||
|
18
tests/source/issue-6147/expect_changed.rs
Normal file
18
tests/source/issue-6147/expect_changed.rs
Normal file
@ -0,0 +1,18 @@
|
||||
pub fn main() {
|
||||
let a = Some(12)
|
||||
match a {
|
||||
#![attr1]
|
||||
#![attr2]
|
||||
#![attr3]
|
||||
_ => None,
|
||||
}
|
||||
|
||||
{
|
||||
match a {
|
||||
#![attr1]
|
||||
#![attr2]
|
||||
#![attr3]
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
}
|
18
tests/target/issue-6147/expect_changed.rs
Normal file
18
tests/target/issue-6147/expect_changed.rs
Normal file
@ -0,0 +1,18 @@
|
||||
pub fn main() {
|
||||
let a = Some(12)
|
||||
match a {
|
||||
#![attr1]
|
||||
#![attr2]
|
||||
#![attr3]
|
||||
_ => None,
|
||||
}
|
||||
|
||||
{
|
||||
match a {
|
||||
#![attr1]
|
||||
#![attr2]
|
||||
#![attr3]
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
}
|
18
tests/target/issue-6147/expect_not_changed.rs
Normal file
18
tests/target/issue-6147/expect_not_changed.rs
Normal file
@ -0,0 +1,18 @@
|
||||
pub fn main() {
|
||||
let a = Some(12)
|
||||
match a {
|
||||
#![attr1]
|
||||
#![attr2]
|
||||
#![attr3]
|
||||
_ => None,
|
||||
}
|
||||
|
||||
{
|
||||
match a {
|
||||
#![attr1]
|
||||
#![attr2]
|
||||
#![attr3]
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user