about summary refs log tree commit diff
path: root/src/libsyntax/parse
diff options
context:
space:
mode:
authorBenjamin Herr <ben@0x539.de>2013-05-22 15:53:26 +0200
committerBenjamin Herr <ben@0x539.de>2013-05-22 15:53:26 +0200
commit5a424813667a27a0def860d96a5e79801718592b (patch)
tree4319229c8a41ce0e02b615c020139d5201e00cfb /src/libsyntax/parse
parent8a4bffc7eee07d895e32db9a4a366c23995d260a (diff)
downloadrust-5a424813667a27a0def860d96a5e79801718592b.tar.gz
rust-5a424813667a27a0def860d96a5e79801718592b.zip
declare that "///" is still a doc comment, just not "////+" (fixes #5838)
Diffstat (limited to 'src/libsyntax/parse')
-rw-r--r--src/libsyntax/parse/lexer.rs11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/libsyntax/parse/lexer.rs b/src/libsyntax/parse/lexer.rs
index 5340293bb02..6cd1ad9077f 100644
--- a/src/libsyntax/parse/lexer.rs
+++ b/src/libsyntax/parse/lexer.rs
@@ -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
@@ -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)),
@@ -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("////"));
+    }
 }