diff --git a/crates/ide/src/syntax_highlighting/test_data/regression_20952.html b/crates/ide/src/syntax_highlighting/test_data/regression_20952.html new file mode 100644 index 0000000000..2c0250c6d4 --- /dev/null +++ b/crates/ide/src/syntax_highlighting/test_data/regression_20952.html @@ -0,0 +1,45 @@ + + +
fn main() {
+ format_args!("{} {}, {} (подозрение на спам: {:.2}%)"б);
+}
\ 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 4e84127c29..58c613ef7c 100644
--- a/crates/ide/src/syntax_highlighting/tests.rs
+++ b/crates/ide/src/syntax_highlighting/tests.rs
@@ -1497,3 +1497,17 @@ fn main() {
false,
);
}
+
+#[test]
+fn regression_20952() {
+ check_highlighting(
+ r#"
+//- minicore: fmt
+fn main() {
+ format_args!("{} {}, {} (подозрение на спам: {:.2}%)"б);
+}
+"#,
+ expect_file!["./test_data/regression_20952.html"],
+ false,
+ );
+}
diff --git a/crates/proc-macro-srv/src/tests/mod.rs b/crates/proc-macro-srv/src/tests/mod.rs
index 08495f50bf..d4f9976c92 100644
--- a/crates/proc-macro-srv/src/tests/mod.rs
+++ b/crates/proc-macro-srv/src/tests/mod.rs
@@ -326,7 +326,7 @@ fn test_fn_like_macro_clone_literals() {
PUNCH , [alone] 1
LITERAL Str hello bridge 1
PUNCH , [alone] 1
- LITERAL Str suffixedsuffix 1
+ LITERAL Err(()) "suffixed"suffix 1
PUNCH , [alone] 1
LITERAL StrRaw(2) raw 1
PUNCH , [alone] 1
@@ -372,7 +372,7 @@ fn test_fn_like_macro_clone_literals() {
PUNCH , [alone] 42:Root[0000, 0]@27..28#ROOT2024
LITERAL Str hello bridge 42:Root[0000, 0]@29..43#ROOT2024
PUNCH , [alone] 42:Root[0000, 0]@43..44#ROOT2024
- LITERAL Str suffixedsuffix 42:Root[0000, 0]@45..61#ROOT2024
+ LITERAL Err(()) "suffixed"suffix 42:Root[0000, 0]@45..61#ROOT2024
PUNCH , [alone] 42:Root[0000, 0]@61..62#ROOT2024
LITERAL StrRaw(2) raw 42:Root[0000, 0]@63..73#ROOT2024
PUNCH , [alone] 42:Root[0000, 0]@73..74#ROOT2024
diff --git a/crates/tt/src/lib.rs b/crates/tt/src/lib.rs
index 243a27b83b..f9a547f611 100644
--- a/crates/tt/src/lib.rs
+++ b/crates/tt/src/lib.rs
@@ -622,6 +622,15 @@ where
let lit = &lit[start_offset..lit.len() - end_offset];
let suffix = match suffix {
"" | "_" => None,
+ // ill-suffixed literals
+ _ if !matches!(kind, LitKind::Integer | LitKind::Float | LitKind::Err(_)) => {
+ return Literal {
+ span,
+ symbol: Symbol::intern(text),
+ kind: LitKind::Err(()),
+ suffix: None,
+ };
+ }
suffix => Some(Symbol::intern(suffix)),
};