Skip to content

Commit 606e0af

Browse files
committed
Simplify doc comment lexing
is_doc_comment function checks the first four chars, but this is redundant, `doc_comment` local var has the same info.
1 parent 546cb21 commit 606e0af

File tree

1 file changed

+5
-17
lines changed
  • src/libsyntax/parse/lexer

1 file changed

+5
-17
lines changed

src/libsyntax/parse/lexer/mod.rs

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -631,26 +631,14 @@ impl<'a> StringReader<'a> {
631631
self.bump();
632632
}
633633

634-
if doc_comment {
634+
let tok = if doc_comment {
635635
self.with_str_from(start_bpos, |string| {
636-
// comments with only more "/"s are not doc comments
637-
let tok = if is_doc_comment(string) {
638-
token::DocComment(Symbol::intern(string))
639-
} else {
640-
token::Comment
641-
};
642-
643-
Some(TokenAndSpan {
644-
tok,
645-
sp: self.mk_sp(start_bpos, self.pos),
646-
})
636+
token::DocComment(Symbol::intern(string))
647637
})
648638
} else {
649-
Some(TokenAndSpan {
650-
tok: token::Comment,
651-
sp: self.mk_sp(start_bpos, self.pos),
652-
})
653-
}
639+
token::Comment
640+
};
641+
Some(TokenAndSpan { tok, sp: self.mk_sp(start_bpos, self.pos) })
654642
}
655643
Some('*') => {
656644
self.bump();

0 commit comments

Comments
 (0)