Skip to content

ICE: overflow evaluating the requirement / impl was matchable against binder but now it is not #141124

Open

Description

@matthiaskrgr

Code

trait a {
    type b;
}
impl<c> a for c
where
    c: d,
{
    type b = <(c,) as a>::b;
}
trait d {}
struct e;
impl d for <e as a>::b {}

pub fn main() {}

Meta

rustc --version --verbose:

rustc 1.89.0-nightly (16d2276fa 2025-05-16)
binary: rustc
commit-hash: 16d2276fa6fccb0cc239a542d4c3f0eb46f660ec
commit-date: 2025-05-16
host: x86_64-unknown-linux-gnu
release: 1.89.0-nightly
LLVM version: 20.1.4

Error output

warning: trait `a` should have an upper camel case name
 --> code.rs:1:7
  |
1 | trait a {
  |       ^ help: convert the identifier to upper camel case: `A`
  |
  = note: `#[warn(non_camel_case_types)]` on by default

warning: associated type `b` should have an upper camel case name
 --> code.rs:2:10
  |
2 |     type b;
  |          ^ help: convert the identifier to upper camel case: `B`

warning: type parameter `c` should have an upper camel case name
 --> code.rs:4:6
  |
4 | impl<c> a for c
  |      ^ help: convert the identifier to upper camel case (notice the capitalization): `C`

warning: trait `d` should have an upper camel case name
  --> code.rs:10:7
   |
10 | trait d {}
   |       ^ help: convert the identifier to upper camel case: `D`

warning: type `e` should have an upper camel case name
  --> code.rs:11:8
   |
11 | struct e;
   |        ^ help: convert the identifier to upper camel case: `E`

error[E0275]: overflow evaluating the requirement `(((((((...,),),),),),),): Sized`
 --> code.rs:8:14
  |
8 |     type b = <(c,) as a>::b;
  |              ^^^^^^^^^^^^^^
  |
  = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`code`)
note: required for `(((((((((((((((((((((((((((((((((((((((((((((((((((...,),),),),),),),),),),),),),),),),),),),),),),),),),),),),),),),),),),),),),),),),),),),),),),),),),),)` to implement `a`
 --> code.rs:4:9
  |
4 | impl<c> a for c
  |      -  ^     ^
  |      |
  |      unsatisfied trait bound introduced here
  = note: the full name for the type has been written to 'code.long-type-5344617421428250298.txt'
  = note: consider using `--verbose` to print the full type name to the console
Backtrace

