Skip to content

ICE on spans with unicode characters #156049

Description

@selfhoster1312

I was trying some crate's span diagnostics with the latest nightly (since it's not available on stable), and had the compiler crash on me. I am using french characters in my struct/function names.

thread 'rustc' panicked at /rustc-dev/c935696dd07ca51e6fba2f6579919eea2a50863b/compiler/rustc_span/src/source_map.rs:914:26:
start byte index 540 is not a char boundary; it is inside 'é' (bytes 539..541 of string)
stack backtrace:
   0:     0x7f8141441d0b - <std[d7d0ddfb10bdc7]::backtrace::Backtrace>::create
   1:     0x7f8141441c55 - <std[d7d0ddfb10bdc7]::backtrace::Backtrace>::force_capture
   2:     0x7f8140450dad - std[d7d0ddfb10bdc7]::panicking::update_hook::<alloc[23a4481fcbb97b7f]::boxed::Box<rustc_driver_impl[50e76e1dd3a4a14e]::install_ice_hook::{closure#1}>>::{closure#0}
   3:     0x7f8141454952 - std[d7d0ddfb10bdc7]::panicking::panic_with_hook
   4:     0x7f8141437252 - std[d7d0ddfb10bdc7]::panicking::panic_handler::{closure#0}
   5:     0x7f814142b789 - std[d7d0ddfb10bdc7]::sys::backtrace::__rust_end_short_backtrace::<std[d7d0ddfb10bdc7]::panicking::panic_handler::{closure#0}, !>
   6:     0x7f8141438cbd - __rustc[4b25d82b28ca9f99]::rust_begin_unwind
   7:     0x7f813e17f93c - core[67c42cdc86eeb6b0]::panicking::panic_fmt
   8:     0x7f813fdbddcc - core[67c42cdc86eeb6b0]::str::slice_error_fail_rt
   9:     0x7f813fbd580a - core[67c42cdc86eeb6b0]::str::slice_error_fail
  10:     0x7f814264213e - <rustc_span[59131b038ab0e4b4]::source_map::SourceMap>::start_point
  11:     0x7f814258242a - <rustc_parse[ce56264028089954]::parser::Parser>::parse_expr_lit
  12:     0x7f8141c1d3d0 - <rustc_parse[ce56264028089954]::parser::Parser>::collect_tokens_for_expr::<<rustc_parse[ce56264028089954]::parser::Parser>::parse_expr_dot_or_call::{closure#0}>
  13:     0x7f8141c15305 - <rustc_parse[ce56264028089954]::parser::Parser>::parse_expr_assoc_with
  14:     0x7f8141bd1eb1 - <rustc_parse[ce56264028089954]::parser::Parser>::parse_block_common
  15:     0x7f8141bcb9d1 - <rustc_parse[ce56264028089954]::parser::Parser>::parse_fn
  16:     0x7f8141b8206f - <rustc_parse[ce56264028089954]::parser::Parser>::parse_item_kind
  17:     0x7f8141b7e16e - <rustc_parse[ce56264028089954]::parser::Parser>::parse_item_common
  18:     0x7f8141b74c19 - <rustc_parse[ce56264028089954]::parser::Parser>::parse_item_impl
  19:     0x7f8141b822a0 - <rustc_parse[ce56264028089954]::parser::Parser>::parse_item_kind
  20:     0x7f8141b7e16e - <rustc_parse[ce56264028089954]::parser::Parser>::parse_item_common
  21:     0x7f8141bbd0ba - <rustc_parse[ce56264028089954]::parser::Parser>::parse_stmt_without_recovery
  22:     0x7f8141bd1a43 - <rustc_parse[ce56264028089954]::parser::Parser>::parse_block_common
  23:     0x7f8141c1c810 - <rustc_parse[ce56264028089954]::parser::Parser>::collect_tokens_for_expr::<<rustc_parse[ce56264028089954]::parser::Parser>::parse_expr_dot_or_call::{closure#0}>
  24:     0x7f8141c15305 - <rustc_parse[ce56264028089954]::parser::Parser>::parse_expr_assoc_with
  25:     0x7f8141bc7644 - <rustc_parse[ce56264028089954]::parser::Parser>::parse_const_item
  26:     0x7f8141b83a13 - <rustc_parse[ce56264028089954]::parser::Parser>::parse_item_kind
  27:     0x7f8141b7e16e - <rustc_parse[ce56264028089954]::parser::Parser>::parse_item_common
  28:     0x7f8142540b1f - <rustc_parse[ce56264028089954]::parser::Parser>::parse_item
  29:     0x7f8142548567 - <rustc_expand[2c972270533de7fe]::proc_macro::DeriveProcMacro as rustc_expand[2c972270533de7fe]::base::MultiItemModifier>::expand
  30:     0x7f8142f54f18 - <rustc_expand[2c972270533de7fe]::expand::MacroExpander>::fully_expand_fragment
  31:     0x7f8142f50800 - <rustc_expand[2c972270533de7fe]::expand::MacroExpander>::expand_crate
  32:     0x7f814220b526 - rustc_interface[57babec0e12977f3]::passes::resolver_for_lowering_raw
  33:     0x7f814220a999 - rustc_query_impl[88f6ad3e1befde91]::query_impl::resolver_for_lowering_raw::invoke_provider_fn::__rust_begin_short_backtrace
  34:     0x7f8142e2abd3 - rustc_query_impl[88f6ad3e1befde91]::execution::try_execute_query::<rustc_middle[c658cc71600ac6d8]::query::caches::SingleCache<rustc_middle[c658cc71600ac6d8]::query::erase::ErasedData<[u8; 16usize]>>, true>
  35:     0x7f8142e2a535 - rustc_query_impl[88f6ad3e1befde91]::query_impl::resolver_for_lowering_raw::execute_query_incr::__rust_end_short_backtrace
  36:     0x7f8142b94ce6 - rustc_interface[57babec0e12977f3]::interface::run_compiler::<(), rustc_driver_impl[50e76e1dd3a4a14e]::run_compiler::{closure#0}>::{closure#1}
  37:     0x7f8142b6217e - std[d7d0ddfb10bdc7]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[57babec0e12977f3]::util::run_in_thread_with_globals<rustc_interface[57babec0e12977f3]::util::run_in_thread_pool_with_globals<rustc_interface[57babec0e12977f3]::interface::run_compiler<(), rustc_driver_impl[50e76e1dd3a4a14e]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  38:     0x7f8142b628ad - <std[d7d0ddfb10bdc7]::thread::lifecycle::spawn_unchecked<rustc_interface[57babec0e12977f3]::util::run_in_thread_with_globals<rustc_interface[57babec0e12977f3]::util::run_in_thread_pool_with_globals<rustc_interface[57babec0e12977f3]::interface::run_compiler<(), rustc_driver_impl[50e76e1dd3a4a14e]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[67c42cdc86eeb6b0]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  39:     0x7f8142b6366c - <std[d7d0ddfb10bdc7]::sys::thread::unix::Thread>::new::thread_start
  40:     0x7f813c69697a - <unknown>
  41:     0x7f813c71a2bc - <unknown>
  42:                0x0 - <unknown>


rustc version: 1.97.0-nightly (c935696dd 2026-04-29)
platform: x86_64-unknown-linux-gnu

query stack during panic:
#0 [resolver_for_lowering_raw] getting the resolver for lowering
end of query stack

This may be because the askama crate i was using is producing incorrect spans due to unicode? but i believe it should not produce an ICE anyway.

I don't have a small repro case right now but i can make one if that's useful.

Metadata

Metadata

Assignees

Labels

A-UnicodeArea: UnicodeA-proc-macrosArea: Procedural macrosC-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️S-needs-reproStatus: This issue has no reproduction and needs a reproduction to make progress.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions