diff --git a/src/items.rs b/src/items.rs index 0e814644304..f9617acb53a 100644 --- a/src/items.rs +++ b/src/items.rs @@ -2342,7 +2342,14 @@ impl Rewrite for ast::Param { Ok(result) } else { - self.ty.rewrite_result(context, shape) + combine_strs_with_missing_comments( + context, + ¶m_attrs_result, + &self.ty.rewrite_result(context, shape)?, + span, + shape, + !has_multiple_attr_lines && !has_doc_comments, + ) } } } diff --git a/tests/source/issue-6561/trait-fn.rs b/tests/source/issue-6561/trait-fn.rs new file mode 100644 index 00000000000..f88c69dadda --- /dev/null +++ b/tests/source/issue-6561/trait-fn.rs @@ -0,0 +1,6 @@ +// rustfmt-edition: 2015 + +trait A { + fn f1(#[allow()] u32); + fn f2(#[allow()] u32, #[allow()] u32); +} \ No newline at end of file diff --git a/tests/source/issue-6561/variadic.rs b/tests/source/issue-6561/variadic.rs new file mode 100644 index 00000000000..6108d584d30 --- /dev/null +++ b/tests/source/issue-6561/variadic.rs @@ -0,0 +1,5 @@ +#[allow()] +unsafe extern "C" { + #[allow()] + pub fn foo(#[allow()] arg: *mut u8, #[allow()]...); +} \ No newline at end of file diff --git a/tests/target/issue-6561/trait-fn.rs b/tests/target/issue-6561/trait-fn.rs new file mode 100644 index 00000000000..a30396be561 --- /dev/null +++ b/tests/target/issue-6561/trait-fn.rs @@ -0,0 +1,6 @@ +// rustfmt-edition: 2015 + +trait A { + fn f1(#[allow()] u32); + fn f2(#[allow()] u32, #[allow()] u32); +} diff --git a/tests/target/issue-6561/variadic.rs b/tests/target/issue-6561/variadic.rs new file mode 100644 index 00000000000..bf5274f31e1 --- /dev/null +++ b/tests/target/issue-6561/variadic.rs @@ -0,0 +1,5 @@ +#[allow()] +unsafe extern "C" { + #[allow()] + pub fn foo(#[allow()] arg: *mut u8, #[allow()] ...); +}