Treat comments beginning with four slashes as regular line comments

This commit is contained in:
adamrk 2020-04-28 10:23:45 +02:00
parent da1f316b02
commit b6560e3ebb
2 changed files with 16 additions and 0 deletions

View File

@ -242,6 +242,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>) {

View File

@ -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) }),