diff options
| author | bors <bors@rust-lang.org> | 2017-01-12 18:32:28 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2017-01-12 18:32:28 +0000 |
| commit | 27b9e6d450590751fca863312a8cf10f289cf1f2 (patch) | |
| tree | e4e04470fc45f547949ea16e84f354976d44de40 | |
| parent | ac5046cf67e51df286e7c8df02d67c302d4c4d09 (diff) | |
| parent | c9a6e874cacc7067bf2466f8bc7d154daccd95b1 (diff) | |
Auto merge of #38569 - chris-morgan:rustdoc-highlight-kw-2, r=steveklabnik
Fix rustdoc highlighting of `&` and `*` Whitespace tokens were included, so the span check used with `&` was incorrect, and it was never highlighted as kw-2 (RefKeyword). The `*` in `*foo` and `*const T` should also be highlighted kw-2, so I added them. Note that this *will* cause mishighlighting of code like `1*2`, but that should have been written `1 * 2`. Same deal with `1&2`.
| -rw-r--r-- | src/librustdoc/html/highlight.rs | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/librustdoc/html/highlight.rs b/src/librustdoc/html/highlight.rs index bd47b1e7c12..a031be8b3c2 100644 --- a/src/librustdoc/html/highlight.rs +++ b/src/librustdoc/html/highlight.rs @@ -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. |
