Skip to content

Commit 6a89b8f

Browse files
committed
rustdoc: color the question mark operator
The idea was proposed by eddyb in: #31436 (comment)
1 parent 304d0c8 commit 6a89b8f

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/librustdoc/html/highlight.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ pub enum Class {
104104
Lifetime,
105105
PreludeTy,
106106
PreludeVal,
107+
QuestionMark,
107108
}
108109

109110
/// Trait that controls writing the output of syntax highlighting. Users should
@@ -237,8 +238,10 @@ impl<'a> Classifier<'a> {
237238
token::Dot | token::DotDot | token::DotDotDot | token::Comma | token::Semi |
238239
token::Colon | token::ModSep | token::LArrow | token::OpenDelim(_) |
239240
token::CloseDelim(token::Brace) | token::CloseDelim(token::Paren) |
240-
token::CloseDelim(token::NoDelim) |
241-
token::Question => Class::None,
241+
token::CloseDelim(token::NoDelim) => Class::None,
242+
243+
token::Question => Class::QuestionMark,
244+
242245
token::Dollar => {
243246
if self.lexer.peek().tok.is_ident() {
244247
self.in_macro_nonterminal = true;
@@ -348,6 +351,7 @@ impl Class {
348351
Class::Lifetime => "lifetime",
349352
Class::PreludeTy => "prelude-ty",
350353
Class::PreludeVal => "prelude-val",
354+
Class::QuestionMark => "question-mark"
351355
}
352356
}
353357
}

src/librustdoc/html/static/rustdoc.css

+3
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,9 @@ pre.rust .self, pre.rust .bool-val, pre.rust .prelude-val,
570570
pre.rust .attribute, pre.rust .attribute .ident { color: #C82829; }
571571
pre.rust .macro, pre.rust .macro-nonterminal { color: #3E999F; }
572572
pre.rust .lifetime { color: #B76514; }
573+
pre.rust .question-mark {
574+
color: #c67e2d;
575+
}
573576

574577
.rusttest { display: none; }
575578
pre.rust { position: relative; }

0 commit comments

Comments
 (0)