Skip to content

Commit

Permalink
declare that "///" is still a doc comment, just not "////+" (fixes #5838
Browse files Browse the repository at this point in the history
)
  • Loading branch information
ben0x539 committed May 22, 2013
1 parent 8a4bffc commit 5a42481
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/libsyntax/parse/lexer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,8 @@ fn consume_whitespace_and_comments(rdr: @mut StringReader)
}

pub fn is_line_non_doc_comment(s: &str) -> bool {
s.trim_right().all(|ch| ch == '/')
let s = s.trim_right();
s.len() > 3 && s.all(|ch| ch == '/')
}

// PRECONDITION: rdr.curr is not whitespace
Expand All @@ -268,7 +269,7 @@ fn consume_any_line_comment(rdr: @mut StringReader)
str::push_char(&mut acc, rdr.curr);
bump(rdr);
}
// but comments with only "/"s are not
// but comments with only more "/"s are not
if !is_line_non_doc_comment(acc) {
return Some(TokenAndSpan{
tok: token::DOC_COMMENT(rdr.interner.intern(acc)),
Expand Down Expand Up @@ -891,4 +892,10 @@ mod test {
let id = env.interner.intern("abc");
assert_eq!(tok, token::LIFETIME(id));
}

#[test] fn line_doc_comments() {
assert!(!is_line_non_doc_comment("///"));
assert!(!is_line_non_doc_comment("/// blah"));
assert!(is_line_non_doc_comment("////"));
}
}

12 comments on commit 5a42481

@bors
Copy link
Contributor

@bors bors commented on 5a42481 May 23, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from graydon
at ben0x539@5a42481

@bors
Copy link
Contributor

@bors bors commented on 5a42481 May 23, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging ben0x539/rust/slashslashslash = 5a42481 into auto

@bors
Copy link
Contributor

@bors bors commented on 5a42481 May 23, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ben0x539/rust/slashslashslash = 5a42481 merged ok, testing candidate = d7987618

@bors
Copy link
Contributor

@bors bors commented on 5a42481 May 23, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No active merge of candidate 5a42481 found, likely manual push to incoming

@bors
Copy link
Contributor

@bors bors commented on 5a42481 May 23, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging ben0x539/rust/slashslashslash = 5a42481 into auto

@bors
Copy link
Contributor

@bors bors commented on 5a42481 May 23, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ben0x539/rust/slashslashslash = 5a42481 merged ok, testing candidate = a8152e3f

@bors
Copy link
Contributor

@bors bors commented on 5a42481 May 23, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors
Copy link
Contributor

@bors bors commented on 5a42481 May 24, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No active merge of candidate 5a42481 found, likely manual push to incoming

@bors
Copy link
Contributor

@bors bors commented on 5a42481 May 24, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging ben0x539/rust/slashslashslash = 5a42481 into auto

@bors
Copy link
Contributor

@bors bors commented on 5a42481 May 24, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ben0x539/rust/slashslashslash = 5a42481 merged ok, testing candidate = b5ab101

@bors
Copy link
Contributor

@bors bors commented on 5a42481 May 24, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors
Copy link
Contributor

@bors bors commented on 5a42481 May 24, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding incoming to auto = b5ab101

Please sign in to comment.