11use crate :: token:: { self , Token , TokenKind } ;
22use crate :: sess:: ParseSess ;
33use crate :: symbol:: { sym, Symbol } ;
4+ use crate :: util:: comments;
45
56use errors:: { FatalError , DiagnosticBuilder } ;
67use syntax_pos:: { BytePos , Pos , Span } ;
@@ -15,7 +16,6 @@ use log::debug;
1516#[ cfg( test) ]
1617mod tests;
1718
18- pub mod comments;
1919mod tokentrees;
2020mod unicode_chars;
2121mod unescape_error_reporting;
@@ -179,7 +179,7 @@ impl<'a> StringReader<'a> {
179179 rustc_lexer:: TokenKind :: LineComment => {
180180 let string = self . str_from ( start) ;
181181 // comments with only more "/"s are not doc comments
182- let tok = if is_doc_comment ( string) {
182+ let tok = if comments :: is_line_doc_comment ( string) {
183183 self . forbid_bare_cr ( start, string, "bare CR not allowed in doc-comment" ) ;
184184 token:: DocComment ( Symbol :: intern ( string) )
185185 } else {
@@ -192,7 +192,7 @@ impl<'a> StringReader<'a> {
192192 let string = self . str_from ( start) ;
193193 // block comments starting with "/**" or "/*!" are doc-comments
194194 // but comments with only "*"s between two "/"s are not
195- let is_doc_comment = is_block_doc_comment ( string) ;
195+ let is_doc_comment = comments :: is_block_doc_comment ( string) ;
196196
197197 if !terminated {
198198 let msg = if is_doc_comment {
@@ -643,18 +643,3 @@ impl<'a> StringReader<'a> {
643643 }
644644 }
645645}
646-
647- fn is_doc_comment ( s : & str ) -> bool {
648- let res = ( s. starts_with ( "///" ) && * s. as_bytes ( ) . get ( 3 ) . unwrap_or ( & b' ' ) != b'/' ) ||
649- s. starts_with ( "//!" ) ;
650- debug ! ( "is {:?} a doc comment? {}" , s, res) ;
651- res
652- }
653-
654- fn is_block_doc_comment ( s : & str ) -> bool {
655- // Prevent `/**/` from being parsed as a doc comment
656- let res = ( ( s. starts_with ( "/**" ) && * s. as_bytes ( ) . get ( 3 ) . unwrap_or ( & b' ' ) != b'*' ) ||
657- s. starts_with ( "/*!" ) ) && s. len ( ) >= 5 ;
658- debug ! ( "is {:?} a doc comment? {}" , s, res) ;
659- res
660- }
0 commit comments