From ee0b6a77ba507ec9506e5fe02117188464ae936f Mon Sep 17 00:00:00 2001 From: pan93412 Date: Tue, 6 Sep 2022 22:59:41 +0800 Subject: [PATCH 1/4] test: Add issue #5533's case --- tests/target/issue_5533.rs | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 tests/target/issue_5533.rs diff --git a/tests/target/issue_5533.rs b/tests/target/issue_5533.rs new file mode 100644 index 00000000000..c3095a44022 --- /dev/null +++ b/tests/target/issue_5533.rs @@ -0,0 +1,6 @@ +// rustfmt-format_code_in_doc_comments: true + +struct TestStruct { + position_currency: String, // Currency for position of this contract. If not null, 1 contract = 1 positionCurrency. + pu: Option, // Previous event update sequense ("u" of previous message), -1 also means None +} From e6c288e28ee771f9389b047dd32f484fabe055f8 Mon Sep 17 00:00:00 2001 From: pan93412 Date: Thu, 8 Sep 2022 11:06:02 +0800 Subject: [PATCH 2/4] fix(comment): Prefer light_rewrite_comment if it is not a doccomment --- src/comment.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/comment.rs b/src/comment.rs index dec925e14c0..7da0f79bd09 100644 --- a/src/comment.rs +++ b/src/comment.rs @@ -365,7 +365,11 @@ fn identify_comment( trim_left_preserve_layout(first_group, shape.indent, config)? } else if !config.normalize_comments() && !config.wrap_comments() - && !config.format_code_in_doc_comments() + && !( + // `format_code_in_doc_comments` should only take effect on doc comments, + // so we only consider it when this comment block is a doc comment block. + is_doc_comment && config.format_code_in_doc_comments() + ) { light_rewrite_comment(first_group, shape.indent, config, is_doc_comment) } else { From 8fe00b2ba667ad6ba2b136c586f094fcc117f78e Mon Sep 17 00:00:00 2001 From: Yacin Tmimi Date: Mon, 24 Oct 2022 21:22:02 -0400 Subject: [PATCH 3/4] Add test case for issue 5568 --- tests/target/issue-5568.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 tests/target/issue-5568.rs diff --git a/tests/target/issue-5568.rs b/tests/target/issue-5568.rs new file mode 100644 index 00000000000..03ca3a4523c --- /dev/null +++ b/tests/target/issue-5568.rs @@ -0,0 +1,14 @@ +// rustfmt-max_width: 119 +// rustfmt-format_code_in_doc_comments: true + +mod libs { + fn mrbgems_sources() { + [ + "mrbgems/mruby-compiler/core/codegen.c", // Ruby parser and bytecode generation + "mrbgems/mruby-compiler/core/y.tab.c", // Ruby parser and bytecode generation + "mrbgems/mruby-metaprog/src/metaprog.c", // APIs on Kernel and Module for accessing classes and variables + "mrbgems/mruby-method/src/method.c", // `Method`, `UnboundMethod`, and method APIs on Kernel and Module + "mrbgems/mruby-pack/src/pack.c", // Array#pack and String#unpack + ] + } +} From badfa310708b0ddf24fc4a4f0df37966d5dc8977 Mon Sep 17 00:00:00 2001 From: Yacin Tmimi Date: Mon, 11 Sep 2023 01:22:40 -0400 Subject: [PATCH 4/4] add test case for issue 5907 --- tests/target/issue_5907.rs | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 tests/target/issue_5907.rs diff --git a/tests/target/issue_5907.rs b/tests/target/issue_5907.rs new file mode 100644 index 00000000000..144de636b9b --- /dev/null +++ b/tests/target/issue_5907.rs @@ -0,0 +1,6 @@ +// rustfmt-format_code_in_doc_comments: true + +// ``` +// [ +// ] +// ```