diff options
| author | Corey Richardson <corey@octayn.net> | 2013-11-24 23:23:50 -0500 |
|---|---|---|
| committer | Corey Richardson <corey@octayn.net> | 2013-11-27 18:00:50 -0500 |
| commit | b50b1628840daf849e548c83372f85bc13092314 (patch) | |
| tree | 0aaafa415f83349218babac24c31f4c2f06e85da /src/libsyntax/parse | |
| parent | e147a090a5c7125428c16b142922002f7a645ea1 (diff) | |
| download | rust-b50b1628840daf849e548c83372f85bc13092314.tar.gz rust-b50b1628840daf849e548c83372f85bc13092314.zip | |
Be more strict about doc comments
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/libsyntax/parse')
| -rw-r--r-- | src/libsyntax/parse/lexer.rs | 6 |
1 files changed, 2 insertions, 4 deletions
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 |
