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.
This commit is contained in:
Aleksey Kladov 2019-04-04 19:51:13 +03:00
parent 546cb21f58
commit 606e0aff81

View File

@ -631,26 +631,14 @@ impl<'a> StringReader<'a> {
self.bump();
}
if doc_comment {
let tok = if doc_comment {
self.with_str_from(start_bpos, |string| {
// comments with only more "/"s are not doc comments
let tok = if is_doc_comment(string) {
token::DocComment(Symbol::intern(string))
} else {
token::Comment
};
Some(TokenAndSpan {
tok,
sp: self.mk_sp(start_bpos, self.pos),
})
token::DocComment(Symbol::intern(string))
})
} else {
Some(TokenAndSpan {
tok: token::Comment,
sp: self.mk_sp(start_bpos, self.pos),
})
}
token::Comment
};
Some(TokenAndSpan { tok, sp: self.mk_sp(start_bpos, self.pos) })
}
Some('*') => {
self.bump();