about summary refs log tree commit diff
diff options
context:
space:
mode:
authoradamrk <ark.email@gmail.com>2020-04-28 10:23:45 +0200
committeradamrk <ark.email@gmail.com>2020-04-28 10:23:45 +0200
commitb6560e3ebb80a7a96b3c3598ecba232f799fe93f (patch)
tree2c6cf47429baab34ee4af70ae466f7d378650943
parentda1f316b0246ce41d7cb8560181e294089f06ef3 (diff)
downloadrust-b6560e3ebb80a7a96b3c3598ecba232f799fe93f.tar.gz
rust-b6560e3ebb80a7a96b3c3598ecba232f799fe93f.zip
Treat comments beginning with four slashes as regular line comments
-rw-r--r--crates/ra_syntax/src/ast.rs15
-rw-r--r--crates/ra_syntax/src/ast/tokens.rs1
2 files changed, 16 insertions, 0 deletions
diff --git a/crates/ra_syntax/src/ast.rs b/crates/ra_syntax/src/ast.rs
index 7fca5661ef9..a716e525b95 100644
--- a/crates/ra_syntax/src/ast.rs
+++ b/crates/ra_syntax/src/ast.rs
@@ -243,6 +243,21 @@ fn test_comments_preserve_trailing_whitespace() {
 }
 
 #[test]
+fn test_four_slash_line_comment() {
+    let file = SourceFile::parse(
+        r#"
+        //// too many slashes to be a doc comment
+        /// doc comment
+        mod foo {}
+        "#,
+    )
+    .ok()
+    .unwrap();
+    let module = file.syntax().descendants().find_map(Module::cast).unwrap();
+    assert_eq!("doc comment", module.doc_comment_text().unwrap());
+}
+
+#[test]
 fn test_where_predicates() {
     fn assert_bound(text: &str, bound: Option<TypeBound>) {
         assert_eq!(text, bound.unwrap().syntax().text().to_string());
diff --git a/crates/ra_syntax/src/ast/tokens.rs b/crates/ra_syntax/src/ast/tokens.rs
index 3865729b8c4..481813e38a8 100644
--- a/crates/ra_syntax/src/ast/tokens.rs
+++ b/crates/ra_syntax/src/ast/tokens.rs
@@ -48,6 +48,7 @@ pub enum CommentPlacement {
 const COMMENT_PREFIX_TO_KIND: &[(&str, CommentKind)] = {
     use {CommentPlacement::*, CommentShape::*};
     &[
+        ("////", CommentKind { shape: Line, doc: None }),
         ("///", CommentKind { shape: Line, doc: Some(Outer) }),
         ("//!", CommentKind { shape: Line, doc: Some(Inner) }),
         ("/**", CommentKind { shape: Block, doc: Some(Outer) }),