diff --git a/crates/ide/src/syntax_highlighting/test_data/highlight_strings.html b/crates/ide/src/syntax_highlighting/test_data/highlight_strings.html
index 43f1b32fd725..d398e1ec85be 100644
--- a/crates/ide/src/syntax_highlighting/test_data/highlight_strings.html
+++ b/crates/ide/src/syntax_highlighting/test_data/highlight_strings.html
@@ -93,4 +93,6 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
println!("{\x41}", A = 92);
println!("{ничоси}", ничоси = 92);
+
+ println!("{:x?} {} ", thingy, n2);
}
\ No newline at end of file
diff --git a/crates/ide/src/syntax_highlighting/tests.rs b/crates/ide/src/syntax_highlighting/tests.rs
index 5c22e2fce360..1dc018a167bb 100644
--- a/crates/ide/src/syntax_highlighting/tests.rs
+++ b/crates/ide/src/syntax_highlighting/tests.rs
@@ -340,6 +340,8 @@ fn main() {
println!("{\x41}", A = 92);
println!("{ничоси}", ничоси = 92);
+
+ println!("{:x?} {} ", thingy, n2);
}"#
.trim(),
expect_file!["./test_data/highlight_strings.html"],
diff --git a/crates/syntax/src/ast/token_ext.rs b/crates/syntax/src/ast/token_ext.rs
index 2661c753e22c..ac03264205a0 100644
--- a/crates/syntax/src/ast/token_ext.rs
+++ b/crates/syntax/src/ast/token_ext.rs
@@ -331,10 +331,22 @@ pub trait HasFormatSpecifier: AstToken {
}
c if c == '_' || c.is_alphabetic() => {
read_identifier(&mut chars, &mut callback);
+
+ if chars.peek().and_then(|next| next.1.as_ref().ok()).copied()
+ == Some('?')
+ {
+ skip_char_and_emit(
+ &mut chars,
+ FormatSpecifier::QuestionMark,
+ &mut callback,
+ );
+ }
+
// can be either width (indicated by dollar sign, or type in which case
// the next sign has to be `}`)
let next =
chars.peek().and_then(|next| next.1.as_ref().ok()).copied();
+
match next {
Some('$') => skip_char_and_emit(
&mut chars,
@@ -417,6 +429,16 @@ pub trait HasFormatSpecifier: AstToken {
}
c if c == '_' || c.is_alphabetic() => {
read_identifier(&mut chars, &mut callback);
+
+ if chars.peek().and_then(|next| next.1.as_ref().ok()).copied()
+ == Some('?')
+ {
+ skip_char_and_emit(
+ &mut chars,
+ FormatSpecifier::QuestionMark,
+ &mut callback,
+ );
+ }
}
_ => {}
}