From a653e30d9f5909407e5a28e091c5b923d7bd92db Mon Sep 17 00:00:00 2001
From: xiongmao86 <xiongmao86dev@sina.com>
Date: Wed, 1 May 2019 16:27:34 +0800
Subject: [PATCH 1/7] Add tests for #3417.

---
 ...utes_should_not_imply_format_doc_comments.rs | 15 +++++++++++++++
 ...ents_should_not_imply_format_doc_comments.rs | 16 ++++++++++++++++
 ...utes_should_not_imply_format_doc_comments.rs | 15 +++++++++++++++
 ...ents_should_not_imply_format_doc_comments.rs | 17 +++++++++++++++++
 4 files changed, 63 insertions(+)
 create mode 100644 tests/source/normalize_doc_attributes_should_not_imply_format_doc_comments.rs
 create mode 100644 tests/source/wrap_comments_should_not_imply_format_doc_comments.rs
 create mode 100644 tests/target/normalize_doc_attributes_should_not_imply_format_doc_comments.rs
 create mode 100644 tests/target/wrap_comments_should_not_imply_format_doc_comments.rs

diff --git a/tests/source/normalize_doc_attributes_should_not_imply_format_doc_comments.rs b/tests/source/normalize_doc_attributes_should_not_imply_format_doc_comments.rs
new file mode 100644
index 00000000000..a97705bfb3b
--- /dev/null
+++ b/tests/source/normalize_doc_attributes_should_not_imply_format_doc_comments.rs
@@ -0,0 +1,15 @@
+// rustfmt-normalize_doc_attributes: true
+
+/// Foo
+///
+/// # Example
+/// ```
+/// # #![cfg_attr(not(dox), feature(cfg_target_feature, target_feature, stdsimd))]
+/// # #![cfg_attr(not(dox), no_std)]
+/// fn foo() {  }
+/// ```
+///
+fn foo() {}
+
+#[doc = "Bar documents"]
+fn bar() {}
diff --git a/tests/source/wrap_comments_should_not_imply_format_doc_comments.rs b/tests/source/wrap_comments_should_not_imply_format_doc_comments.rs
new file mode 100644
index 00000000000..78b3ce146f2
--- /dev/null
+++ b/tests/source/wrap_comments_should_not_imply_format_doc_comments.rs
@@ -0,0 +1,16 @@
+// rustfmt-wrap_comments: true
+
+/// Foo
+///
+/// # Example
+/// ```
+/// # #![cfg_attr(not(dox), feature(cfg_target_feature, target_feature, stdsimd))]
+/// # #![cfg_attr(not(dox), no_std)]
+/// fn foo() {  }
+/// ```
+///
+fn foo() {}
+
+/// A long commment for wrapping
+/// This is a long long long long long long long long long long long long long long long long long long long long sentence.
+fn bar() {}
diff --git a/tests/target/normalize_doc_attributes_should_not_imply_format_doc_comments.rs b/tests/target/normalize_doc_attributes_should_not_imply_format_doc_comments.rs
new file mode 100644
index 00000000000..562d9565e9a
--- /dev/null
+++ b/tests/target/normalize_doc_attributes_should_not_imply_format_doc_comments.rs
@@ -0,0 +1,15 @@
+// rustfmt-normalize_doc_attributes: true
+
+/// Foo
+///
+/// # Example
+/// ```
+/// # #![cfg_attr(not(dox), feature(cfg_target_feature, target_feature, stdsimd))]
+/// # #![cfg_attr(not(dox), no_std)]
+/// fn foo() {  }
+/// ```
+///
+fn foo() {}
+
+///Bar documents
+fn bar() {}
diff --git a/tests/target/wrap_comments_should_not_imply_format_doc_comments.rs b/tests/target/wrap_comments_should_not_imply_format_doc_comments.rs
new file mode 100644
index 00000000000..a316179f820
--- /dev/null
+++ b/tests/target/wrap_comments_should_not_imply_format_doc_comments.rs
@@ -0,0 +1,17 @@
+// rustfmt-wrap_comments: true
+
+/// Foo
+///
+/// # Example
+/// ```
+/// # #![cfg_attr(not(dox), feature(cfg_target_feature, target_feature, stdsimd))]
+/// # #![cfg_attr(not(dox), no_std)]
+/// fn foo() {  }
+/// ```
+///
+fn foo() {}
+
+/// A long commment for wrapping
+/// This is a long long long long long long long long long long long long long
+/// long long long long long long long sentence.
+fn bar() {}

From 3300bb22a5a42ee5d6c768b2f192c4ac33abad67 Mon Sep 17 00:00:00 2001
From: xiongmao86 <xiongmao86dev@sina.com>
Date: Thu, 2 May 2019 21:11:13 +0800
Subject: [PATCH 2/7] Isolate format_doc_comment with normalize_comments and
 wrap_comments.

---
 src/comment.rs                                      | 13 ++++++++++---
 tests/source/issue-2520.rs                          |  1 +
 tests/source/issue-2523.rs                          |  1 +
 tests/source/issue-3055/original.rs                 |  1 +
 tests/source/itemized-blocks/no_wrap.rs             |  1 +
 tests/source/itemized-blocks/wrap.rs                |  1 +
 tests/target/issue-2520.rs                          |  1 +
 tests/target/issue-2523.rs                          |  1 +
 tests/target/issue-3055/original.rs                 |  1 +
 tests/target/itemized-blocks/no_wrap.rs             |  1 +
 tests/target/itemized-blocks/wrap.rs                |  1 +
 ...comments_should_not_imply_format_doc_comments.rs |  1 -
 12 files changed, 20 insertions(+), 4 deletions(-)

