mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-16 00:43:50 +00:00
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>`.
This commit is contained in:
parent
a207871d5c
commit
617e13548f
@ -189,7 +189,9 @@ impl<'a> Classifier<'a> {
|
||||
// leading identifier.
|
||||
TokenKind::Bang if self.in_macro => {
|
||||
self.in_macro = false;
|
||||
Class::Macro
|
||||
sink(Highlight::Token { text, class: None });
|
||||
sink(Highlight::ExitSpan);
|
||||
return;
|
||||
}
|
||||
|
||||
// Assume that '&' or '*' is the reference or dereference operator
|
||||
@ -298,7 +300,9 @@ impl<'a> Classifier<'a> {
|
||||
},
|
||||
TokenKind::Ident | TokenKind::RawIdent if lookahead == Some(TokenKind::Bang) => {
|
||||
self.in_macro = true;
|
||||
Class::Macro
|
||||
sink(Highlight::EnterSpan { class: Class::Macro });
|
||||
sink(Highlight::Token { text, class: None });
|
||||
return;
|
||||
}
|
||||
TokenKind::Ident => match text {
|
||||
"ref" | "mut" => Class::RefKeyWord,
|
||||
|
Loading…
Reference in New Issue
Block a user