Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix rustdoc highlighting of & and * #38569

Merged
merged 1 commit into from
Jan 12, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/librustdoc/html/highlight.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,9 +218,11 @@ impl<'a> Classifier<'a> {
token::Comment => Class::Comment,
token::DocComment(..) => Class::DocComment,

// If this '&' token is directly adjacent to another token, assume
// that it's the address-of operator instead of the and-operator.
token::BinOp(token::And) if self.lexer.peek().sp.lo == tas.sp.hi => Class::RefKeyWord,
// If this '&' or '*' token is followed by a non-whitespace token, assume that it's the
// reference or dereference operator or a reference or pointer type, instead of the
// bit-and or multiplication operator.
token::BinOp(token::And) | token::BinOp(token::Star)
if self.lexer.peek().tok != token::Whitespace => Class::RefKeyWord,

// Consider this as part of a macro invocation if there was a
// leading identifier.
Expand Down