File tree 1 file changed +9
-2
lines changed
1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -247,7 +247,8 @@ fn consume_whitespace_and_comments(rdr: @mut StringReader)
247
247
}
248
248
249
249
pub fn is_line_non_doc_comment ( s : & str ) -> bool {
250
- s. trim_right ( ) . all ( |ch| ch == '/' )
250
+ let s = s. trim_right ( ) ;
251
+ s. len ( ) > 3 && s. all ( |ch| ch == '/' )
251
252
}
252
253
253
254
// PRECONDITION: rdr.curr is not whitespace
@@ -268,7 +269,7 @@ fn consume_any_line_comment(rdr: @mut StringReader)
268
269
str:: push_char ( & mut acc, rdr. curr ) ;
269
270
bump ( rdr) ;
270
271
}
271
- // but comments with only "/"s are not
272
+ // but comments with only more "/"s are not
272
273
if !is_line_non_doc_comment ( acc) {
273
274
return Some ( TokenAndSpan {
274
275
tok : token:: DOC_COMMENT ( rdr. interner . intern ( acc) ) ,
@@ -891,4 +892,10 @@ mod test {
891
892
let id = env. interner . intern ( "abc" ) ;
892
893
assert_eq ! ( tok, token:: LIFETIME ( id) ) ;
893
894
}
895
+
896
+ #[ test] fn line_doc_comments ( ) {
897
+ assert ! ( !is_line_non_doc_comment( "///" ) ) ;
898
+ assert ! ( !is_line_non_doc_comment( "/// blah" ) ) ;
899
+ assert ! ( is_line_non_doc_comment( "////" ) ) ;
900
+ }
894
901
}
You can’t perform that action at this time.
0 commit comments