diff --git a/src/comment.rs b/src/comment.rs
index 797f75fc580..b8dcae23521 100644
--- a/src/comment.rs
+++ b/src/comment.rs
@@ -656,9 +656,16 @@ impl<'a> CommentRewrite<'a> {
                     _ => {
                         let mut config = self.fmt.config.clone();
                         config.set().wrap_comments(false);
-                        match crate::format_code_block(&self.code_block_buffer, &config) {
-                            Some(ref s) => trim_custom_comment_prefix(&s.snippet),
-                            None => trim_custom_comment_prefix(&self.code_block_buffer),
+                        if config.format_doc_comments() {
+                            if let Some(s) =
+                                crate::format_code_block(&self.code_block_buffer, &config)
+                            {
+                                trim_custom_comment_prefix(&s.snippet)
+                            } else {
+                                trim_custom_comment_prefix(&self.code_block_buffer)
+                            }
+                        } else {
+                            trim_custom_comment_prefix(&self.code_block_buffer)
                         }
                     }
                 };
diff --git a/tests/source/issue-2520.rs b/tests/source/issue-2520.rs
index d8ecf1f7d69..9ea522c4fe4 100644
--- a/tests/source/issue-2520.rs
+++ b/tests/source/issue-2520.rs
@@ -1,4 +1,5 @@
 // rustfmt-normalize_comments: true
+// rustfmt-format_doc_comments: true
 
 //! ```rust
 //! println!( "hello, world" );
diff --git a/tests/source/issue-2523.rs b/tests/source/issue-2523.rs
index 693d06e131a..71aed6ac535 100644
--- a/tests/source/issue-2523.rs
+++ b/tests/source/issue-2523.rs
@@ -1,4 +1,5 @@
 // rustfmt-normalize_comments: true
+// rustfmt-format_doc_comments: true
 
 // Do not unindent macro calls in comment with unformattable syntax.
 //! ```rust
diff --git a/tests/source/issue-3055/original.rs b/tests/source/issue-3055/original.rs
index 1f7d33ac5ae..eaf00afa3d3 100644
--- a/tests/source/issue-3055/original.rs
+++ b/tests/source/issue-3055/original.rs
@@ -1,4 +1,5 @@
 // rustfmt-wrap_comments: true
+// rustfmt-format_doc_comments: true
 
 /// Vestibulum elit nibh, rhoncus non, euismod sit amet, pretium eu, enim. Nunc commodo ultricies dui.
 ///
diff --git a/tests/source/itemized-blocks/no_wrap.rs b/tests/source/itemized-blocks/no_wrap.rs
index 6354d39eb96..a0c546ad18e 100644
--- a/tests/source/itemized-blocks/no_wrap.rs
+++ b/tests/source/itemized-blocks/no_wrap.rs
@@ -1,4 +1,5 @@
 // rustfmt-normalize_comments: true
+// rustfmt-format_doc_comments: true
 
 //! This is a list:
 //!  * Outer
diff --git a/tests/source/itemized-blocks/wrap.rs b/tests/source/itemized-blocks/wrap.rs
index 61448dce852..14fc8daa2e9 100644
--- a/tests/source/itemized-blocks/wrap.rs
+++ b/tests/source/itemized-blocks/wrap.rs
@@ -1,4 +1,5 @@
 // rustfmt-wrap_comments: true
+// rustfmt-format_doc_comments: true
 // rustfmt-max_width: 50
 
 //! This is a list:
diff --git a/tests/target/issue-2520.rs b/tests/target/issue-2520.rs
index 012921f441c..7d22b2b665a 100644
--- a/tests/target/issue-2520.rs
+++ b/tests/target/issue-2520.rs
@@ -1,4 +1,5 @@
 // rustfmt-normalize_comments: true
+// rustfmt-format_doc_comments: true
 
 //! ```rust
 //! println!("hello, world");
diff --git a/tests/target/issue-2523.rs b/tests/target/issue-2523.rs
index c62e058cde6..c0118e53780 100644
--- a/tests/target/issue-2523.rs
+++ b/tests/target/issue-2523.rs
@@ -1,4 +1,5 @@
 // rustfmt-normalize_comments: true
+// rustfmt-format_doc_comments: true
 
 // Do not unindent macro calls in comment with unformattable syntax.
 //! ```rust
diff --git a/tests/target/issue-3055/original.rs b/tests/target/issue-3055/original.rs
index 1455ac1a916..1fb35d50682 100644
--- a/tests/target/issue-3055/original.rs
+++ b/tests/target/issue-3055/original.rs
@@ -1,4 +1,5 @@
 // rustfmt-wrap_comments: true
+// rustfmt-format_doc_comments: true
 
 /// Vestibulum elit nibh, rhoncus non, euismod sit amet, pretium eu, enim. Nunc
 /// commodo ultricies dui.
diff --git a/tests/target/itemized-blocks/no_wrap.rs b/tests/target/itemized-blocks/no_wrap.rs
index 945c3fbbca0..a1f9c39a115 100644
--- a/tests/target/itemized-blocks/no_wrap.rs
+++ b/tests/target/itemized-blocks/no_wrap.rs
@@ -1,4 +1,5 @@
 // rustfmt-normalize_comments: true
+// rustfmt-format_doc_comments: true
 
 //! This is a list:
 //!  * Outer
diff --git a/tests/target/itemized-blocks/wrap.rs b/tests/target/itemized-blocks/wrap.rs
index 0a21c474ca6..967a38b91ae 100644
--- a/tests/target/itemized-blocks/wrap.rs
+++ b/tests/target/itemized-blocks/wrap.rs
@@ -1,4 +1,5 @@
 // rustfmt-wrap_comments: true
+// rustfmt-format_doc_comments: true
 // rustfmt-max_width: 50
 
 //! This is a list:
diff --git a/tests/target/wrap_comments_should_not_imply_format_doc_comments.rs b/tests/target/wrap_comments_should_not_imply_format_doc_comments.rs
index a316179f820..d61d4d7c216 100644
--- a/tests/target/wrap_comments_should_not_imply_format_doc_comments.rs
+++ b/tests/target/wrap_comments_should_not_imply_format_doc_comments.rs
@@ -8,7 +8,6 @@
 /// # #![cfg_attr(not(dox), no_std)]
 /// fn foo() {  }
 /// ```
-///
 fn foo() {}
 
 /// A long commment for wrapping

From 6a6924c12b2ad9a99686df9b3d65fd2dd8647665 Mon Sep 17 00:00:00 2001
From: xiongmao86 <xiongmao86dev@sina.com>
Date: Mon, 6 May 2019 19:45:34 +0800
Subject: [PATCH 3/7] Change config option from format_doc_comments to
 format_code_in_doc_comments.

---
 Configurations.md                                | 4 ++--
 src/comment.rs                                   | 4 ++--
 src/config/mod.rs                                | 2 +-
 tests/source/doc-comment-with-example.rs         | 2 +-
 tests/source/invalid-rust-code-in-doc-comment.rs | 2 +-
 tests/source/issue-2520.rs                       | 2 +-
 tests/source/issue-2523.rs                       | 2 +-
 tests/source/issue-3055/original.rs              | 2 +-
 tests/source/itemized-blocks/no_wrap.rs          | 2 +-
 tests/source/itemized-blocks/wrap.rs             | 2 +-
 tests/target/doc-comment-with-example.rs         | 2 +-
 tests/target/invalid-rust-code-in-doc-comment.rs | 2 +-
 tests/target/issue-2520.rs                       | 2 +-
 tests/target/issue-2523.rs                       | 2 +-
 tests/target/issue-3055/original.rs              | 2 +-
 tests/target/itemized-blocks/no_wrap.rs          | 2 +-
 tests/target/itemized-blocks/wrap.rs             | 2 +-
 17 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/Configurations.md b/Configurations.md
index 7557b3637f1..dc91a3d255a 100644
--- a/Configurations.md
+++ b/Configurations.md
@@ -1978,9 +1978,9 @@ fn main() {
 }
 ```
 
-## `format_doc_comments`
+## `format_code_in_doc_comments`
 
-Format doc comments.
+Format code snippet included in doc comments.
 
 - **Default value**: `false`
 - **Possible values**: `true`, `false`
diff --git a/src/comment.rs b/src/comment.rs
index b8dcae23521..0a3062583c5 100644
--- a/src/comment.rs
+++ b/src/comment.rs
@@ -353,7 +353,7 @@ fn identify_comment(
             trim_left_preserve_layout(first_group, shape.indent, config)?
         } else if !config.normalize_comments()
             && !config.wrap_comments()
-            && !config.format_doc_comments()
+            && !config.format_code_in_doc_comments()
         {
             light_rewrite_comment(first_group, shape.indent, config, is_doc_comment)
         } else {
@@ -656,7 +656,7 @@ impl<'a> CommentRewrite<'a> {
                     _ => {
                         let mut config = self.fmt.config.clone();
                         config.set().wrap_comments(false);
-                        if config.format_doc_comments() {
+                        if config.format_code_in_doc_comments() {
                             if let Some(s) =
                                 crate::format_code_block(&self.code_block_buffer, &config)
                             {
diff --git a/src/config/mod.rs b/src/config/mod.rs
index c0221e93e02..f04074e4f32 100644
--- a/src/config/mod.rs
+++ b/src/config/mod.rs
@@ -37,7 +37,7 @@ create_config! {
 
     // Comments. macros, and strings
     wrap_comments: bool, false, false, "Break comments to fit on the line";
-    format_doc_comments: bool, false, false, "Format doc comments.";
+    format_code_in_doc_comments: bool, false, false, "Format the code snippet in doc comments.";
     comment_width: usize, 80, false,
         "Maximum length of comments. No effect unless wrap_comments = true";
     normalize_comments: bool, false, false, "Convert /* */ comments to // comments where possible";
diff --git a/tests/source/doc-comment-with-example.rs b/tests/source/doc-comment-with-example.rs
index 58d98acfa25..e74ceefd195 100644
--- a/tests/source/doc-comment-with-example.rs
+++ b/tests/source/doc-comment-with-example.rs
@@ -1,4 +1,4 @@
-// rustfmt-format_doc_comments: true
+// rustfmt-format_code_in_doc_comments: true
 
 /// Foo
 ///
diff --git a/tests/source/invalid-rust-code-in-doc-comment.rs b/tests/source/invalid-rust-code-in-doc-comment.rs
index 6d33dcfce55..835b0261b76 100644
--- a/tests/source/invalid-rust-code-in-doc-comment.rs
+++ b/tests/source/invalid-rust-code-in-doc-comment.rs
@@ -1,4 +1,4 @@
-// rustfmt-format_doc_comments: true
+// rustfmt-format_code_in_doc_comments: true
 
 /// ```rust
 /// if (true) { … }
diff --git a/tests/source/issue-2520.rs b/tests/source/issue-2520.rs
index 9ea522c4fe4..5a23f10430d 100644
--- a/tests/source/issue-2520.rs
+++ b/tests/source/issue-2520.rs
@@ -1,5 +1,5 @@
 // rustfmt-normalize_comments: true
-// rustfmt-format_doc_comments: true
+// rustfmt-format_code_in_doc_comments: true
 
 //! ```rust
 //! println!( "hello, world" );
diff --git a/tests/source/issue-2523.rs b/tests/source/issue-2523.rs
index 71aed6ac535..491d5c38fc2 100644
--- a/tests/source/issue-2523.rs
+++ b/tests/source/issue-2523.rs
@@ -1,5 +1,5 @@
 // rustfmt-normalize_comments: true
-// rustfmt-format_doc_comments: true
+// rustfmt-format_code_in_doc_comments: true
 
 // Do not unindent macro calls in comment with unformattable syntax.
 //! ```rust
diff --git a/tests/source/issue-3055/original.rs b/tests/source/issue-3055/original.rs
index eaf00afa3d3..ad505547ac0 100644
--- a/tests/source/issue-3055/original.rs
+++ b/tests/source/issue-3055/original.rs
@@ -1,5 +1,5 @@
 // rustfmt-wrap_comments: true
-// rustfmt-format_doc_comments: true
+// rustfmt-format_code_in_doc_comments: true
 
 /// Vestibulum elit nibh, rhoncus non, euismod sit amet, pretium eu, enim. Nunc commodo ultricies dui.
 ///
diff --git a/tests/source/itemized-blocks/no_wrap.rs b/tests/source/itemized-blocks/no_wrap.rs
index a0c546ad18e..a7b6a10a010 100644
--- a/tests/source/itemized-blocks/no_wrap.rs
+++ b/tests/source/itemized-blocks/no_wrap.rs
@@ -1,5 +1,5 @@
 // rustfmt-normalize_comments: true
-// rustfmt-format_doc_comments: true
+// rustfmt-format_code_in_doc_comments: true
 
 //! This is a list:
 //!  * Outer
diff --git a/tests/source/itemized-blocks/wrap.rs b/tests/source/itemized-blocks/wrap.rs
index 14fc8daa2e9..955cc698b79 100644
--- a/tests/source/itemized-blocks/wrap.rs
+++ b/tests/source/itemized-blocks/wrap.rs
@@ -1,5 +1,5 @@
 // rustfmt-wrap_comments: true
-// rustfmt-format_doc_comments: true
+// rustfmt-format_code_in_doc_comments: true
 // rustfmt-max_width: 50
 
 //! This is a list:
diff --git a/tests/target/doc-comment-with-example.rs b/tests/target/doc-comment-with-example.rs
index bec931d13c7..c5a4e779ea2 100644
--- a/tests/target/doc-comment-with-example.rs
+++ b/tests/target/doc-comment-with-example.rs
@@ -1,4 +1,4 @@
-// rustfmt-format_doc_comments: true
+// rustfmt-format_code_in_doc_comments: true
 
 /// Foo
 ///
diff --git a/tests/target/invalid-rust-code-in-doc-comment.rs b/tests/target/invalid-rust-code-in-doc-comment.rs
index 2593410a418..f8479d4e345 100644
--- a/tests/target/invalid-rust-code-in-doc-comment.rs
+++ b/tests/target/invalid-rust-code-in-doc-comment.rs
@@ -1,4 +1,4 @@
-// rustfmt-format_doc_comments: true
+// rustfmt-format_code_in_doc_comments: true
 
 /// ```rust
 /// if (true) { … }
diff --git a/tests/target/issue-2520.rs b/tests/target/issue-2520.rs
index 7d22b2b665a..7c134d3972b 100644
--- a/tests/target/issue-2520.rs
+++ b/tests/target/issue-2520.rs
@@ -1,5 +1,5 @@
 // rustfmt-normalize_comments: true
-// rustfmt-format_doc_comments: true
+// rustfmt-format_code_in_doc_comments: true
 
 //! ```rust
 //! println!("hello, world");
diff --git a/tests/target/issue-2523.rs b/tests/target/issue-2523.rs
index c0118e53780..612f93249ac 100644
--- a/tests/target/issue-2523.rs
+++ b/tests/target/issue-2523.rs
@@ -1,5 +1,5 @@
 // rustfmt-normalize_comments: true
-// rustfmt-format_doc_comments: true
+// rustfmt-format_code_in_doc_comments: true
 
 // Do not unindent macro calls in comment with unformattable syntax.
 //! ```rust
diff --git a/tests/target/issue-3055/original.rs b/tests/target/issue-3055/original.rs
index 1fb35d50682..de27ccfb344 100644
--- a/tests/target/issue-3055/original.rs
+++ b/tests/target/issue-3055/original.rs
@@ -1,5 +1,5 @@
 // rustfmt-wrap_comments: true
-// rustfmt-format_doc_comments: true
+// rustfmt-format_code_in_doc_comments: true
 
 /// Vestibulum elit nibh, rhoncus non, euismod sit amet, pretium eu, enim. Nunc
 /// commodo ultricies dui.
diff --git a/tests/target/itemized-blocks/no_wrap.rs b/tests/target/itemized-blocks/no_wrap.rs
index a1f9c39a115..de885638272 100644
--- a/tests/target/itemized-blocks/no_wrap.rs
+++ b/tests/target/itemized-blocks/no_wrap.rs
@@ -1,5 +1,5 @@
 // rustfmt-normalize_comments: true
-// rustfmt-format_doc_comments: true
+// rustfmt-format_code_in_doc_comments: true
 
 //! This is a list:
 //!  * Outer
diff --git a/tests/target/itemized-blocks/wrap.rs b/tests/target/itemized-blocks/wrap.rs
index 967a38b91ae..a4907303c9e 100644
--- a/tests/target/itemized-blocks/wrap.rs
+++ b/tests/target/itemized-blocks/wrap.rs
@@ -1,5 +1,5 @@
 // rustfmt-wrap_comments: true
-// rustfmt-format_doc_comments: true
+// rustfmt-format_code_in_doc_comments: true
 // rustfmt-max_width: 50
 
 //! This is a list:

From 97d7216cd4ebce511d5707ec5dd8b7b8fe771cba Mon Sep 17 00:00:00 2001
From: xiongmao86 <xiongmao86dev@sina.com>
Date: Wed, 8 May 2019 16:51:32 +0800
Subject: [PATCH 4/7] Revert "Change config option from format_doc_comments to
 format_code_in_doc_comments."

This reverts commit 6a6924c12b2ad9a99686df9b3d65fd2dd8647665.
---
 Configurations.md                                | 4 ++--
 src/comment.rs                                   | 4 ++--
 src/config/mod.rs                                | 2 +-
 tests/source/doc-comment-with-example.rs         | 2 +-
 tests/source/invalid-rust-code-in-doc-comment.rs | 2 +-
 tests/source/issue-2520.rs                       | 2 +-
 tests/source/issue-2523.rs                       | 2 +-
 tests/source/issue-3055/original.rs              | 2 +-
 tests/source/itemized-blocks/no_wrap.rs          | 2 +-
 tests/source/itemized-blocks/wrap.rs             | 2 +-
 tests/target/doc-comment-with-example.rs         | 2 +-
 tests/target/invalid-rust-code-in-doc-comment.rs | 2 +-
 tests/target/issue-2520.rs                       | 2 +-
 tests/target/issue-2523.rs                       | 2 +-
 tests/target/issue-3055/original.rs              | 2 +-
 tests/target/itemized-blocks/no_wrap.rs          | 2 +-
 tests/target/itemized-blocks/wrap.rs             | 2 +-
 17 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/Configurations.md b/Configurations.md
index dc91a3d255a..7557b3637f1 100644
--- a/Configurations.md
+++ b/Configurations.md
@@ -1978,9 +1978,9 @@ fn main() {
 }
 ```
 
-## `format_code_in_doc_comments`
+## `format_doc_comments`
 
-Format code snippet included in doc comments.
+Format doc comments.
 
 - **Default value**: `false`
 - **Possible values**: `true`, `false`
diff --git a/src/comment.rs b/src/comment.rs
index 0a3062583c5..b8dcae23521 100644
--- a/src/comment.rs
+++ b/src/comment.rs
@@ -353,7 +353,7 @@ 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()
+            && !config.format_doc_comments()
         {
             light_rewrite_comment(first_group, shape.indent, config, is_doc_comment)
         } else {
@@ -656,7 +656,7 @@ impl<'a> CommentRewrite<'a> {
                     _ => {
                         let mut config = self.fmt.config.clone();
                         config.set().wrap_comments(false);
-                        if config.format_code_in_doc_comments() {
+                        if config.format_doc_comments() {
                             if let Some(s) =
                                 crate::format_code_block(&self.code_block_buffer, &config)
                             {
diff --git a/src/config/mod.rs b/src/config/mod.rs
index f04074e4f32..c0221e93e02 100644
--- a/src/config/mod.rs
+++ b/src/config/mod.rs
@@ -37,7 +37,7 @@ create_config! {
 
     // Comments. macros, and strings
     wrap_comments: bool, false, false, "Break comments to fit on the line";
-    format_code_in_doc_comments: bool, false, false, "Format the code snippet in doc comments.";
+    format_doc_comments: bool, false, false, "Format doc comments.";
     comment_width: usize, 80, false,
         "Maximum length of comments. No effect unless wrap_comments = true";
     normalize_comments: bool, false, false, "Convert /* */ comments to // comments where possible";
diff --git a/tests/source/doc-comment-with-example.rs b/tests/source/doc-comment-with-example.rs
index e74ceefd195..58d98acfa25 100644
--- a/tests/source/doc-comment-with-example.rs
+++ b/tests/source/doc-comment-with-example.rs
@@ -1,4 +1,4 @@
-// rustfmt-format_code_in_doc_comments: true
+// rustfmt-format_doc_comments: true
 
 /// Foo
 ///
diff --git a/tests/source/invalid-rust-code-in-doc-comment.rs b/tests/source/invalid-rust-code-in-doc-comment.rs
index 835b0261b76..6d33dcfce55 100644
--- a/tests/source/invalid-rust-code-in-doc-comment.rs
+++ b/tests/source/invalid-rust-code-in-doc-comment.rs
@@ -1,4 +1,4 @@
-// rustfmt-format_code_in_doc_comments: true
+// rustfmt-format_doc_comments: true
 
 /// ```rust
 /// if (true) { … }
diff --git a/tests/source/issue-2520.rs b/tests/source/issue-2520.rs
index 5a23f10430d..9ea522c4fe4 100644
--- a/tests/source/issue-2520.rs
+++ b/tests/source/issue-2520.rs
@@ -1,5 +1,5 @@
 // rustfmt-normalize_comments: true
-// rustfmt-format_code_in_doc_comments: true
+// rustfmt-format_doc_comments: true
 
 //! ```rust
 //! println!( "hello, world" );
diff --git a/tests/source/issue-2523.rs b/tests/source/issue-2523.rs
index 491d5c38fc2..71aed6ac535 100644
--- a/tests/source/issue-2523.rs
+++ b/tests/source/issue-2523.rs
@@ -1,5 +1,5 @@
 // rustfmt-normalize_comments: true
-// rustfmt-format_code_in_doc_comments: true
+// rustfmt-format_doc_comments: true
 
 // Do not unindent macro calls in comment with unformattable syntax.
 //! ```rust
diff --git a/tests/source/issue-3055/original.rs b/tests/source/issue-3055/original.rs
index ad505547ac0..eaf00afa3d3 100644
--- a/tests/source/issue-3055/original.rs
+++ b/tests/source/issue-3055/original.rs
@@ -1,5 +1,5 @@
 // rustfmt-wrap_comments: true
-// rustfmt-format_code_in_doc_comments: true
+// rustfmt-format_doc_comments: true
 
 /// Vestibulum elit nibh, rhoncus non, euismod sit amet, pretium eu, enim. Nunc commodo ultricies dui.
 ///
diff --git a/tests/source/itemized-blocks/no_wrap.rs b/tests/source/itemized-blocks/no_wrap.rs
index a7b6a10a010..a0c546ad18e 100644
--- a/tests/source/itemized-blocks/no_wrap.rs
+++ b/tests/source/itemized-blocks/no_wrap.rs
@@ -1,5 +1,5 @@
 // rustfmt-normalize_comments: true
-// rustfmt-format_code_in_doc_comments: true
+// rustfmt-format_doc_comments: true
 
 //! This is a list:
 //!  * Outer
diff --git a/tests/source/itemized-blocks/wrap.rs b/tests/source/itemized-blocks/wrap.rs
index 955cc698b79..14fc8daa2e9 100644
--- a/tests/source/itemized-blocks/wrap.rs
+++ b/tests/source/itemized-blocks/wrap.rs
@@ -1,5 +1,5 @@
 // rustfmt-wrap_comments: true
-// rustfmt-format_code_in_doc_comments: true
+// rustfmt-format_doc_comments: true
 // rustfmt-max_width: 50
 
 //! This is a list:
diff --git a/tests/target/doc-comment-with-example.rs b/tests/target/doc-comment-with-example.rs
index c5a4e779ea2..bec931d13c7 100644
--- a/tests/target/doc-comment-with-example.rs
+++ b/tests/target/doc-comment-with-example.rs
@@ -1,4 +1,4 @@
-// rustfmt-format_code_in_doc_comments: true
+// rustfmt-format_doc_comments: true
 
 /// Foo
 ///
diff --git a/tests/target/invalid-rust-code-in-doc-comment.rs b/tests/target/invalid-rust-code-in-doc-comment.rs
index f8479d4e345..2593410a418 100644
--- a/tests/target/invalid-rust-code-in-doc-comment.rs
+++ b/tests/target/invalid-rust-code-in-doc-comment.rs
@@ -1,4 +1,4 @@
-// rustfmt-format_code_in_doc_comments: true
+// rustfmt-format_doc_comments: true
 
 /// ```rust
 /// if (true) { … }
diff --git a/tests/target/issue-2520.rs b/tests/target/issue-2520.rs
index 7c134d3972b..7d22b2b665a 100644
--- a/tests/target/issue-2520.rs
+++ b/tests/target/issue-2520.rs
@@ -1,5 +1,5 @@
 // rustfmt-normalize_comments: true
-// rustfmt-format_code_in_doc_comments: true
+// rustfmt-format_doc_comments: true
 
 //! ```rust
 //! println!("hello, world");
diff --git a/tests/target/issue-2523.rs b/tests/target/issue-2523.rs
index 612f93249ac..c0118e53780 100644
--- a/tests/target/issue-2523.rs
+++ b/tests/target/issue-2523.rs
@@ -1,5 +1,5 @@
 // rustfmt-normalize_comments: true
-// rustfmt-format_code_in_doc_comments: true
+// rustfmt-format_doc_comments: true
 
 // Do not unindent macro calls in comment with unformattable syntax.
 //! ```rust
diff --git a/tests/target/issue-3055/original.rs b/tests/target/issue-3055/original.rs
index de27ccfb344..1fb35d50682 100644
--- a/tests/target/issue-3055/original.rs
+++ b/tests/target/issue-3055/original.rs
@@ -1,5 +1,5 @@
 // rustfmt-wrap_comments: true
-// rustfmt-format_code_in_doc_comments: true
+// rustfmt-format_doc_comments: true
 
 /// Vestibulum elit nibh, rhoncus non, euismod sit amet, pretium eu, enim. Nunc
 /// commodo ultricies dui.
diff --git a/tests/target/itemized-blocks/no_wrap.rs b/tests/target/itemized-blocks/no_wrap.rs
index de885638272..a1f9c39a115 100644
--- a/tests/target/itemized-blocks/no_wrap.rs
+++ b/tests/target/itemized-blocks/no_wrap.rs
@@ -1,5 +1,5 @@
 // rustfmt-normalize_comments: true
-// rustfmt-format_code_in_doc_comments: true
+// rustfmt-format_doc_comments: true
 
 //! This is a list:
 //!  * Outer
diff --git a/tests/target/itemized-blocks/wrap.rs b/tests/target/itemized-blocks/wrap.rs
index a4907303c9e..967a38b91ae 100644
--- a/tests/target/itemized-blocks/wrap.rs
+++ b/tests/target/itemized-blocks/wrap.rs
@@ -1,5 +1,5 @@
 // rustfmt-wrap_comments: true
-// rustfmt-format_code_in_doc_comments: true
+// rustfmt-format_doc_comments: true
 // rustfmt-max_width: 50
 
 //! This is a list:

From de425f1eb881bfe96478388147333a406b3725a4 Mon Sep 17 00:00:00 2001
From: xiongmao86 <xiongmao86dev@sina.com>
Date: Wed, 8 May 2019 16:56:53 +0800
Subject: [PATCH 5/7] Fix docs in Configurations.md.

---
 Configurations.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Configurations.md b/Configurations.md
index 7557b3637f1..f51c464b6f9 100644
--- a/Configurations.md
+++ b/Configurations.md
@@ -1980,7 +1980,7 @@ fn main() {
 
 ## `format_doc_comments`
 
-Format doc comments.
+Format code snippet in doc comments.
 
 - **Default value**: `false`
 - **Possible values**: `true`, `false`

From a956a2053257131f794bcad6a88edf5370b93e23 Mon Sep 17 00:00:00 2001
From: xiongmao86 <xiongmao86dev@sina.com>
Date: Fri, 10 May 2019 21:22:52 +0800
Subject: [PATCH 6/7] Revert "Revert "Change config option from
 format_doc_comments to format_code_in_doc_comments.""

This reverts commit 97d7216cd4ebce511d5707ec5dd8b7b8fe771cba.
---
 Configurations.md                                | 4 ++--
 src/comment.rs                                   | 4 ++--
 src/config/mod.rs                                | 2 +-
 tests/source/doc-comment-with-example.rs         | 2 +-
 tests/source/invalid-rust-code-in-doc-comment.rs | 2 +-
 tests/source/issue-2520.rs                       | 2 +-
 tests/source/issue-2523.rs                       | 2 +-
 tests/source/issue-3055/original.rs              | 2 +-
 tests/source/itemized-blocks/no_wrap.rs          | 2 +-
 tests/source/itemized-blocks/wrap.rs             | 2 +-
 tests/target/doc-comment-with-example.rs         | 2 +-
 tests/target/invalid-rust-code-in-doc-comment.rs | 2 +-
 tests/target/issue-2520.rs                       | 2 +-
 tests/target/issue-2523.rs                       | 2 +-
 tests/target/issue-3055/original.rs              | 2 +-
 tests/target/itemized-blocks/no_wrap.rs          | 2 +-
 tests/target/itemized-blocks/wrap.rs             | 2 +-
 17 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/Configurations.md b/Configurations.md
index f51c464b6f9..dc91a3d255a 100644
--- a/Configurations.md
+++ b/Configurations.md
@@ -1978,9 +1978,9 @@ fn main() {
 }
 ```
 
-## `format_doc_comments`
+## `format_code_in_doc_comments`
 
-Format code snippet in doc comments.
+Format code snippet included in doc comments.
 
 - **Default value**: `false`
 - **Possible values**: `true`, `false`
diff --git a/src/comment.rs b/src/comment.rs
index b8dcae23521..0a3062583c5 100644
--- a/src/comment.rs
+++ b/src/comment.rs
@@ -353,7 +353,7 @@ fn identify_comment(
             trim_left_preserve_layout(first_group, shape.indent, config)?
         } else if !config.normalize_comments()
             && !config.wrap_comments()
-            && !config.format_doc_comments()
+            && !config.format_code_in_doc_comments()
         {
             light_rewrite_comment(first_group, shape.indent, config, is_doc_comment)
         } else {
@@ -656,7 +656,7 @@ impl<'a> CommentRewrite<'a> {
                     _ => {
                         let mut config = self.fmt.config.clone();
                         config.set().wrap_comments(false);
-                        if config.format_doc_comments() {
+                        if config.format_code_in_doc_comments() {
                             if let Some(s) =
                                 crate::format_code_block(&self.code_block_buffer, &config)
                             {
diff --git a/src/config/mod.rs b/src/config/mod.rs
index c0221e93e02..f04074e4f32 100644
--- a/src/config/mod.rs
+++ b/src/config/mod.rs
@@ -37,7 +37,7 @@ create_config! {
 
     // Comments. macros, and strings
     wrap_comments: bool, false, false, "Break comments to fit on the line";
-    format_doc_comments: bool, false, false, "Format doc comments.";
+    format_code_in_doc_comments: bool, false, false, "Format the code snippet in doc comments.";
     comment_width: usize, 80, false,
         "Maximum length of comments. No effect unless wrap_comments = true";
     normalize_comments: bool, false, false, "Convert /* */ comments to // comments where possible";
diff --git a/tests/source/doc-comment-with-example.rs b/tests/source/doc-comment-with-example.rs
index 58d98acfa25..e74ceefd195 100644
--- a/tests/source/doc-comment-with-example.rs
+++ b/tests/source/doc-comment-with-example.rs
@@ -1,4 +1,4 @@
-// rustfmt-format_doc_comments: true
+// rustfmt-format_code_in_doc_comments: true
 
 /// Foo
 ///
diff --git a/tests/source/invalid-rust-code-in-doc-comment.rs b/tests/source/invalid-rust-code-in-doc-comment.rs
index 6d33dcfce55..835b0261b76 100644
--- a/tests/source/invalid-rust-code-in-doc-comment.rs
+++ b/tests/source/invalid-rust-code-in-doc-comment.rs
@@ -1,4 +1,4 @@
-// rustfmt-format_doc_comments: true
+// rustfmt-format_code_in_doc_comments: true
 
 /// ```rust
 /// if (true) { … }
diff --git a/tests/source/issue-2520.rs b/tests/source/issue-2520.rs
index 9ea522c4fe4..5a23f10430d 100644
--- a/tests/source/issue-2520.rs
+++ b/tests/source/issue-2520.rs
@@ -1,5 +1,5 @@
 // rustfmt-normalize_comments: true
-// rustfmt-format_doc_comments: true
+// rustfmt-format_code_in_doc_comments: true
 
 //! ```rust
 //! println!( "hello, world" );
diff --git a/tests/source/issue-2523.rs b/tests/source/issue-2523.rs
index 71aed6ac535..491d5c38fc2 100644
--- a/tests/source/issue-2523.rs
+++ b/tests/source/issue-2523.rs
@@ -1,5 +1,5 @@
 // rustfmt-normalize_comments: true
-// rustfmt-format_doc_comments: true
+// rustfmt-format_code_in_doc_comments: true
 
 // Do not unindent macro calls in comment with unformattable syntax.
 //! ```rust
diff --git a/tests/source/issue-3055/original.rs b/tests/source/issue-3055/original.rs
index eaf00afa3d3..ad505547ac0 100644
--- a/tests/source/issue-3055/original.rs
+++ b/tests/source/issue-3055/original.rs
@@ -1,5 +1,5 @@
 // rustfmt-wrap_comments: true
-// rustfmt-format_doc_comments: true
+// rustfmt-format_code_in_doc_comments: true
 
 /// Vestibulum elit nibh, rhoncus non, euismod sit amet, pretium eu, enim. Nunc commodo ultricies dui.
 ///
diff --git a/tests/source/itemized-blocks/no_wrap.rs b/tests/source/itemized-blocks/no_wrap.rs
index a0c546ad18e..a7b6a10a010 100644
--- a/tests/source/itemized-blocks/no_wrap.rs
+++ b/tests/source/itemized-blocks/no_wrap.rs
@@ -1,5 +1,5 @@
 // rustfmt-normalize_comments: true
-// rustfmt-format_doc_comments: true
+// rustfmt-format_code_in_doc_comments: true
 
 //! This is a list:
 //!  * Outer
diff --git a/tests/source/itemized-blocks/wrap.rs b/tests/source/itemized-blocks/wrap.rs
index 14fc8daa2e9..955cc698b79 100644
--- a/tests/source/itemized-blocks/wrap.rs
+++ b/tests/source/itemized-blocks/wrap.rs
@@ -1,5 +1,5 @@
 // rustfmt-wrap_comments: true
-// rustfmt-format_doc_comments: true
+// rustfmt-format_code_in_doc_comments: true
 // rustfmt-max_width: 50
 
 //! This is a list:
diff --git a/tests/target/doc-comment-with-example.rs b/tests/target/doc-comment-with-example.rs
index bec931d13c7..c5a4e779ea2 100644
--- a/tests/target/doc-comment-with-example.rs
+++ b/tests/target/doc-comment-with-example.rs
@@ -1,4 +1,4 @@
-// rustfmt-format_doc_comments: true
+// rustfmt-format_code_in_doc_comments: true
 
 /// Foo
 ///
diff --git a/tests/target/invalid-rust-code-in-doc-comment.rs b/tests/target/invalid-rust-code-in-doc-comment.rs
index 2593410a418..f8479d4e345 100644
--- a/tests/target/invalid-rust-code-in-doc-comment.rs
+++ b/tests/target/invalid-rust-code-in-doc-comment.rs
@@ -1,4 +1,4 @@
-// rustfmt-format_doc_comments: true
+// rustfmt-format_code_in_doc_comments: true
 
 /// ```rust
 /// if (true) { … }
diff --git a/tests/target/issue-2520.rs b/tests/target/issue-2520.rs
index 7d22b2b665a..7c134d3972b 100644
--- a/tests/target/issue-2520.rs
+++ b/tests/target/issue-2520.rs
@@ -1,5 +1,5 @@
 // rustfmt-normalize_comments: true
-// rustfmt-format_doc_comments: true
+// rustfmt-format_code_in_doc_comments: true
 
 //! ```rust
 //! println!("hello, world");
diff --git a/tests/target/issue-2523.rs b/tests/target/issue-2523.rs
index c0118e53780..612f93249ac 100644
--- a/tests/target/issue-2523.rs
+++ b/tests/target/issue-2523.rs
@@ -1,5 +1,5 @@
 // rustfmt-normalize_comments: true
-// rustfmt-format_doc_comments: true
+// rustfmt-format_code_in_doc_comments: true
 
 // Do not unindent macro calls in comment with unformattable syntax.
 //! ```rust
diff --git a/tests/target/issue-3055/original.rs b/tests/target/issue-3055/original.rs
index 1fb35d50682..de27ccfb344 100644
--- a/tests/target/issue-3055/original.rs
+++ b/tests/target/issue-3055/original.rs
@@ -1,5 +1,5 @@
 // rustfmt-wrap_comments: true
-// rustfmt-format_doc_comments: true
+// rustfmt-format_code_in_doc_comments: true
 
 /// Vestibulum elit nibh, rhoncus non, euismod sit amet, pretium eu, enim. Nunc
 /// commodo ultricies dui.
diff --git a/tests/target/itemized-blocks/no_wrap.rs b/tests/target/itemized-blocks/no_wrap.rs
index a1f9c39a115..de885638272 100644
--- a/tests/target/itemized-blocks/no_wrap.rs
+++ b/tests/target/itemized-blocks/no_wrap.rs
@@ -1,5 +1,5 @@
 // rustfmt-normalize_comments: true
-// rustfmt-format_doc_comments: true
+// rustfmt-format_code_in_doc_comments: true
 
 //! This is a list:
 //!  * Outer
diff --git a/tests/target/itemized-blocks/wrap.rs b/tests/target/itemized-blocks/wrap.rs
index 967a38b91ae..a4907303c9e 100644
--- a/tests/target/itemized-blocks/wrap.rs
+++ b/tests/target/itemized-blocks/wrap.rs
@@ -1,5 +1,5 @@
 // rustfmt-wrap_comments: true
-// rustfmt-format_doc_comments: true
+// rustfmt-format_code_in_doc_comments: true
 // rustfmt-max_width: 50
 
 //! This is a list:

From a9932f66064b31bcd47f682212afb4dc829898c4 Mon Sep 17 00:00:00 2001
From: xiongmao86 <xiongmao86dev@sina.com>
Date: Fri, 10 May 2019 21:29:08 +0800
Subject: [PATCH 7/7] update CHANGELOG.

---
 CHANGELOG.md | 1 +
 1 file changed, 1 insertion(+)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 87b54af8299..39372bcb129 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,7 @@
 
 ## [Unreleased]
 
+- Change option `format_doc_comment` to `format_code_in_doc_comment`.
 - `use_small_heuristics` changed to be an enum and stabilised. Configuration
   options are now ready for 1.0.