Skip to content

[ICE]: frontmatter: begin <= end (4 <= 0) when slicing ---- #151882

@matthiaskrgr

Description

@matthiaskrgr

snippet:

----

Version information

rustc 1.95.0-nightly (a293cc4af 2026-01-30)
binary: rustc
commit-hash: a293cc4af8b26701c42738381c0c6f9d2ba881e0
commit-date: 2026-01-30
host: x86_64-unknown-linux-gnu
release: 1.95.0-nightly
LLVM version: 22.1.0

Possibly related line of code:

);
self.dcx().emit_err(errors::FrontmatterInvalidInfostring { span });
}
let last_line_start = real_s.rfind('\n').map_or(0, |i| i + 1);
let content = &real_s[line_end..last_line_start];
if let Some(cr_offset) = content.find('\r') {
let cr_pos = start + BytePos((real_start + line_end + cr_offset) as u32);
let span = self.mk_sp(cr_pos, cr_pos + BytePos(1 as u32));
self.dcx().emit_err(errors::BareCrFrontmatter { span });
}

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc

Program output

error: invalid infostring for frontmatter
 --> /tmp/icemaker_global_tempdir.Qo7uG1unyi8h/rustc_testrunner_tmpdir_reporting.UUbESpCjbC7E/mvce.rs:1:5
  |
1 | ----
  |     ^
  |
  = note: frontmatter infostrings must be a single identifier immediately following the opening


thread 'rustc' (87314) panicked at /rustc-dev/a293cc4af8b26701c42738381c0c6f9d2ba881e0/compiler/rustc_parse/src/lexer/mod.rs:628:30:
begin <= end (4 <= 0) when slicing `----`
stack backtrace:
   0:     0x7f538bc44ebb - <<std[b56300d62699629]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[1940e17cfe77f04e]::fmt::Display>::fmt
   1:     0x7f538c20ef88 - core[1940e17cfe77f04e]::fmt::write
   2:     0x7f538bc5bd96 - <std[b56300d62699629]::sys::stdio::unix::Stderr as std[b56300d62699629]::io::Write>::write_fmt
   3:     0x7f538bc1af68 - std[b56300d62699629]::panicking::default_hook::{closure#0}
   4:     0x7f538bc38283 - std[b56300d62699629]::panicking::default_hook
   5:     0x7f538ac0da0d - std[b56300d62699629]::panicking::update_hook::<alloc[77e06c05b3e1163]::boxed::Box<rustc_driver_impl[306165e0f22ac3b8]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x7f538bc38562 - std[b56300d62699629]::panicking::panic_with_hook
   7:     0x7f538bc1b028 - std[b56300d62699629]::panicking::panic_handler::{closure#0}
   8:     0x7f538bc0f599 - std[b56300d62699629]::sys::backtrace::__rust_end_short_backtrace::<std[b56300d62699629]::panicking::panic_handler::{closure#0}, !>
   9:     0x7f538bc1ca8d - __rustc[dff7bba7b93d99f5]::rust_begin_unwind
  10:     0x7f53888c973c - core[1940e17cfe77f04e]::panicking::panic_fmt
  11:     0x7f538a57c0ee - core[1940e17cfe77f04e]::str::slice_error_fail_rt
  12:     0x7f5388c699ca - core[1940e17cfe77f04e]::str::slice_error_fail
  13:     0x7f5388c658ab - <rustc_parse[25eb9a6f6d8ec74f]::lexer::Lexer>::bump_minimal
  14:     0x7f538d265d25 - <rustc_parse[25eb9a6f6d8ec74f]::lexer::Lexer>::lex_token_trees
  15:     0x7f538d265693 - rustc_parse[25eb9a6f6d8ec74f]::source_file_to_stream
  16:     0x7f538cf13f90 - rustc_parse[25eb9a6f6d8ec74f]::new_parser_from_source_file
  17:     0x7f538cf13f00 - rustc_parse[25eb9a6f6d8ec74f]::new_parser_from_file
  18:     0x7f538d241848 - rustc_interface[c33df4e5b4e639ae]::passes::parse
  19:     0x7f538d39484f - rustc_interface[c33df4e5b4e639ae]::interface::run_compiler::<(), rustc_driver_impl[306165e0f22ac3b8]::run_compiler::{closure#0}>::{closure#1}
  20:     0x7f538d3d25be - std[b56300d62699629]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[c33df4e5b4e639ae]::util::run_in_thread_with_globals<rustc_interface[c33df4e5b4e639ae]::util::run_in_thread_pool_with_globals<rustc_interface[c33df4e5b4e639ae]::interface::run_compiler<(), rustc_driver_impl[306165e0f22ac3b8]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  21:     0x7f538d3d2ae0 - <std[b56300d62699629]::thread::lifecycle::spawn_unchecked<rustc_interface[c33df4e5b4e639ae]::util::run_in_thread_with_globals<rustc_interface[c33df4e5b4e639ae]::util::run_in_thread_pool_with_globals<rustc_interface[c33df4e5b4e639ae]::interface::run_compiler<(), rustc_driver_impl[306165e0f22ac3b8]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[1940e17cfe77f04e]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  22:     0x7f538d3d396c - <std[b56300d62699629]::sys::thread::unix::Thread>::new::thread_start
  23:     0x7f5386c9698b - <unknown>
  24:     0x7f5386d1a9cc - <unknown>
  25:                0x0 - <unknown>

error: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: please make sure that you have updated to the latest nightly

note: rustc 1.95.0-nightly (a293cc4af 2026-01-30) running on x86_64-unknown-linux-gnu

query stack during panic:
end of query stack
error: aborting due to 1 previous error


Metadata

Metadata

Assignees

Labels

C-bugCategory: This is a bug.F-frontmatter`#![feature(frontmatter)]`I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️S-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issueT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions