Skip to content

Commit b6560e3

Browse files
committed
Treat comments beginning with four slashes as regular line comments
1 parent da1f316 commit b6560e3

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

crates/ra_syntax/src/ast.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,21 @@ fn test_comments_preserve_trailing_whitespace() {
242242
);
243243
}
244244

245+
#[test]
246+
fn test_four_slash_line_comment() {
247+
let file = SourceFile::parse(
248+
r#"
249+
//// too many slashes to be a doc comment
250+
/// doc comment
251+
mod foo {}
252+
"#,
253+
)
254+
.ok()
255+
.unwrap();
256+
let module = file.syntax().descendants().find_map(Module::cast).unwrap();
257+
assert_eq!("doc comment", module.doc_comment_text().unwrap());
258+
}
259+
245260
#[test]
246261
fn test_where_predicates() {
247262
fn assert_bound(text: &str, bound: Option<TypeBound>) {

crates/ra_syntax/src/ast/tokens.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ pub enum CommentPlacement {
4848
const COMMENT_PREFIX_TO_KIND: &[(&str, CommentKind)] = {
4949
use {CommentPlacement::*, CommentShape::*};
5050
&[
51+
("////", CommentKind { shape: Line, doc: None }),
5152
("///", CommentKind { shape: Line, doc: Some(Outer) }),
5253
("//!", CommentKind { shape: Line, doc: Some(Inner) }),
5354
("/**", CommentKind { shape: Block, doc: Some(Outer) }),

0 commit comments

Comments
 (0)