about summary refs log tree commit diff
path: root/src/comment.rs
diff options
context:
space:
mode:
authorsinkuu <sinkuupump@gmail.com>2016-07-09 22:41:28 +0900
committersinkuu <sinkuupump@gmail.com>2016-07-09 22:56:50 +0900
commit0dc3fc7a2c0dd6ac5a4f4df1c83b4e8e41b042dd (patch)
tree67be8d1a63bf96c94ca6bcf9dfd140b57577bad1 /src/comment.rs
parentffa5a22d1c91d0648ab63de101afcc610caefccd (diff)
Fix formatting empty block comments (`/**/`)
issue #1086
Diffstat (limited to 'src/comment.rs')
-rw-r--r--src/comment.rs10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/comment.rs b/src/comment.rs
index 66cc5e2fb6f..062e4ba0ca7 100644
--- a/src/comment.rs
+++ b/src/comment.rs
@@ -33,7 +33,7 @@ pub fn rewrite_comment(orig: &str,
         if block_style {
             ("/* ", " */", " * ")
         } else if !config.normalize_comments {
-            if orig.starts_with("/**") {
+            if orig.starts_with("/**") && !orig.starts_with("/**/") {
                 ("/** ", " **/", " ** ")
             } else if orig.starts_with("/*!") {
                 ("/*! ", " */", " * ")
@@ -46,7 +46,8 @@ pub fn rewrite_comment(orig: &str,
             } else {
                 ("// ", "", "// ")
             }
-        } else if orig.starts_with("///") || orig.starts_with("/**") {
+        } else if orig.starts_with("///") ||
+                  (orig.starts_with("/**") && !orig.starts_with("/**/")) {
             ("/// ", "", "/// ")
         } else if orig.starts_with("//!") || orig.starts_with("/*!") {
             ("//! ", "", "//! ")
@@ -130,7 +131,7 @@ fn left_trim_comment_line(line: &str) -> &str {
     } else if line.starts_with("/* ") || line.starts_with("// ") || line.starts_with("//!") ||
               line.starts_with("///") ||
               line.starts_with("** ") || line.starts_with("/*!") ||
-              line.starts_with("/**") {
+              (line.starts_with("/**") && !line.starts_with("/**/")) {
         &line[3..]
     } else if line.starts_with("/*") || line.starts_with("* ") || line.starts_with("//") ||
               line.starts_with("**") {
@@ -606,7 +607,8 @@ fn remove_comment_header(comment: &str) -> &str {
         &comment[3..]
     } else if comment.starts_with("//") {
         &comment[2..]
-    } else if comment.starts_with("/**") || comment.starts_with("/*!") {
+    } else if (comment.starts_with("/**") && !comment.starts_with("/**/")) ||
+              comment.starts_with("/*!") {
         &comment[3..comment.len() - 2]
     } else {
         assert!(comment.starts_with("/*"),