error: internal compiler error: compiler/rustc_trait_selection/src/traits/select/mod.rs:2463:17: impl DefId(0:11 ~ code[7efa]::{impl#1}) was matchable against Binder { value: TraitPredicate(<((e,),) as d>, polarity:Positive), bound_vars: [] } but now is not


thread 'rustc' panicked at compiler/rustc_trait_selection/src/traits/select/mod.rs:2463:17:
Box<dyn Any>
stack backtrace:
   0:     0x7f6eca165b33 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h8ce760ad42a959df
   1:     0x7f6eca805977 - core::fmt::write::h17deacb9d093717d
   2:     0x7f6ecb85bdd1 - std::io::Write::write_fmt::h8edc637e3ed34e58
   3:     0x7f6eca165992 - std::sys::backtrace::BacktraceLock::print::hf4e931b5b8f47af6
   4:     0x7f6eca16958a - std::panicking::default_hook::{{closure}}::h1aa602af6f79c655
   5:     0x7f6eca16910f - std::panicking::default_hook::hb6d5039bf2b4cecd
   6:     0x7f6ec9194e13 - std[23b1014898398f3a]::panicking::update_hook::<alloc[189bd33173793ff9]::boxed::Box<rustc_driver_impl[c8796dbdb0a790d0]::install_ice_hook::{closure#1}>>::{closure#0}
   7:     0x7f6eca169e03 - std::panicking::rust_panic_with_hook::h1a38b2651d61b684
   8:     0x7f6ec91d1281 - std[23b1014898398f3a]::panicking::begin_panic::<rustc_errors[84d6361680d21c4f]::ExplicitBug>::{closure#0}
   9:     0x7f6ec91c5156 - std[23b1014898398f3a]::sys::backtrace::__rust_end_short_backtrace::<std[23b1014898398f3a]::panicking::begin_panic<rustc_errors[84d6361680d21c4f]::ExplicitBug>::{closure#0}, !>
  10:     0x7f6ec91c513b - std[23b1014898398f3a]::panicking::begin_panic::<rustc_errors[84d6361680d21c4f]::ExplicitBug>
  11:     0x7f6ec91db9f1 - <rustc_errors[84d6361680d21c4f]::diagnostic::BugAbort as rustc_errors[84d6361680d21c4f]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  12:     0x7f6ec984a14a - rustc_middle[3cba1f9493d37f78]::util::bug::opt_span_bug_fmt::<rustc_span[10508ddd74bd9d4e]::span_encoding::Span>::{closure#0}
  13:     0x7f6ec982394a - rustc_middle[3cba1f9493d37f78]::ty::context::tls::with_opt::<rustc_middle[3cba1f9493d37f78]::util::bug::opt_span_bug_fmt<rustc_span[10508ddd74bd9d4e]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  14:     0x7f6ec98237bb - rustc_middle[3cba1f9493d37f78]::ty::context::tls::with_context_opt::<rustc_middle[3cba1f9493d37f78]::ty::context::tls::with_opt<rustc_middle[3cba1f9493d37f78]::util::bug::opt_span_bug_fmt<rustc_span[10508ddd74bd9d4e]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  15:     0x7f6ec6a87ff0 - rustc_middle[3cba1f9493d37f78]::util::bug::bug_fmt
  16:     0x7f6eca99b058 - <rustc_trait_selection[c3f3da74ab5cc5d9]::traits::select::SelectionContext>::confirm_candidate
  17:     0x7f6ecb2cc36f - <rustc_trait_selection[c3f3da74ab5cc5d9]::traits::fulfill::FulfillProcessor as rustc_data_structures[766a8a49e9a623b6]::obligation_forest::ObligationProcessor>::process_obligation
  18:     0x7f6eca807fd5 - <rustc_data_structures[766a8a49e9a623b6]::obligation_forest::ObligationForest<rustc_trait_selection[c3f3da74ab5cc5d9]::traits::fulfill::PendingPredicateObligation>>::process_obligations::<rustc_trait_selection[c3f3da74ab5cc5d9]::traits::fulfill::FulfillProcessor>
  19:     0x7f6ecafd43ab - <rustc_trait_selection[c3f3da74ab5cc5d9]::traits::fulfill::FulfillmentContext<rustc_trait_selection[c3f3da74ab5cc5d9]::traits::FulfillmentError> as rustc_infer[7388de4d28332a4e]::traits::engine::TraitEngine<rustc_trait_selection[c3f3da74ab5cc5d9]::traits::FulfillmentError>>::select_all_or_error
  20:     0x7f6ecb05fea8 - rustc_hir_analysis[2ff1991ffb30aa1a]::check::wfcheck::check_well_formed
  21:     0x7f6ecb05e90b - rustc_query_impl[efffa611636c8e5b]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[efffa611636c8e5b]::query_impl::check_well_formed::dynamic_query::{closure#2}::{closure#0}, rustc_middle[3cba1f9493d37f78]::query::erase::Erased<[u8; 1usize]>>
  22:     0x7f6ecb05e1b1 - rustc_query_system[194713339954f907]::query::plumbing::try_execute_query::<rustc_query_impl[efffa611636c8e5b]::DynamicConfig<rustc_data_structures[766a8a49e9a623b6]::vec_cache::VecCache<rustc_span[10508ddd74bd9d4e]::def_id::LocalDefId, rustc_middle[3cba1f9493d37f78]::query::erase::Erased<[u8; 1usize]>, rustc_query_system[194713339954f907]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[efffa611636c8e5b]::plumbing::QueryCtxt, false>
  23:     0x7f6ecb05dca6 - rustc_query_impl[efffa611636c8e5b]::query_impl::check_well_formed::get_query_non_incr::__rust_end_short_backtrace
  24:     0x7f6ecb05b225 - rustc_hir_analysis[2ff1991ffb30aa1a]::check::wfcheck::check_mod_type_wf
  25:     0x7f6ecb05b01f - rustc_query_impl[efffa611636c8e5b]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[efffa611636c8e5b]::query_impl::check_mod_type_wf::dynamic_query::{closure#2}::{closure#0}, rustc_middle[3cba1f9493d37f78]::query::erase::Erased<[u8; 1usize]>>
  26:     0x7f6ecb7fc284 - rustc_query_system[194713339954f907]::query::plumbing::try_execute_query::<rustc_query_impl[efffa611636c8e5b]::DynamicConfig<rustc_query_system[194713339954f907]::query::caches::DefaultCache<rustc_span[10508ddd74bd9d4e]::def_id::LocalModDefId, rustc_middle[3cba1f9493d37f78]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[efffa611636c8e5b]::plumbing::QueryCtxt, false>
  27:     0x7f6ecb7fc011 - rustc_query_impl[efffa611636c8e5b]::query_impl::check_mod_type_wf::get_query_non_incr::__rust_end_short_backtrace
  28:     0x7f6ecaae36ae - rustc_hir_analysis[2ff1991ffb30aa1a]::check_crate
  29:     0x7f6ecac41245 - rustc_interface[88f95fb9e776d181]::passes::run_required_analyses
  30:     0x7f6ecb6f8ade - rustc_interface[88f95fb9e776d181]::passes::analysis
  31:     0x7f6ecb6f8ab5 - rustc_query_impl[efffa611636c8e5b]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[efffa611636c8e5b]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[3cba1f9493d37f78]::query::erase::Erased<[u8; 0usize]>>
  32:     0x7f6ecb6fabba - rustc_query_system[194713339954f907]::query::plumbing::try_execute_query::<rustc_query_impl[efffa611636c8e5b]::DynamicConfig<rustc_query_system[194713339954f907]::query::caches::SingleCache<rustc_middle[3cba1f9493d37f78]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[efffa611636c8e5b]::plumbing::QueryCtxt, false>
  33:     0x7f6ecb6fa88f - rustc_query_impl[efffa611636c8e5b]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  34:     0x7f6ecb926607 - rustc_interface[88f95fb9e776d181]::passes::create_and_enter_global_ctxt::<core[64e60dbc053b37]::option::Option<rustc_interface[88f95fb9e776d181]::queries::Linker>, rustc_driver_impl[c8796dbdb0a790d0]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
  35:     0x7f6ecb879ba6 - rustc_interface[88f95fb9e776d181]::interface::run_compiler::<(), rustc_driver_impl[c8796dbdb0a790d0]::run_compiler::{closure#0}>::{closure#1}
  36:     0x7f6ecb8528be - std[23b1014898398f3a]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[88f95fb9e776d181]::util::run_in_thread_with_globals<rustc_interface[88f95fb9e776d181]::util::run_in_thread_pool_with_globals<rustc_interface[88f95fb9e776d181]::interface::run_compiler<(), rustc_driver_impl[c8796dbdb0a790d0]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  37:     0x7f6ecb852d2b - <<std[23b1014898398f3a]::thread::Builder>::spawn_unchecked_<rustc_interface[88f95fb9e776d181]::util::run_in_thread_with_globals<rustc_interface[88f95fb9e776d181]::util::run_in_thread_pool_with_globals<rustc_interface[88f95fb9e776d181]::interface::run_compiler<(), rustc_driver_impl[c8796dbdb0a790d0]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[64e60dbc053b37]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  38:     0x7f6ecb85412b - std::sys::pal::unix::thread::Thread::new::thread_start::ha2537cf437130d92
  39:     0x7f6ec56a370a - <unknown>
  40:     0x7f6ec5727aac - <unknown>
  41:                0x0 - <unknown>

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: please attach the file at `/home/matthias/vcs/github/CRED/rustc-ice-2025-05-17T12_23_23-1960773.txt` to your bug report

query stack during panic:
#0 [check_well_formed] checking that `<impl at code.rs:12:1: 12:23>` is well-formed
#1 [check_mod_type_wf] checking that types are well-formed in top-level module
... and 1 other queries... use `env RUST_BACKTRACE=1` to see the full query stack
error: aborting due to 2 previous errors; 5 warnings emitted

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

Activity

  1. added
    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.
    C-bugCategory: This is a bug.
    on May 17, 2025
  2. added
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on May 17, 2025
  3. moxian commented on May 17, 2025

    @moxian
    Contributor

    not smaller, but with more conventional item names and fewer warnings:

    struct S;
    trait SimpleTrait {}
    trait TraitAssoc {
        type Assoc;
    }
    
    impl<T> TraitAssoc for T
    where
        T: SimpleTrait,
    {
        type Assoc = <(T,) as TraitAssoc>::Assoc;
    }
    impl SimpleTrait for <S as TraitAssoc>::Assoc {}
    
    pub fn main() {}
    Bisection
    Regression in nightly-2024-02-23. PRs in range:
     - #117658 (rename ptr::invalid -> ptr::without_provenance) by RalfJung
     - #121415 (Rollup of 8 pull requests) by matthiaskrgr
       - #121206 (Top level error handling)
       - #121261 (coverage: Remove `pending_dups` from the span refiner)
       - #121336 (triagebot: add queue notifications)
       - #121373 (Consistently refer to a test's `revision` instead of `cfg`)
       - #121391 (never patterns: Fix liveness analysis in the presence of never patterns)
       - #121392 (Unify dylib loading between proc macros and codegen backends)
       - #121399 (Solaris linker does not support --strip-debug)
       - #121406 (Add a couple tests)
     - #118634 (Remove useless `'static` bounds on `Box` allocator) by Jules-Bertholet
     - #121223 (intrinsics::simd: add missing functions, avoid UB-triggering fast-math) by RalfJung
     - #117174 (Improve UEFI stdio) by Ayush1325
     - #121129 (Improve codegen diagnostic handling) by nnethercote
     - #121225 (require simd_insert, simd_extract indices to be constants) by RalfJung
     - #121309 (Make intrinsic fallback bodies cross-crate inlineable) by Nilstrieb
     - #121372 (Make `x test tests` work) by clubby789
     - #121370 (Migrate compiletest to use `ui_test`-style `//@` directives) by jieyouxu
     - #121469 (Rollup of 8 pull requests) by matthiaskrgr
       - #120598 (No need to `validate_alias_bound_self_from_param_env` in `assemble_alias_bound_candidates`)
       - #121386 (test that we do not support higher-ranked regions in opaque type inference)
       - #121393 (match lowering: Introduce a `TestCase` enum to replace most matching on `PatKind`)
       - #121401 (Fix typo in serialized.rs)
       - #121427 (Fix panic when compiling `Rocket`.)
       - #121439 (Fix typo in metadata.rs doc comment)
       - #121441 (`DefId`  to `LocalDefId`)
       - #121452 (Add new maintainers to nto-qnx.md)
     - #119989 (remove `sub_relations` from the `InferCtxt`) by lcnr

    Sounds like #119989 ?.. (or maybe #120598 / #121386 ?..)

    Interestingly (academically speaking), this used to ICE even before that, and got fixed once in nightly-2022-03-31. Seemingly accidentally, by #94081

    PRs in nightly-2022-03-31:
     - #95448 (Rollup of 4 pull requests) by Dylan-DPC
       - #93840 (Stabilize Termination and ExitCode)
       - #95256 (Ensure io::Error's bitpacked repr doesn't accidentally impl UnwindSafe)
       - #95386 (Suggest wrapping patterns in enum variants)
       - #95437 (diagnostics: regression test for derive bounds)
     - #95455 (update miri) by RalfJung
     - #94081 (Lazy type-alias-impl-trait take two) by oli-obk
     - #95466 (Rollup of 5 pull requests) by Dylan-DPC
       - #95294 (Document Linux kernel handoff in std::io::copy and std::fs::copy)
       - #95443 (Clarify how `src/tools/x` searches for python)
       - #95452 (fix since field version for termination stabilization)
       - #95460 (Spellchecking compiler code)
       - #95461 (Spellchecking some comments)
     - #95241 (Strict Provenance MVP) by Gankra
     - #94963 (allow arbitrary inherent impls for builtin types in core) by lcnr
     - #95458 (Sync rustfmt subtree) by calebcartwright
     - #95425 (Yet more `parse_tt` improvements) by nnethercote

    doesn't ICE with -Znext-solver

    @rustbot label: +S-has-mcve +S-has-bisection +T-types +A-trait-system +A-associated-items -T-compiler

  4. added
    A-associated-itemsArea: Associated items (types, constants & functions)
    S-has-bisectionStatus: A bisection has been found for this issue
    S-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issue
    T-typesRelevant to the types team, which will review and decide on the PR/issue.
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    and removed
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    on May 17, 2025
  5. added
    S-bug-has-testStatus: This bug is tracked inside the repo by a `known-bug` test.
    on May 20, 2025
  6. removed
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Jun 8, 2025
  7. added
    fixed-by-next-solverFixed by the next-generation trait solver, `-Znext-solver`.
    on Aug 11, 2026
  8. added a commit that references this issue on Oct 4, 2026
  9. added a commit that references this issue on Oct 4, 2026
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-associated-itemsArea: Associated items (types, constants & functions)A-trait-systemArea: Trait systemC-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️S-bug-has-testStatus: This bug is tracked inside the repo by a `known-bug` test.S-has-bisectionStatus: A bisection has been found for this issueS-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issueT-typesRelevant to the types team, which will review and decide on the PR/issue.fixed-by-next-solverFixed by the next-generation trait solver, `-Znext-solver`.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions