about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorStéphane Campinas <stephane.campinas@gmail.com>2019-10-02 16:58:25 +0200
committerSeiichi Uchida <seuchida@gmail.com>2019-10-02 23:58:25 +0900
commitdbd89363913b2a35110077fed113aaa82b741079 (patch)
tree5855e91fbc5bbdcfe626f29ff5be1a079488d531 /src
parentf4bc4941531fbdfde423779b60946060b7f7cae6 (diff)
fix rust code in comment with a line containing only a hash sign (#3818)
Diffstat (limited to 'src')
-rw-r--r--src/comment.rs3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/comment.rs b/src/comment.rs
index 6222c34b1a2..e725adea6ba 100644
--- a/src/comment.rs
+++ b/src/comment.rs
@@ -823,7 +823,8 @@ fn rewrite_comment_inner(
 const RUSTFMT_CUSTOM_COMMENT_PREFIX: &str = "//#### ";
 
 fn hide_sharp_behind_comment(s: &str) -> Cow<'_, str> {
-    if s.trim_start().starts_with("# ") {
+    let s_trimmed = s.trim();
+    if s_trimmed.starts_with("# ") || s_trimmed == "#" {
         Cow::from(format!("{}{}", RUSTFMT_CUSTOM_COMMENT_PREFIX, s))
     } else {
         Cow::from(s)