File tree Expand file tree Collapse file tree 4 files changed +29
-11
lines changed Expand file tree Collapse file tree 4 files changed +29
-11
lines changed Original file line number Diff line number Diff line change @@ -153,17 +153,19 @@ Some productions are defined by exclusion of particular Unicode characters:
153153~~~~ {.ebnf .gram}
154154comment : block_comment | line_comment ;
155155block_comment : "/*" block_comment_body * '*' + '/' ;
156- block_comment_body : non_star * | '*' + non_slash_or_star ;
156+ block_comment_body : (block_comment | character) * ;
157157line_comment : "//" non_eol * ;
158158~~~~
159159
160160Comments in Rust code follow the general C++ style of line and block-comment forms,
161161with no nesting of block-comment delimiters.
162162
163- Line comments beginning with _ three_ slashes (` /// ` ),
164- and block comments beginning with a repeated asterisk in the block-open sequence (` /** ` ),
165- are interpreted as a special syntax for ` doc ` [ attributes] ( #attributes ) .
166- That is, they are equivalent to writing ` #[doc "..."] ` around the comment's text.
163+ Line comments beginning with exactly _ three_ slashes (` /// ` ), and block
164+ comments beginning with a exactly one repeated asterisk in the block-open
165+ sequence (` /** ` ), are interpreted as a special syntax for ` doc `
166+ [ attributes] ( #attributes ) . That is, they are equivalent to writing
167+ ` #[doc="..."] ` around the body of the comment (this includes the comment
168+ characters themselves, ie ` /// Foo ` turns into ` #[doc="/// Foo"] ` ).
167169
168170Non-doc comments are interpreted as a form of whitespace.
169171
Original file line number Diff line number Diff line change @@ -187,8 +187,8 @@ syn match rustCharacter /'\([^'\\]\|\\\([nrt0\\'"]\|x\x\{2}\|u\x\{4}\|U\x\{8
187187
188188syn region rustCommentML start =" /\* " end =" \* /" contains =rustTodo
189189syn region rustComment start =" //" end =" $" contains =rustTodo keepend
190- syn region rustCommentMLDoc start =" /\*\% (!\|\* / \@ !\) " end =" \* /" contains =rustTodo
191- syn region rustCommentDoc start =" //[/!] " end =" $" contains =rustTodo keepend
190+ syn region rustCommentMLDoc start =" /\*\% (!\|\* [*/] \@ !\) " end =" \* /" contains =rustTodo
191+ syn region rustCommentDoc start =" //\% (// \@ ! \| ! \) " end =" $" contains =rustTodo keepend
192192
193193syn keyword rustTodo contained TODO FIXME XXX NB NOTE
194194
Original file line number Diff line number Diff line change @@ -317,8 +317,7 @@ fn consume_whitespace_and_comments(rdr: @mut StringReader)
317317}
318318
319319pub fn is_line_non_doc_comment ( s : & str ) -> bool {
320- let s = s. trim_right ( ) ;
321- s. len ( ) > 3 && s. chars ( ) . all ( |ch| ch == '/' )
320+ s. starts_with ( "////" )
322321}
323322
324323// PRECONDITION: rdr.curr is not whitespace
@@ -378,8 +377,7 @@ fn consume_any_line_comment(rdr: @mut StringReader)
378377}
379378
380379pub fn is_block_non_doc_comment ( s : & str ) -> bool {
381- assert ! ( s. len( ) >= 1 u) ;
382- s. slice ( 1 u, s. len ( ) - 1 u) . chars ( ) . all ( |ch| ch == '*' )
380+ s. starts_with ( "/***" )
383381}
384382
385383// might return a sugared-doc-attr
Original file line number Diff line number Diff line change 1+ // Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2+ // file at the top-level directory of this distribution and at
3+ // http://rust-lang.org/COPYRIGHT.
4+ //
5+ // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+ // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+ // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+ // option. This file may not be copied, modified, or distributed
9+ // except according to those terms.
10+
11+ pub fn main ( ) {
12+ //// I am not a doc comment!
13+ ////////////////// still not a doc comment
14+ /////**** nope, me neither */
15+ /*** And neither am I! */
16+ 5 ;
17+ /*****! certainly not I */
18+ }
You can’t perform that action at this time.
0 commit comments