File tree 4 files changed +29
-11
lines changed
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:
153
153
~~~~ {.ebnf .gram}
154
154
comment : block_comment | line_comment ;
155
155
block_comment : "/*" block_comment_body * '*' + '/' ;
156
- block_comment_body : non_star * | '*' + non_slash_or_star ;
156
+ block_comment_body : (block_comment | character) * ;
157
157
line_comment : "//" non_eol * ;
158
158
~~~~
159
159
160
160
Comments in Rust code follow the general C++ style of line and block-comment forms,
161
161
with no nesting of block-comment delimiters.
162
162
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"] ` ).
167
169
168
170
Non-doc comments are interpreted as a form of whitespace.
169
171
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
187
187
188
188
syn region rustCommentML start =" /\* " end =" \* /" contains =rustTodo
189
189
syn 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
192
192
193
193
syn keyword rustTodo contained TODO FIXME XXX NB NOTE
194
194
Original file line number Diff line number Diff line change @@ -317,8 +317,7 @@ fn consume_whitespace_and_comments(rdr: @mut StringReader)
317
317
}
318
318
319
319
pub 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 ( "////" )
322
321
}
323
322
324
323
// PRECONDITION: rdr.curr is not whitespace
@@ -378,8 +377,7 @@ fn consume_any_line_comment(rdr: @mut StringReader)
378
377
}
379
378
380
379
pub 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 ( "/***" )
383
381
}
384
382
385
383
// 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