rust-lang / rust-lang/rust-analyzer

highlight: panic: end byte index 48 is not a char boundary; it is inside 'ệ' (bytes 47..50 of string)

Open
#23,259 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-doc-comments C-bug I-panic
Dominant language
Rust
Stars
16.9k
Forks
2.2k
Avg merge
1d 12h
Merged PRs (30d)
72

Description

#[doc = "
~~~
let s = \"中华Việt Nam\";
8: ệ
"]
fn main() {}

rust-analyzer highlight < code.rs

thread 'main' (1036223) panicked at src/tools/rust-analyzer/crates/ide/src/syntax_highlighting/html.rs:40:38:
end byte index 48 is not a char boundary; it is inside 'ệ' (bytes 47..50 of string)
stack backtrace:
   0:     0x7f5271ea1f16 - <<std[c12b020f820b1a60]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[27a82328e35982ef]::fmt::Display>::fmt
   1:     0x7f527260b98f - core[27a82328e35982ef]::fmt::write
   2:     0x7f5271eb702c - <std[c12b020f820b1a60]::sys::stdio::unix::Stderr as core[27a82328e35982ef]::io::write::Write>::write_fmt
   3:     0x7f5271e74a1a - std[c12b020f820b1a60]::panicking::default_hook::{closure#0}
   4:     0x7f5271e961d3 - std[c12b020f820b1a60]::panicking::default_hook
   5:     0x7f5271e9663b - std[c12b020f820b1a60]::panicking::panic_with_hook
   6:     0x7f5271e74ad2 - std[c12b020f820b1a60]::panicking::panic_handlerrust-analyzer 1.100.0-nightly (fd7ed57 2026-08-29)
::{closure#0}
   7:     0x7f5271e6cba9 - std[c12b020f820b1a60]::sys::backtrace::__rust_end_short_backtrace::<std[c12b020f820b1a60]::panicking::panic_handler::{closure#0}, !>
   8:     0x7f5271e763fd - __rustc[2017c61168e86746]::rust_begin_unwind
   9:     0x7f526eb1d73c - core[27a82328e35982ef]::panicking::panic_fmt
  10:     0x7f527077bd03 - core[27a82328e35982ef]::str::slice_error_fail_rt
  11:     0x7f52705a7a2a - core[27a82328e35982ef]::str::slice_error_fail
  12:     0x55fe4969a802 - ide[fafaf42c27ac4820]::syntax_highlighting::html::highlight_as_html_with_config
  13:     0x55fe4960178c - <ide[fafaf42c27ac4820]::Analysis>::highlight_as_html
  14:     0x55fe4a0b56e2 - <rust_analyzer[a070aa089420c7c5]::cli::flags::Highlight>::run
  15:     0x55fe4a2ec962 - rust_analyzer[a3113cdea8e5f10]::main
  16:     0x55fe4a2e8993 - std[c12b020f820b1a60]::sys::backtrace::__rust_begin_short_backtrace::<fn() -> core[27a82328e35982ef]::result::Result<std[c12b020f820b1a60]::process::ExitCode, anyhow[9c6208b72e48fd79]::Error>, core[27a82328e35982ef]::result::Result<std[c12b020f820b1a60]::process::ExitCode, anyhow[9c6208b72e48fd79]::Error>>
  17:     0x55fe4a2ea942 - std[c12b020f820b1a60]::rt::lang_start::<core[27a82328e35982ef]::result::Result<std[c12b020f820b1a60]::process::ExitCode, anyhow[9c6208b72e48fd79]::Error>>::{closure#0}
  18:     0x7f52739cd352 - std[c12b020f820b1a60]::rt::lang_start_internal
  19:     0x55fe4a3032b8 - main
  20:     0x7f526ca27781 - <unknown>
  21:     0x7f526ca278b9 - __libc_start_main
  22:     0x55fe48c0d3e9 - <unknown>
  23:                0x0 - <unknown>

rust-analyzer 1.100.0-nightly (fd7ed57 2026-08-29)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in src/tools/rust-analyzer/crates/ide/src/syntax_highlighting/html.rs at the reported line, then reproduce the failure with the provided code.rs input and the rust-analyzer highlight < code.rs command. Trace the byte-range handling for the multibyte character; done means this input completes without a panic and the highlight output remains valid.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
76/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.