diff options
| -rw-r--r-- | src/matches.rs | 12 | ||||
| -rw-r--r-- | tests/source/issue-6147/case_rustfmt_v1.rs (renamed from tests/source/issue-6147/expect_changed.rs) | 2 | ||||
| -rw-r--r-- | tests/source/issue-6147/case_rustfmt_v2.rs | 20 | ||||
| -rw-r--r-- | tests/target/issue-6147/case_rustfmt_v1.rs (renamed from tests/target/issue-6147/expect_not_changed.rs) | 10 | ||||
| -rw-r--r-- | tests/target/issue-6147/case_rustfmt_v2.rs (renamed from tests/target/issue-6147/expect_changed.rs) | 2 |
5 files changed, 39 insertions, 7 deletions
diff --git a/src/matches.rs b/src/matches.rs index 9423175d693..e59413647a9 100644 --- a/src/matches.rs +++ b/src/matches.rs @@ -103,9 +103,15 @@ pub(crate) fn rewrite_match( let inner_attrs_str = if inner_attrs.is_empty() { String::new() } else { - inner_attrs - .rewrite(context, shape.block_indent(context.config.tab_spaces())) - .map(|s| format!("{}{}\n", nested_indent_str, s))? + if context.config.version() == Version::One { + inner_attrs + .rewrite(context, shape) + .map(|s| format!("{}{}\n", nested_indent_str, s))? + } else { + 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() { diff --git a/tests/source/issue-6147/expect_changed.rs b/tests/source/issue-6147/case_rustfmt_v1.rs index 709ef9edd7f..2ac2e0361c3 100644 --- a/tests/source/issue-6147/expect_changed.rs +++ b/tests/source/issue-6147/case_rustfmt_v1.rs @@ -1,3 +1,5 @@ +// rustfmt-version: One + pub fn main() { let a = Some(12); match a { diff --git a/tests/source/issue-6147/case_rustfmt_v2.rs b/tests/source/issue-6147/case_rustfmt_v2.rs new file mode 100644 index 00000000000..c1bf1ad4bf8 --- /dev/null +++ b/tests/source/issue-6147/case_rustfmt_v2.rs @@ -0,0 +1,20 @@ +// rustfmt-version: Two + +pub fn main() { +let a = Some(12); +match a { +#![attr1] +#![attr2] +#![attr3] +_ => None, +} + +{ +match a { +#![attr1] +#![attr2] +#![attr3] +_ => None, +} +} +} diff --git a/tests/target/issue-6147/expect_not_changed.rs b/tests/target/issue-6147/case_rustfmt_v1.rs index f662d88f852..75800012c63 100644 --- a/tests/target/issue-6147/expect_not_changed.rs +++ b/tests/target/issue-6147/case_rustfmt_v1.rs @@ -1,17 +1,19 @@ +// rustfmt-version: One + pub fn main() { let a = Some(12); match a { #![attr1] - #![attr2] - #![attr3] + #![attr2] + #![attr3] _ => None, } { match a { #![attr1] - #![attr2] - #![attr3] + #![attr2] + #![attr3] _ => None, } } diff --git a/tests/target/issue-6147/expect_changed.rs b/tests/target/issue-6147/case_rustfmt_v2.rs index f662d88f852..5e4220e7306 100644 --- a/tests/target/issue-6147/expect_changed.rs +++ b/tests/target/issue-6147/case_rustfmt_v2.rs @@ -1,3 +1,5 @@ +// rustfmt-version: Two + pub fn main() { let a = Some(12); match a { |
