Skip to content

Commit

Permalink
Auto merge of #59700 - matklad:simplify, r=eddyb
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
bors committed Apr 20, 2019
2 parents 72bc620 + 606e0af commit 4530c52
Showing 1 changed file with 5 additions and 17 deletions.
22 changes: 5 additions & 17 deletions src/libsyntax/parse/lexer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -630,26 +630,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();
Expand Down

0 comments on commit 4530c52

Please sign in to comment.