Skip to content

[ICE]: bpos.to_u32() >= mbc.pos.to_u32() + mbc.bytes as u32 #155037

@matthiaskrgr

Description

@matthiaskrgr

auto-reduced (treereduce-rust):

// error.

trait Trait {
    type 对__否
    where
        u32: Copy,
    = ();
}

original:

// error.
//@ run-rustfix

#![feature(diagnostic_on_move)]
#![feature(LocalResult)]

trait Trait {
    // Not fine, suggests moving.
    type Assoc where u32: Copy = ();
    //~^ WARNING where clause not allowed here
    // Not fine, suggests moving `u32: Copy`
    type 对__否 where u32: Copy = () where i32: Copy;
    // This test would tries to unify `N` with `N + 1` which must fail the occurs check.
}

fn main() {}

Version information

rustc 1.96.0-nightly (1948ee19e 2026-04-09)
binary: rustc
commit-hash: 1948ee19e95ef7835624c591eef11a8838b66ec7
commit-date: 2026-04-09
host: x86_64-unknown-linux-gnu
release: 1.96.0-nightly
LLVM version: 22.1.2

Possibly related line of code:

if mbc.pos < bpos {
// Every character is at least one byte, so we only
// count the actual extra bytes.
total_extra_bytes += mbc.bytes as u32 - 1;
// We should never see a byte position in the middle of a
// character.
assert!(bpos.to_u32() >= mbc.pos.to_u32() + mbc.bytes as u32);
} else {
break;
}
}
assert!(total_extra_bytes <= bpos.to_u32());

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

Program output

error[E0658]: associated type defaults are unstable
 --> /tmp/icemaker_global_tempdir.assyrpTvnsKy/rustc_testrunner_tmpdir_reporting.6HVvnCCt3Z1g/mvce.rs:4:5
  |
4 | /     type 对__否
5 | |     where
6 | |         u32: Copy,
7 | |     = ();
  | |_________^
  |
  = note: see issue #29661 <https://github.com/rust-lang/rust/issues/29661> for more information
  = help: add `#![feature(associated_type_defaults)]` to the crate attributes to enable
  = note: this compiler was built on 2026-04-09; consider upgrading it if it is out of date

warning: associated type `对__否` should have an upper camel case name
 --> /tmp/icemaker_global_tempdir.assyrpTvnsKy/rustc_testrunner_tmpdir_reporting.6HVvnCCt3Z1g/mvce.rs:4:10
  |
4 |     type 对__否
  |          ^^^^^^ help: convert the identifier to upper camel case: `对_否`
  |
  = note: `#[warn(non_camel_case_types)]` (part of `#[warn(nonstandard_style)]`) on by default


thread 'rustc' (1415007) panicked at /rustc-dev/1948ee19e95ef7835624c591eef11a8838b66ec7/compiler/rustc_span/src/lib.rs:2439:17:
assertion failed: bpos.to_u32() >= mbc.pos.to_u32() + mbc.bytes as u32
stack backtrace:
   0:     0x7f51d69e685b - <<std[afe9d9a8c7c60344]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[a753eb1c755cef5d]::fmt::Display>::fmt
   1:     0x7f51d701df88 - core[a753eb1c755cef5d]::fmt::write
   2:     0x7f51d69fdb26 - <std[afe9d9a8c7c60344]::sys::stdio::unix::Stderr as std[afe9d9a8c7c60344]::io::Write>::write_fmt
   3:     0x7f51d69bcb58 - std[afe9d9a8c7c60344]::panicking::default_hook::{closure#0}
   4:     0x7f51d69d9ec3 - std[afe9d9a8c7c60344]::panicking::default_hook
   5:     0x7f51d59db2bc - std[afe9d9a8c7c60344]::panicking::update_hook::<alloc[ad0d6ab31f3a4629]::boxed::Box<rustc_driver_impl[417fcbfcaea66ef1]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x7f51d69da1a2 - std[afe9d9a8c7c60344]::panicking::panic_with_hook
   7:     0x7f51d69bcc4a - std[afe9d9a8c7c60344]::panicking::panic_handler::{closure#0}
   8:     0x7f51d69b1179 - std[afe9d9a8c7c60344]::sys::backtrace::__rust_end_short_backtrace::<std[afe9d9a8c7c60344]::panicking::panic_handler::{closure#0}, !>
   9:     0x7f51d69be67d - __rustc[e13175df4d110ca]::rust_begin_unwind
  10:     0x7f51d36543fc - core[a753eb1c755cef5d]::panicking::panic_fmt
  11:     0x7f51d3005dd2 - core[a753eb1c755cef5d]::panicking::panic
  12:     0x7f51d75d1b68 - <rustc_span[e2aab30ab9650ce5]::source_map::SourceMap>::lookup_char_pos
  13:     0x7f51d8525352 - <rustc_span[e2aab30ab9650ce5]::source_map::SourceMap>::is_valid_span
  14:     0x7f51d8528848 - <rustc_errors[972bb65355123279]::annotate_snippet_emitter_writer::AnnotateSnippetEmitter>::emit_messages_default
  15:     0x7f51d8521a9f - <rustc_errors[972bb65355123279]::annotate_snippet_emitter_writer::AnnotateSnippetEmitter as rustc_errors[972bb65355123279]::emitter::Emitter>::emit_diagnostic
  16:     0x7f51d851f1f0 - <rustc_errors[972bb65355123279]::DiagCtxtInner>::emit_diagnostic::{closure#3}
  17:     0x7f51d851d36c - rustc_interface[f2e03cdea6df0bf4]::callbacks::track_diagnostic::<core[a753eb1c755cef5d]::option::Option<rustc_span[e2aab30ab9650ce5]::ErrorGuaranteed>>
  18:     0x7f51d851bdb1 - <rustc_errors[972bb65355123279]::DiagCtxtInner>::emit_diagnostic
  19:     0x7f51d851bc5f - <rustc_errors[972bb65355123279]::DiagCtxtHandle>::emit_diagnostic
  20:     0x7f51d851bb1d - <() as rustc_errors[972bb65355123279]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  21:     0x7f51d79fb332 - rustc_middle[20c1f01b7ae5e16e]::lint::emit_lint_base::emit_lint_base_impl
  22:     0x7f51d79fabcc - <rustc_lint[e69b855d1aaf7628]::context::EarlyContext as rustc_lint[e69b855d1aaf7628]::context::LintContext>::opt_span_lint::<rustc_error_messages[bbfb23b858bc1419]::MultiSpan, rustc_lint[e69b855d1aaf7628]::early::diagnostics::DiagAndSess>
  23:     0x7f51d735e182 - rustc_ast[c71d2570fa9e4091]::visit::walk_item_inner::<rustc_ast[c71d2570fa9e4091]::ast::AssocItemKind, rustc_lint[e69b855d1aaf7628]::early::EarlyContextAndPass<rustc_lint[e69b855d1aaf7628]::BuiltinCombinedEarlyLintPass>>
  24:     0x7f51d735c9d6 - rustc_ast[c71d2570fa9e4091]::visit::walk_item_inner::<rustc_ast[c71d2570fa9e4091]::ast::ItemKind, rustc_lint[e69b855d1aaf7628]::early::EarlyContextAndPass<rustc_lint[e69b855d1aaf7628]::BuiltinCombinedEarlyLintPass>>
  25:     0x7f51d735b55f - <rustc_lint[e69b855d1aaf7628]::early::EarlyContextAndPass<rustc_lint[e69b855d1aaf7628]::BuiltinCombinedEarlyLintPass> as rustc_ast[c71d2570fa9e4091]::visit::Visitor>::visit_item
  26:     0x7f51d73530e6 - rustc_interface[f2e03cdea6df0bf4]::passes::early_lint_checks
  27:     0x7f51d8227209 - rustc_query_impl[8effcd60942cb632]::execution::try_execute_query::<rustc_middle[20c1f01b7ae5e16e]::query::caches::SingleCache<rustc_middle[20c1f01b7ae5e16e]::query::erase::ErasedData<[u8; 0usize]>>, false>
  28:     0x7f51d8226fe9 - rustc_query_impl[8effcd60942cb632]::query_impl::early_lint_checks::execute_query_non_incr::__rust_end_short_backtrace
  29:     0x7f51d782d600 - rustc_ast_lowering[e495849d0dfb149e]::lower_to_hir
  30:     0x7f51d8227daa - rustc_query_impl[8effcd60942cb632]::query_impl::hir_crate::invoke_provider_fn::__rust_begin_short_backtrace
  31:     0x7f51d8226525 - rustc_query_impl[8effcd60942cb632]::execution::try_execute_query::<rustc_middle[20c1f01b7ae5e16e]::query::caches::SingleCache<rustc_middle[20c1f01b7ae5e16e]::query::erase::ErasedData<[u8; 8usize]>>, false>
  32:     0x7f51d83a1e7f - rustc_query_impl[8effcd60942cb632]::query_impl::hir_crate::execute_query_non_incr::__rust_end_short_backtrace
  33:     0x7f51d83a1edb - rustc_middle[20c1f01b7ae5e16e]::hir::map::hir_crate_items
  34:     0x7f51d822a225 - rustc_query_impl[8effcd60942cb632]::query_impl::hir_crate_items::invoke_provider_fn::__rust_begin_short_backtrace
  35:     0x7f51d8226525 - rustc_query_impl[8effcd60942cb632]::execution::try_execute_query::<rustc_middle[20c1f01b7ae5e16e]::query::caches::SingleCache<rustc_middle[20c1f01b7ae5e16e]::query::erase::ErasedData<[u8; 8usize]>>, false>
  36:     0x7f51d822538f - rustc_query_impl[8effcd60942cb632]::query_impl::hir_crate_items::execute_query_non_incr::__rust_end_short_backtrace
  37:     0x7f51d70b91d8 - rustc_interface[f2e03cdea6df0bf4]::passes::analysis
  38:     0x7f51d8227209 - rustc_query_impl[8effcd60942cb632]::execution::try_execute_query::<rustc_middle[20c1f01b7ae5e16e]::query::caches::SingleCache<rustc_middle[20c1f01b7ae5e16e]::query::erase::ErasedData<[u8; 0usize]>>, false>
  39:     0x7f51d8226e75 - rustc_query_impl[8effcd60942cb632]::query_impl::analysis::execute_query_non_incr::__rust_end_short_backtrace
  40:     0x7f51d824f4de - rustc_interface[f2e03cdea6df0bf4]::interface::run_compiler::<(), rustc_driver_impl[417fcbfcaea66ef1]::run_compiler::{closure#0}>::{closure#1}
  41:     0x7f51d82055fe - std[afe9d9a8c7c60344]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[f2e03cdea6df0bf4]::util::run_in_thread_with_globals<rustc_interface[f2e03cdea6df0bf4]::util::run_in_thread_pool_with_globals<rustc_interface[f2e03cdea6df0bf4]::interface::run_compiler<(), rustc_driver_impl[417fcbfcaea66ef1]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  42:     0x7f51d8205ea0 - <std[afe9d9a8c7c60344]::thread::lifecycle::spawn_unchecked<rustc_interface[f2e03cdea6df0bf4]::util::run_in_thread_with_globals<rustc_interface[f2e03cdea6df0bf4]::util::run_in_thread_pool_with_globals<rustc_interface[f2e03cdea6df0bf4]::interface::run_compiler<(), rustc_driver_impl[417fcbfcaea66ef1]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[a753eb1c755cef5d]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  43:     0x7f51d8206dac - <std[afe9d9a8c7c60344]::sys::thread::unix::Thread>::new::thread_start
  44:     0x7f51d1ca597a - <unknown>
  45:     0x7f51d1d292bc - <unknown>
  46:                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.96.0-nightly (1948ee19e 2026-04-09) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [early_lint_checks] perform lints prior to AST lowering
#1 [hir_crate] getting the crate HIR
#2 [hir_crate_items] getting HIR crate items
#3 [analysis] running analysis passes on crate `mvce`
end of query stack
error: aborting due to 1 previous error; 2 warnings emitted

For more information about this error, try `rustc --explain E0658`.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsC-bugCategory: This is a bug.F-associated_type_defaults`#![feature(associated_type_defaults)]`I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-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