Unnamed repository; edit this file 'description' to name the repository.
| -rw-r--r-- | crates/ide/src/syntax_highlighting/test_data/regression_20952.html | 45 | ||||
| -rw-r--r-- | crates/ide/src/syntax_highlighting/tests.rs | 14 | ||||
| -rw-r--r-- | crates/proc-macro-srv/src/tests/mod.rs | 4 | ||||
| -rw-r--r-- | crates/tt/src/lib.rs | 9 |
4 files changed, 70 insertions, 2 deletions
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 @@ + +<style> +body { margin: 0; } +pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padding: 0.4em; } + +.lifetime { color: #DFAF8F; font-style: italic; } +.label { color: #DFAF8F; font-style: italic; } +.comment { color: #7F9F7F; } +.documentation { color: #629755; } +.intra_doc_link { font-style: italic; } +.injected { opacity: 0.65 ; } +.struct, .enum { color: #7CB8BB; } +.enum_variant { color: #BDE0F3; } +.string_literal { color: #CC9393; } +.field { color: #94BFF3; } +.function { color: #93E0E3; } +.parameter { color: #94BFF3; } +.text { color: #DCDCCC; } +.type { color: #7CB8BB; } +.builtin_type { color: #8CD0D3; } +.type_param { color: #DFAF8F; } +.attribute { color: #94BFF3; } +.numeric_literal { color: #BFEBBF; } +.bool_literal { color: #BFE6EB; } +.macro { color: #94BFF3; } +.proc_macro { color: #94BFF3; text-decoration: underline; } +.derive { color: #94BFF3; font-style: italic; } +.module { color: #AFD8AF; } +.value_param { color: #DCDCCC; } +.variable { color: #DCDCCC; } +.format_specifier { color: #CC696B; } +.mutable { text-decoration: underline; } +.escape_sequence { color: #94BFF3; } +.keyword { color: #F0DFAF; font-weight: bold; } +.control { font-style: italic; } +.reference { font-style: italic; font-weight: bold; } +.const { font-weight: bolder; } +.unsafe { color: #BC8383; } + +.invalid_escape_sequence { color: #FC5555; text-decoration: wavy underline; } +.unresolved_reference { color: #FC5555; text-decoration: wavy underline; } +</style> +<pre><code><span class="keyword">fn</span> <span class="function declaration">main</span><span class="parenthesis">(</span><span class="parenthesis">)</span> <span class="brace">{</span> + <span class="macro default_library library">format_args</span><span class="macro_bang">!</span><span class="parenthesis">(</span>"{} {}, {} (подозрение на спам: {:.2}%)"б<span class="parenthesis">)</span><span class="semicolon">;</span> +<span class="brace">}</span></code></pre>
\ 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)), }; |