Skip to content

[ICE]: corecursive trait solver failure with lifetimes #162343

Closed

Description

@mumbleskates

Code

code here, branch here

Meta

rustc --version --verbose:

rustc 1.100.0-nightly (0ed41eb41 2026-09-04)
binary: rustc
commit-hash: 0ed41eb4142dda2df61eb1145a312c1a9d62eb56
commit-date: 2026-09-04
host: x86_64-unknown-linux-gnu
release: 1.100.0-nightly
LLVM version: 23.1.1

rustc 1.98.1 (48a229cea 2026-09-01)
binary: rustc
commit-hash: 48a229ceaefd4985c50990b14116b6d856af0985
commit-date: 2026-09-01
host: x86_64-unknown-linux-gnu
release: 1.98.1
LLVM version: 22.1.8

Error output

On nightly:

error: internal compiler error: /rustc-dev/0ed41eb4142dda2df61eb1145a312c1a9d62eb56/compiler/rustc_middle/src/ty/instance.rs:640:21: failed to resolve instance for <ListValue<'_> as RawMessage>::clear
   --> test-ice/src/lib.rs:250:9
    |
250 |         <ListValue<'a> as ::bilrost::encoding::RawMessage>::clear(val);
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

[...]

query stack during panic:
#0 [items_of_instance] collecting items used by `<impl at test-ice/src/lib.rs:241:1: 244:84>::clear`
#1 [collect_and_partition_mono_items] collect_and_partition_mono_items

On stable: No error (‼️), consumes resources seemingly indefinitely without terminating

Backtrace

