Skip to content

Commit 617e135

Browse files
committed
rustdoc: highlight macros more efficiently
Instead of producing `<span class=macro>assert_eq</span><span class=macro>!</span>`, just produce `<span class=macro>assert_eq!</span>`.
1 parent a207871 commit 617e135

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/librustdoc/html/highlight.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,9 @@ impl<'a> Classifier<'a> {
189189
// leading identifier.
190190
TokenKind::Bang if self.in_macro => {
191191
self.in_macro = false;
192-
Class::Macro
192+
sink(Highlight::Token { text, class: None });
193+
sink(Highlight::ExitSpan);
194+
return;
193195
}
194196

195197
// Assume that '&' or '*' is the reference or dereference operator
@@ -298,7 +300,9 @@ impl<'a> Classifier<'a> {
298300
},
299301
TokenKind::Ident | TokenKind::RawIdent if lookahead == Some(TokenKind::Bang) => {
300302
self.in_macro = true;
301-
Class::Macro
303+
sink(Highlight::EnterSpan { class: Class::Macro });
304+
sink(Highlight::Token { text, class: None });
305+
return;
302306
}
303307
TokenKind::Ident => match text {
304308
"ref" | "mut" => Class::RefKeyWord,

0 commit comments

Comments
 (0)