summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2013-11-27 15:32:18 -0800
committerbors <bors@rust-lang.org>2013-11-27 15:32:18 -0800
commitd2c405eeff3930bf0c0777f06108a2eedcd456f6 (patch)
tree0672956c3f38a15d76316f27171bd663520a8659 /src
parentd662820b297f0ecda17126577571fcf886bdac81 (diff)
parentb50b1628840daf849e548c83372f85bc13092314 (diff)
downloadrust-d2c405eeff3930bf0c0777f06108a2eedcd456f6.tar.gz
rust-d2c405eeff3930bf0c0777f06108a2eedcd456f6.zip
auto merge of #10642 : cmr/rust/strict_doccomment, r=alexcrichton
Previously, `//// foo` and `/*** foo ***/` were accepted as doc comments. This
changes that, so that only `/// foo` and `/** foo ***/` are accepted. This
confuses many newcomers and it seems weird.

Also update the manual for these changes, and modernify the EBNF for comments.

Closes #10638
Diffstat (limited to 'src')
-rw-r--r--src/etc/vim/syntax/rust.vim4
-rw-r--r--src/libsyntax/parse/lexer.rs6
-rw-r--r--src/test/run-pass/issue-10638.rs18
3 files changed, 22 insertions, 6 deletions
diff --git a/src/etc/vim/syntax/rust.vim b/src/etc/vim/syntax/rust.vim
index e5ff089e2e1..dc1e58c1ae3 100644
--- a/src/etc/vim/syntax/rust.vim
+++ b/src/etc/vim/syntax/rust.vim
@@ -187,8 +187,8 @@ syn match   rustCharacter   /'\([^'\\]\|\\\([nrt0\\'"]\|x\x\{2}\|u\x\{4}\|U\x\{8
 
 syn region    rustCommentML   start="/\*" end="\*/" contains=rustTodo
 syn region    rustComment     start="//" end="$" contains=rustTodo keepend
-syn region    rustCommentMLDoc start="/\*\%(!\|\*/\@!\)" end="\*/" contains=rustTodo
-syn region    rustCommentDoc  start="//[/!]" end="$" contains=rustTodo keepend
+syn region    rustCommentMLDoc start="/\*\%(!\|\*[*/]\@!\)" end="\*/" contains=rustTodo
+syn region    rustCommentDoc  start="//\%(//\@!\|!\)" end="$" contains=rustTodo keepend
 
 syn keyword rustTodo contained TODO FIXME XXX NB NOTE
 
diff --git a/src/libsyntax/parse/lexer.rs b/src/libsyntax/parse/lexer.rs
index e4b93c3b4d5..fa93c5f8977 100644
--- a/src/libsyntax/parse/lexer.rs
+++ b/src/libsyntax/parse/lexer.rs
@@ -317,8 +317,7 @@ fn consume_whitespace_and_comments(rdr: @mut StringReader)
 }
 
 pub fn is_line_non_doc_comment(s: &str) -> bool {
-    let s = s.trim_right();
-    s.len() > 3 && s.chars().all(|ch| ch == '/')
+    s.starts_with("////")
 }
 
 // PRECONDITION: rdr.curr is not whitespace
@@ -378,8 +377,7 @@ fn consume_any_line_comment(rdr: @mut StringReader)
 }
 
 pub fn is_block_non_doc_comment(s: &str) -> bool {
-    assert!(s.len() >= 1u);
-    s.slice(1u, s.len() - 1u).chars().all(|ch| ch == '*')
+    s.starts_with("/***")
 }
 
 // might return a sugared-doc-attr
diff --git a/src/test/run-pass/issue-10638.rs b/src/test/run-pass/issue-10638.rs
new file mode 100644
index 00000000000..bc77b4c5343
--- /dev/null
+++ b/src/test/run-pass/issue-10638.rs
@@ -0,0 +1,18 @@
+// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+pub fn main() {
+    //// I am not a doc comment!
+    ////////////////// still not a doc comment
+    /////**** nope, me neither */
+    /*** And neither am I! */
+    5;
+    /*****! certainly not I */
+}