thread 'rustc' (2849301) panicked at /rustc-dev/0ed41eb4142dda2df61eb1145a312c1a9d62eb56/compiler/rustc_middle/src/ty/instance.rs:640:21:
Box<dyn Any>
stack backtrace:
   0:     0x79f5ec291516 - <<std[d4c1480f659289a4]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[645f4c3e01480c61]::fmt::Display>::fmt
   1:     0x79f5eca0ba8f - core[645f4c3e01480c61]::fmt::write
   2:     0x79f5ec2a660c - <std[d4c1480f659289a4]::sys::stdio::unix::Stderr as core[645f4c3e01480c61]::io::write::Write>::write_fmt
   3:     0x79f5ec263dba - std[d4c1480f659289a4]::panicking::default_hook::{closure#0}
   4:     0x79f5ec285813 - std[d4c1480f659289a4]::panicking::default_hook
   5:     0x79f5eb1dcaef - std[d4c1480f659289a4]::panicking::update_hook::<alloc[85239869be382ab2]::boxed::Box<rustc_driver_impl[52b061d793d3365c]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x79f5ec285cb2 - std[d4c1480f659289a4]::panicking::panic_with_hook
   7:     0x79f5eb20b7d4 - std[d4c1480f659289a4]::panicking::begin_panic::<rustc_errors[a73332a6523420a1]::ExplicitBug>::{closure#0}
   8:     0x79f5eb204566 - std[d4c1480f659289a4]::sys::backtrace::__rust_end_short_backtrace::<std[d4c1480f659289a4]::panicking::begin_panic<rustc_errors[a73332a6523420a1]::ExplicitBug>::{closure#0}, !>
   9:     0x79f5eb20429b - std[d4c1480f659289a4]::panicking::begin_panic::<rustc_errors[a73332a6523420a1]::ExplicitBug>
  10:     0x79f5eb217031 - <rustc_errors[a73332a6523420a1]::diagnostic::BugAbort as rustc_errors[a73332a6523420a1]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  11:     0x79f5eb7894ac - <rustc_errors[a73332a6523420a1]::DiagCtxtHandle>::span_bug::<rustc_span[fb518c986e8dde63]::span_encoding::Span, alloc[85239869be382ab2]::string::String>
  12:     0x79f5eb7b7cc6 - rustc_middle[7aa4fce01e3768ef]::util::bug::opt_span_bug_fmt::<rustc_span[fb518c986e8dde63]::span_encoding::Span>::{closure#0}
  13:     0x79f5eb7b80e2 - rustc_middle[7aa4fce01e3768ef]::ty::context::tls::with_opt::<rustc_middle[7aa4fce01e3768ef]::util::bug::opt_span_bug_fmt<rustc_span[fb518c986e8dde63]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  14:     0x79f5eb7a3400 - rustc_middle[7aa4fce01e3768ef]::ty::context::tls::with_context_opt::<rustc_middle[7aa4fce01e3768ef]::ty::context::tls::with_opt<rustc_middle[7aa4fce01e3768ef]::util::bug::opt_span_bug_fmt<rustc_span[fb518c986e8dde63]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  15:     0x79f5e954aa38 - rustc_middle[7aa4fce01e3768ef]::util::bug::span_bug_fmt::<rustc_span[fb518c986e8dde63]::span_encoding::Span>
  16:     0x79f5ece36103 - <rustc_middle[7aa4fce01e3768ef]::ty::instance::Instance>::expect_resolve
  17:     0x79f5ece38e92 - rustc_monomorphize[f697b03780a3381a]::collector::items_of_instance
  18:     0x79f5ece37c91 - rustc_query_impl[52f5aaaf2d2e4217]::query_vtables::items_of_instance::invoke_provider_fn::__rust_begin_short_backtrace
  19:     0x79f5ed982e81 - rustc_query_impl[52f5aaaf2d2e4217]::execution::try_execute_query::<rustc_middle[7aa4fce01e3768ef]::query::caches::DefaultCache<(rustc_middle[7aa4fce01e3768ef]::ty::instance::Instance, rustc_middle[7aa4fce01e3768ef]::mono::CollectionMode), rustc_middle[7aa4fce01e3768ef]::query::erase::ErasedData<[u8; 32usize]>>, true>
  20:     0x79f5ed9824ab - rustc_query_impl[52f5aaaf2d2e4217]::query_vtables::items_of_instance::execute_query_incr::__rust_end_short_backtrace
  21:     0x79f5edb5f22e - rustc_monomorphize[f697b03780a3381a]::collector::collect_items_rec
  22:     0x79f5edb658b4 - rustc_monomorphize[f697b03780a3381a]::collector::collect_crate_mono_items::{closure#1}::{closure#0}
  23:     0x79f5edb661e3 - rustc_monomorphize[f697b03780a3381a]::partitioning::collect_and_partition_mono_items
  24:     0x79f5edc5cf16 - rustc_query_impl[52f5aaaf2d2e4217]::query_vtables::collect_and_partition_mono_items::invoke_provider_fn::__rust_begin_short_backtrace
  25:     0x79f5ee305451 - rustc_query_impl[52f5aaaf2d2e4217]::execution::try_execute_query::<rustc_middle[7aa4fce01e3768ef]::query::caches::SingleCache<rustc_middle[7aa4fce01e3768ef]::query::erase::ErasedData<[u8; 24usize]>>, true>
  26:     0x79f5ee304e8c - rustc_query_impl[52f5aaaf2d2e4217]::query_vtables::collect_and_partition_mono_items::execute_query_incr::__rust_end_short_backtrace
  27:     0x79f5ed59be03 - rustc_codegen_ssa[ce71d2ce136ae586]::back::symbol_export::exported_generic_symbols_provider_local
  28:     0x79f5edb4fa74 - rustc_query_impl[52f5aaaf2d2e4217]::query_vtables::exported_generic_symbols::invoke_provider_fn::__rust_begin_short_backtrace
  29:     0x79f5edb4e594 - rustc_query_impl[52f5aaaf2d2e4217]::execution::try_execute_query::<rustc_data_structures[35e205c67e017b95]::vec_cache::VecCache<rustc_span[fb518c986e8dde63]::def_id::CrateNum, rustc_middle[7aa4fce01e3768ef]::query::erase::ErasedData<[u8; 16usize]>, rustc_middle[7aa4fce01e3768ef]::dep_graph::graph::DepNodeIndex>, true>
  30:     0x79f5edb4dd27 - rustc_query_impl[52f5aaaf2d2e4217]::query_vtables::exported_generic_symbols::execute_query_incr::__rust_end_short_backtrace
  31:     0x79f5edc0ad97 - <rustc_metadata[8b637ccb72f2b57d]::rmeta::encoder::EncodeContext>::encode_crate_root
  32:     0x79f5edbedee1 - rustc_metadata[8b637ccb72f2b57d]::rmeta::encoder::encode_metadata::{closure#3}
  33:     0x79f5edbec504 - rustc_metadata[8b637ccb72f2b57d]::rmeta::encoder::encode_metadata
  34:     0x79f5edea7190 - rustc_metadata[8b637ccb72f2b57d]::fs::encode_and_write_metadata
  35:     0x79f5ede0363e - <rustc_interface[facc905b6ccf4600]::queries::Linker>::codegen_and_build_linker
  36:     0x79f5eddfae41 - rustc_interface[facc905b6ccf4600]::interface::run_compiler::<(), rustc_driver_impl[52b061d793d3365c]::run_compiler::{closure#0}>::{closure#2}
  37:     0x79f5ede89602 - std[d4c1480f659289a4]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[facc905b6ccf4600]::util::run_in_thread_with_globals<rustc_interface[facc905b6ccf4600]::util::run_in_thread_pool_with_globals<rustc_interface[facc905b6ccf4600]::interface::run_compiler<(), rustc_driver_impl[52b061d793d3365c]::run_compiler::{closure#0}>::{closure#2}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  38:     0x79f5ede893ad - <std[d4c1480f659289a4]::thread::lifecycle::spawn_unchecked<rustc_interface[facc905b6ccf4600]::util::run_in_thread_with_globals<rustc_interface[facc905b6ccf4600]::util::run_in_thread_pool_with_globals<rustc_interface[facc905b6ccf4600]::interface::run_compiler<(), rustc_driver_impl[52b061d793d3365c]::run_compiler::{closure#0}>::{closure#2}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[645f4c3e01480c61]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  39:     0x79f5ede86f47 - <std[d4c1480f659289a4]::sys::thread::unix::Thread>::new::thread_start
  40:     0x79f5e6ea407a - <unknown>
  41:     0x79f5e6f3772c - <unknown>
  42:                0x0 - <unknown>

Activity

  1. added
    I-ICE
    T-compiler
    C-bug
    on Sep 5, 2026
  2. added
    needs-triage
    on Sep 5, 2026
  3. changed the title [-][ICE]:[/-] [+][ICE]: corecursive trait solver failure with type lifetimes[/+] on Sep 5, 2026
  4. changed the title [-][ICE]: corecursive trait solver failure with type lifetimes[/-] [+][ICE]: corecursive trait solver failure with lifetimes[/+] on Sep 5, 2026
  5. cyrgani commented on Sep 6, 2026

    @cyrgani
    Contributor

    smaller:

    trait RawMessage<'a> {
        fn baz() {}
    }
    
    impl<'a> RawMessage<'a> for () where (): RawMessage<'a> {}
    
    trait EmptyState2 {
        fn bar() {}
    }
    impl<'a> EmptyState2 for ()
    where
        (): RawMessage<'a>,
    {
        fn bar() {
            <() as RawMessage>::baz();
        }
    }

    this causes a regular overflow error with -Znext-solver=coherence

  6. added
    S-has-mcve
    WG-trait-system-refactor
    A-trait-system
    S-has-bisection
    and removed
    needs-triage
    on Sep 6, 2026
  7. mumbleskates commented on Sep 8, 2026

    @mumbleskates
    ContributorAuthor

    As noted in the thread: This minimization works great for me to reproduce the polonius crash; however, the old trait solver hang (which to be fair could be a different issue) does not reproduce on this.

  8. mumbleskates commented on Sep 9, 2026

    @mumbleskates
    ContributorAuthor

    The minimization in @amirHdev's PR does reproduce the stable-rustc hang for me

  9. cyrgani commented on Sep 9, 2026

    @cyrgani
    Contributor

    merging them both gives

    trait RawMessage<'a> {
        fn baz() {}
    }
    
    impl<'a> RawMessage<'a> for () where (): RawMessage<'a> + EmptyState2<'a> {}
    
    trait EmptyState2<'a> {
        fn bar() {}
    }
    impl<'a> EmptyState2<'a> for ()
    where
        (): RawMessage<'a>,
    {
        fn bar() {
            <() as RawMessage>::baz();
        }
    }

    which also reproduces the hang on stable.

  10. mumbleskates commented on Sep 9, 2026

    @mumbleskates
    ContributorAuthor

    beautiful, thank you!

  11. added a commit that references this issue on Oct 16, 2026
    a0aea04
  12. added a commit that references this issue on Oct 16, 2026
    63a228a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-trait-systemC-bugI-ICES-has-bisectionS-has-mcveT-compilerWG-trait-system-refactor

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions