Skip to content

ICE: all spans must be disjoint #146261

@matthiaskrgr

Description

@matthiaskrgr

snippet:

enum U {
    B(isize, usize),
}

fn main() {
    let x = T::A(U::C);
}

Version information

rustc 1.91.0-nightly (545819dbd 2025-09-06)
binary: rustc
commit-hash: 545819dbd20aedb23979b58489956f0c532328a0
commit-date: 2025-09-06
host: x86_64-unknown-linux-gnu
release: 1.91.0-nightly
LLVM version: 21.1.0

Possibly related line of code:

.cloned()
.filter_map(|mut substitution| {
// Assumption: all spans are in the same file, and all spans
// are disjoint. Sort in ascending order.
substitution.parts.sort_by_key(|part| part.span.lo());
// Verify the assumption that all spans are disjoint
assert_eq!(
substitution.parts.array_windows().find(|[a, b]| a.span.overlaps(b.span)),
None,
"all spans must be disjoint",
);
// Account for cases where we are suggesting the same code that's already

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

Program output

error[E0433]: failed to resolve: use of undeclared type `T`
 --> /tmp/icemaker_global_tempdir.Q6tglH6czsBn/rustc_testrunner_tmpdir_reporting.xoB9eZKc3cgt/mvce.rs:6:13
  |
6 |     let x = T::A(U::C);
  |             ^
  |             |
  |             use of undeclared type `T`
  |             help: an enum with a similar name exists: `U`

error[E0599]: no variant or associated item named `C` found for enum `U` in the current scope
 --> /tmp/icemaker_global_tempdir.Q6tglH6czsBn/rustc_testrunner_tmpdir_reporting.xoB9eZKc3cgt/mvce.rs:6:21
  |
1 | enum U {
  | ------ variant or associated item `C` not found for this enum
...
6 |     let x = T::A(U::C);
  |                     ^ variant or associated item not found in `U`
  |

thread 'rustc' (3965356) panicked at compiler/rustc_errors/src/lib.rs:385:17:
assertion `left == right` failed: all spans must be disjoint
  left: Some([SubstitutionPart { span: /tmp/icemaker_global_tempdir.Q6tglH6czsBn/rustc_testrunner_tmpdir_reporting.xoB9eZKc3cgt/mvce.rs:6:18: 6:22 (#0), snippet: "/* isize */, /* usize */" }, SubstitutionPart { span: /tmp/icemaker_global_tempdir.Q6tglH6czsBn/rustc_testrunner_tmpdir_reporting.xoB9eZKc3cgt/mvce.rs:6:21: 6:22 (#0), snippet: "B" }])
 right: None
stack backtrace:
   0:     0x7fbddea7a6d2 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::hc3c24dbc0e3117f4
   1:     0x7fbddf20c57c - core::fmt::write::h29b0ae7fb737cdf7
   2:     0x7fbddea2e951 - std::io::Write::write_fmt::hfbf30fe4bcb95c8f
   3:     0x7fbddea3ffd2 - std::sys::backtrace::BacktraceLock::print::h848c524e8acac552
   4:     0x7fbddea462a7 - std::panicking::default_hook::{{closure}}::hb8c7b3cc8fb2d5dd
   5:     0x7fbddea45db3 - std::panicking::default_hook::h37279b6c9f1102b6
   6:     0x7fbddda671f1 - std[cdb730cb4561e573]::panicking::update_hook::<alloc[de6c300a92ce283a]::boxed::Box<rustc_driver_impl[57fd2133dc62b146]::install_ice_hook::{closure#1}>>::{closure#0}
   7:     0x7fbddea467af - std::panicking::panic_with_hook::h000910830c041a29
   8:     0x7fbddea4655a - std::panicking::panic_handler::{{closure}}::h417045386ececce4
   9:     0x7fbddea40109 - std::sys::backtrace::__rust_end_short_backtrace::h02af68c94bdea14f
  10:     0x7fbddea1fc8d - __rustc[e33a429a800d0dee]::rust_begin_unwind
  11:     0x7fbddbc365f0 - core::panicking::panic_fmt::hc1b7583a75e0fdc1
  12:     0x7fbddd43eab3 - core::panicking::assert_failed_inner::h2de980fd5b33037e
  13:     0x7fbddda97b2f - core[9456f0e655e63c05]::panicking::assert_failed::<core[9456f0e655e63c05]::option::Option<&[rustc_errors[93377e4d1981e1c0]::SubstitutionPart; 2usize]>, core[9456f0e655e63c05]::option::Option<&[rustc_errors[93377e4d1981e1c0]::SubstitutionPart; 2usize]>>
  14:     0x7fbde07dc8cc - <core[9456f0e655e63c05]::iter::adapters::filter_map::FilterMap<core[9456f0e655e63c05]::iter::adapters::cloned::Cloned<core[9456f0e655e63c05]::iter::adapters::filter::Filter<core[9456f0e655e63c05]::slice::iter::Iter<rustc_errors[93377e4d1981e1c0]::Substitution>, <rustc_errors[93377e4d1981e1c0]::CodeSuggestion>::splice_lines::{closure#0}>>, <rustc_errors[93377e4d1981e1c0]::CodeSuggestion>::splice_lines::{closure#1}> as core[9456f0e655e63c05]::iter::traits::iterator::Iterator>::next
  15:     0x7fbde07ddb4c - <rustc_errors[93377e4d1981e1c0]::emitter::HumanEmitter>::emit_suggestion_default
  16:     0x7fbde06c1926 - <rustc_errors[93377e4d1981e1c0]::emitter::HumanEmitter as rustc_errors[93377e4d1981e1c0]::emitter::Emitter>::emit_diagnostic
  17:     0x7fbde06bd52c - <rustc_errors[93377e4d1981e1c0]::DiagCtxtInner>::emit_diagnostic::{closure#3}
  18:     0x7fbde06bb378 - rustc_interface[70a720fdc895519a]::callbacks::track_diagnostic::<core[9456f0e655e63c05]::option::Option<rustc_span[4c77626872d52f70]::ErrorGuaranteed>>
  19:     0x7fbde06ba374 - <rustc_errors[93377e4d1981e1c0]::DiagCtxtInner>::emit_diagnostic
  20:     0x7fbde06ba221 - <rustc_errors[93377e4d1981e1c0]::DiagCtxtHandle>::emit_diagnostic
  21:     0x7fbddbd68958 - <rustc_span[4c77626872d52f70]::ErrorGuaranteed as rustc_errors[93377e4d1981e1c0]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  22:     0x7fbdddd6b444 - <rustc_hir_typeck[adfa7c083fdf5a8a]::fn_ctxt::FnCtxt>::report_no_match_method_error
  23:     0x7fbdddd57c7d - <rustc_hir_typeck[adfa7c083fdf5a8a]::fn_ctxt::FnCtxt>::report_method_error
  24:     0x7fbddff6b876 - <rustc_hir_typeck[adfa7c083fdf5a8a]::fn_ctxt::FnCtxt>::check_expr_path
  25:     0x7fbddf8d368e - <rustc_hir_typeck[adfa7c083fdf5a8a]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  26:     0x7fbddf8b17ef - <rustc_hir_typeck[adfa7c083fdf5a8a]::fn_ctxt::FnCtxt>::check_expr_call
  27:     0x7fbddf8d46ea - <rustc_hir_typeck[adfa7c083fdf5a8a]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  28:     0x7fbddf86401e - <rustc_hir_typeck[adfa7c083fdf5a8a]::fn_ctxt::FnCtxt>::check_decl
  29:     0x7fbddf8522ea - <rustc_hir_typeck[adfa7c083fdf5a8a]::fn_ctxt::FnCtxt>::check_expr_block
  30:     0x7fbddf8d4c0f - <rustc_hir_typeck[adfa7c083fdf5a8a]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  31:     0x7fbddf85de22 - rustc_hir_typeck[adfa7c083fdf5a8a]::check::check_fn
  32:     0x7fbddf6ecfcb - rustc_hir_typeck[adfa7c083fdf5a8a]::typeck_with_inspect::{closure#0}
  33:     0x7fbddf6eb6f0 - rustc_query_impl[e31179642f79d754]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[e31179642f79d754]::query_impl::typeck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[566bc0f40b2fea21]::query::erase::Erased<[u8; 8usize]>>
  34:     0x7fbddf3fb3c5 - rustc_query_system[7a27fac43ee7359b]::query::plumbing::try_execute_query::<rustc_query_impl[e31179642f79d754]::DynamicConfig<rustc_data_structures[2503fe1aae1b4642]::vec_cache::VecCache<rustc_span[4c77626872d52f70]::def_id::LocalDefId, rustc_middle[566bc0f40b2fea21]::query::erase::Erased<[u8; 8usize]>, rustc_query_system[7a27fac43ee7359b]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[e31179642f79d754]::plumbing::QueryCtxt, false>
  35:     0x7fbddf3fae09 - rustc_query_impl[e31179642f79d754]::query_impl::typeck::get_query_non_incr::__rust_end_short_backtrace
  36:     0x7fbddfa2cb6a - rustc_hir_analysis[339df563cf152ed2]::check_crate
  37:     0x7fbddf3ef800 - rustc_interface[70a720fdc895519a]::passes::analysis
  38:     0x7fbddf3ef4cd - rustc_query_impl[e31179642f79d754]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[e31179642f79d754]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[566bc0f40b2fea21]::query::erase::Erased<[u8; 0usize]>>
  39:     0x7fbde02e8060 - rustc_query_system[7a27fac43ee7359b]::query::plumbing::try_execute_query::<rustc_query_impl[e31179642f79d754]::DynamicConfig<rustc_query_system[7a27fac43ee7359b]::query::caches::SingleCache<rustc_middle[566bc0f40b2fea21]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[e31179642f79d754]::plumbing::QueryCtxt, false>
  40:     0x7fbde02e7cb6 - rustc_query_impl[e31179642f79d754]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  41:     0x7fbde04a5b76 - rustc_interface[70a720fdc895519a]::passes::create_and_enter_global_ctxt::<core[9456f0e655e63c05]::option::Option<rustc_interface[70a720fdc895519a]::queries::Linker>, rustc_driver_impl[57fd2133dc62b146]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
  42:     0x7fbde0496f05 - rustc_interface[70a720fdc895519a]::interface::run_compiler::<(), rustc_driver_impl[57fd2133dc62b146]::run_compiler::{closure#0}>::{closure#1}
  43:     0x7fbde03aa6c3 - std[cdb730cb4561e573]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[70a720fdc895519a]::util::run_in_thread_with_globals<rustc_interface[70a720fdc895519a]::util::run_in_thread_pool_with_globals<rustc_interface[70a720fdc895519a]::interface::run_compiler<(), rustc_driver_impl[57fd2133dc62b146]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  44:     0x7fbde03aa388 - <<std[cdb730cb4561e573]::thread::Builder>::spawn_unchecked_<rustc_interface[70a720fdc895519a]::util::run_in_thread_with_globals<rustc_interface[70a720fdc895519a]::util::run_in_thread_pool_with_globals<rustc_interface[70a720fdc895519a]::interface::run_compiler<(), rustc_driver_impl[57fd2133dc62b146]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[9456f0e655e63c05]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  45:     0x7fbde03b092f - std::sys::pal::unix::thread::Thread::new::thread_start::hfb8e9b20892af115
  46:     0x7fbdd9a969cb - <unknown>
  47:     0x7fbdd9b1aa0c - <unknown>
  48:                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.91.0-nightly (545819dbd 2025-09-06) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [typeck] type-checking `main`
#1 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 2 previous errors

Some errors have detailed explanations: E0433, E0599.
For more information about an error, try `rustc --explain E0433`.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.D-diagnostic-infraDiagnostics: Issues that affect all diagnostics, or relate to the diagnostic machinery itself.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

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions