Skip to content

Commit 3da9ddb

Browse files
author
Jonathan Turner
authored
Rollup merge of rust-lang#37102 - est31:rustdoc_question_mark, r=GuillaumeGomez
rustdoc: color the question mark operator The idea of coloring `?` specially was proposed by @eddyb in: rust-lang#31436 (comment)
2 parents ad40a42 + 87cbfb4 commit 3da9ddb

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/librustdoc/html/highlight.rs

Lines changed: 6 additions & 2 deletions
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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,10 @@ 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: #ff9011;
575+
font-weight: bold;
576+
}
573577

574578
.rusttest { display: none; }
575579
pre.rust { position: relative; }

0 commit comments

Comments
 (0)