rust-lang / rust-lang/rust-analyzer
panic: frontmatter without EOF \n
Open
Nobody has claimed this yet.
B-unstable
C-bug
I-panic
- Dominant language
- Rust
- Stars
- 16.9k
- Forks
- 2.2k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 72
Description
---
-
note for the repro there must not be a "\n" at the end of the file; save as code.rs, then truncate -s -1 code.rs
RUSTFLAGS="" ~/.rustup/toolchains/master/bin/rust-analyzer highlight < code.rs
thread 'main' (1114745) panicked at /rustc/d62fb1c8a007f6967376a52da8315ae51b64a70c/library/core/src/str/mod.rs:861:21:
end byte index 2 is out of bounds for string of length 1
stack backtrace:
0: 0x7f10ed64bed6 - <<std[cf0678d25afc9ccf]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[9662e8fc1527f23c]::fmt::Display>::fmt
1: 0x7f10edc0f0c8 - core[9662e8fc1527f23c]::fmt::write
2: 0x7f10ed66113c - <std[cf0678d25afc9ccf]::sys::stdio::unix::Stderr as core[9662e8fc1527f23c]::io::write::Write>::write_fmt
3: 0x7f10ed61e04a - std[cf0678d25afc9ccf]::panicking::default_hook::{closure#0}
4: 0x7f10ed63e5f3 - std[cf0678d25afc9ccf]::panicking::default_hook
5: 0x7f10ed63ea5b - std[cf0678d25afc9ccf]::panicking::panic_with_hook
6: 0x7f10ed61e102 - std[cf0678d25afc9ccf]::panicking::panic_handler::{closure#0}
7: 0x7f10ed616a89 - std[cf0678d25afc9ccf]::sys::backtrace::__rust_end_short_backtrace::<std[cf0678d25afc9ccf]::panicking::panic_handler::{closure#0}, !>
8: 0x7f10ed61fa5d - __rustc[c7d2cd00dee8f709]::rust_begin_unwind
9: 0x7f10ea360bac - core[9662e8fc1527f23c]::panicking::panic_fmt
10: 0x7f10ebf95e46 - core[9662e8fc1527f23c]::str::slice_error_fail_rt
11: 0x7f10ebd93f3a - core[9662e8fc1527f23c]::str::slice_error_fail
12: 0x5618991013c9 - <parser[ca50523a01af9e94]::lexed_str::LexedStr>::new
13: 0x561899787e33 - <syntax[88d6ea7446ced16c]::ast::generated::nodes::SourceFile>::parse
14: 0x56189802409b - <<base_db[1ece6b420f9ff01c]::editioned_file_id::EditionedFileId>::parse::_::parse_Configuration_ as salsa[65a99894a6a39c25]::function::Configuration>::execute
15: 0x5618980132e8 - <salsa[65a99894a6a39c25]::function::IngredientImpl<<base_db[1ece6b420f9ff01c]::editioned_file_id::EditionedFileId>::parse::_::parse_Configuration_>>::execute
16: 0x56189801102b - <base_db[1ece6b420f9ff01c]::editioned_file_id::EditionedFileId>::parse
17: 0x561898439628 - <hir_expand[b9ae3878f9b984c5]::HirFileId>::parse_or_expand
18: 0x5618984200cb - <salsa[65a99894a6a39c25]::function::IngredientImpl<<hir_expand[b9ae3878f9b984c5]::HirFileId>::ast_id_map::_::ast_id_map__Configuration_>>::execute
19: 0x56189840d5f6 - salsa[65a99894a6a39c25]::attach::attach::<&span[d2036d0eb69be145]::ast_id::AstIdMap, dyn base_db[1ece6b420f9ff01c]::SourceDatabase, <hir_expand[b9ae3878f9b984c5]::HirFileId>::ast_id_map::ast_id_map_::{closure#0}>::{closure#0}
20: 0x561898319796 - <hir_def[36b966b8558e1ecf]::item_tree::_::file_item_tree_query_Configuration_ as salsa[65a99894a6a39c25]::function::Configuration>::execute
21: 0x56189820683c - <salsa[65a99894a6a39c25]::function::IngredientImpl<hir_def[36b966b8558e1ecf]::item_tree::_::file_item_tree_query_Configuration_>>::execute
22: 0x5618982d107e - hir_def[36b966b8558e1ecf]::item_tree::file_item_tree
23: 0x5618982db8f4 - hir_def[36b966b8558e1ecf]::nameres::collector::collect_defs
24: 0x561898317fc8 - <hir_def[36b966b8558e1ecf]::nameres::_::crate_local_def_map_Configuration_ as salsa[65a99894a6a39c25]::function::Configuration>::execute
25: 0x561898205e05 - <salsa[65a99894a6a39c25]::function::IngredientImpl<hir_def[36b966b8558e1ecf]::nameres::_::crate_local_def_map_Configuration_>>::execute
26: 0x561898203581 - <salsa[65a99894a6a39c25]::function::IngredientImpl<hir_def[36b966b8558e1ecf]::nameres::_::crate_local_def_map_Configuration_>>::fetch
27: 0x5618981598a1 - <salsa[65a99894a6a39c25]::attach::Attached>::attach::<dyn base_db[1ece6b420f9ff01c]::SourceDatabase, &hir_def[36b966b8558e1ecf]::nameres::DefMapPair, hir_def[36b966b8558e1ecf]::nameres::crate_local_def_map::{closure#0}>
28: 0x561898115357 - <hir[c107f094967a75ab]::semantics::source_to_def::SourceToDefCtx>::file_to_def
29: 0x5618980f2454 - <hir[c107f094967a75ab]::semantics::SemanticsImpl>::file_to_module_defs
30: 0x5618980ffae6 - <hir[c107f094967a75ab]::semantics::SemanticsImpl>::attach_first_edition_opt
31: 0x561898a91d5c - ide[37737ece80204ca3]::syntax_highlighting::html::highlight_as_html_with_config
32: 0x5618989f8dec - <ide[37737ece80204ca3]::Analysis>::highlight_as_html
33: 0x561899447872 - <rust_analyzer[c9a7b5a74bd4f6b9]::cli::flags::Highlight>::run
34: 0x5618996e7034 - rust_analyzer[e3769bb504499c95]::main
35: 0x56189967d713 - std[cf0678d25afc9ccf]::sys::backtrace::__rust_begin_short_backtrace::<fn() -> core[9662e8fc1527f23c]::result::Result<std[cf0678d25afc9ccf]::process::ExitCode, anyhow[6279a09abd95b935]::Error>, core[9662e8fc1527f23c]::result::Result<std[cf0678d25afc9ccf]::process::ExitCode, anyhow[6279a09abd95b935]::Error>>
36: 0x5618996e0082 - std[cf0678d25afc9ccf]::rt::lang_start::<core[9662e8fc1527f23c]::result::Result<std[cf0678d25afc9ccf]::process::ExitCode, anyhow[6279a09abd95b935]::Error>>::{closure#0}
37: 0x7f10eed6af99 - std[cf0678d25afc9ccf]::rt::lang_start_internal
38: 0x561899700148 - main
39: 0x7f10e8627741 - <unknown>
40: 0x7f10e8627879 - __libc_start_main
41: 0x561897ff16e9 - <unknown>
42: 0x0 - <unknown>
rust-analyzer 1.99.0-nightly (d62fb1c 2026-07-16)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue with the provided rust-analyzer highlight < code.rs command and the EOF-less frontmatter input. Start at parser::lexed_str::LexedStr::new, then follow syntax::ast::generated::nodes::SourceFile::parse into the highlighting entry point. Done means this input no longer panics during highlighting.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers, devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100