Skip to content

ICE on #[const_trait] with where clause #143944

@Jules-Bertholet

Description

@Jules-Bertholet

Code

#![feature(const_trait_impl)]

#[const_trait]
trait Foo
where
    Self::Assoc: Clone,
{
    type Assoc;
}

Meta

rustc --version --verbose:

rustc 1.90.0-nightly (e9182f195 2025-07-13)
binary: rustc
commit-hash: e9182f195b8505c87c4bd055b9f6e114ccda0981
commit-date: 2025-07-13
host: x86_64-unknown-linux-gnu
release: 1.90.0-nightly
LLVM version: 20.1.7

Error output

error: internal compiler error: compiler/rustc_hir_analysis/src/collect/predicates_of.rs:1142:26: converted TraitPredicate(<<Self as Foo>::Assoc as std::clone::Clone>, polarity:Positive)
Backtrace

thread 'rustc' panicked at compiler/rustc_hir_analysis/src/collect/predicates_of.rs:1142:26:
Box<dyn Any>
stack backtrace:
   0:     0x7f39559a0565 - std::backtrace::Backtrace::create::h94eb50fdd3a6a273
   1:     0x7f39559a04b5 - std::backtrace::Backtrace::force_capture::h0feae89e5ff07d60
   2:     0x7f3954a580be - std[466a06c814bbffcc]::panicking::update_hook::<alloc[7a8a4df61ffbab14]::boxed::Box<rustc_driver_impl[e17e027cba32f02b]::install_ice_hook::{closure#1}>>::{closure#0}
   3:     0x7f39559ba54e - std::panicking::rust_panic_with_hook::h0c63431ef8028367
   4:     0x7f3954a91511 - std[466a06c814bbffcc]::panicking::begin_panic::<rustc_errors[c165c9bbf98cfeda]::ExplicitBug>::{closure#0}
   5:     0x7f3954a864a6 - std[466a06c814bbffcc]::sys::backtrace::__rust_end_short_backtrace::<std[466a06c814bbffcc]::panicking::begin_panic<rustc_errors[c165c9bbf98cfeda]::ExplicitBug>::{closure#0}, !>
   6:     0x7f3954a82ca9 - std[466a06c814bbffcc]::panicking::begin_panic::<rustc_errors[c165c9bbf98cfeda]::ExplicitBug>
   7:     0x7f3954a9aff1 - <rustc_errors[c165c9bbf98cfeda]::diagnostic::BugAbort as rustc_errors[c165c9bbf98cfeda]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
   8:     0x7f395509421a - rustc_middle[a658f3bf2df6b231]::util::bug::opt_span_bug_fmt::<rustc_span[ffed115297ce1f48]::span_encoding::Span>::{closure#0}
   9:     0x7f395507416a - rustc_middle[a658f3bf2df6b231]::ty::context::tls::with_opt::<rustc_middle[a658f3bf2df6b231]::util::bug::opt_span_bug_fmt<rustc_span[ffed115297ce1f48]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  10:     0x7f3955073fdb - rustc_middle[a658f3bf2df6b231]::ty::context::tls::with_context_opt::<rustc_middle[a658f3bf2df6b231]::ty::context::tls::with_opt<rustc_middle[a658f3bf2df6b231]::util::bug::opt_span_bug_fmt<rustc_span[ffed115297ce1f48]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  11:     0x7f39526490a0 - rustc_middle[a658f3bf2df6b231]::util::bug::bug_fmt
  12:     0x7f3954c1a87e - rustc_hir_analysis[d3f6ff1863cf1c5]::collect::predicates_of::explicit_implied_const_bounds
  13:     0x7f3958174afc - rustc_query_impl[fe8bd91f7c525aae]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[fe8bd91f7c525aae]::query_impl::explicit_implied_const_bounds::dynamic_query::{closure#2}::{closure#0}, rustc_middle[a658f3bf2df6b231]::query::erase::Erased<[u8; 16usize]>>.cold
  14:     0x7f39572f6931 - <rustc_query_impl[fe8bd91f7c525aae]::query_impl::explicit_implied_const_bounds::dynamic_query::{closure#2} as core[9c06681427b239fc]::ops::function::FnOnce<(rustc_middle[a658f3bf2df6b231]::ty::context::TyCtxt, rustc_span[ffed115297ce1f48]::def_id::DefId)>>::call_once
  15:     0x7f3956c041c6 - rustc_query_system[61b9b72cff5aabdf]::query::plumbing::try_execute_query::<rustc_query_impl[fe8bd91f7c525aae]::DynamicConfig<rustc_query_system[61b9b72cff5aabdf]::query::caches::DefIdCache<rustc_middle[a658f3bf2df6b231]::query::erase::Erased<[u8; 16usize]>>, false, false, false>, rustc_query_impl[fe8bd91f7c525aae]::plumbing::QueryCtxt, true>
  16:     0x7f395737fe4c - rustc_query_impl[fe8bd91f7c525aae]::query_impl::explicit_implied_const_bounds::get_query_incr::__rust_end_short_backtrace
  17:     0x7f3956bfdcb3 - <rustc_metadata[4facfa3844d9e3d8]::rmeta::encoder::EncodeContext>::encode_def_ids
  18:     0x7f3956c180fb - <rustc_metadata[4facfa3844d9e3d8]::rmeta::encoder::EncodeContext>::encode_crate_root
  19:     0x7f39576a08f0 - <rustc_metadata[4facfa3844d9e3d8]::rmeta::encoder::encode_metadata::{closure#3} as core[9c06681427b239fc]::ops::function::FnOnce<(rustc_middle[a658f3bf2df6b231]::ty::context::TyCtxt, &std[466a06c814bbffcc]::path::Path)>>::call_once
  20:     0x7f395769fa92 - <rustc_middle[a658f3bf2df6b231]::dep_graph::DepsType as rustc_query_system[61b9b72cff5aabdf]::dep_graph::Deps>::with_deps::<<rustc_query_system[61b9b72cff5aabdf]::dep_graph::graph::DepGraphData<rustc_middle[a658f3bf2df6b231]::dep_graph::DepsType>>::with_task<rustc_middle[a658f3bf2df6b231]::ty::context::TyCtxt, &std[466a06c814bbffcc]::path::Path, ()>::{closure#1}::{closure#0}, ()>
  21:     0x7f395769def6 - rustc_metadata[4facfa3844d9e3d8]::rmeta::encoder::encode_metadata
  22:     0x7f3957187318 - rustc_metadata[4facfa3844d9e3d8]::fs::encode_and_write_metadata
  23:     0x7f39575188ca - <rustc_interface[50980e854deb1df]::queries::Linker>::codegen_and_build_linker
  24:     0x7f3957516407 - rustc_interface[50980e854deb1df]::passes::create_and_enter_global_ctxt::<core[9c06681427b239fc]::option::Option<rustc_interface[50980e854deb1df]::queries::Linker>, rustc_driver_impl[e17e027cba32f02b]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
  25:     0x7f39574d8257 - rustc_interface[50980e854deb1df]::interface::run_compiler::<(), rustc_driver_impl[e17e027cba32f02b]::run_compiler::{closure#0}>::{closure#1}
  26:     0x7f39573a2a38 - std[466a06c814bbffcc]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[50980e854deb1df]::util::run_in_thread_with_globals<rustc_interface[50980e854deb1df]::util::run_in_thread_pool_with_globals<rustc_interface[50980e854deb1df]::interface::run_compiler<(), rustc_driver_impl[e17e027cba32f02b]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  27:     0x7f39573a2716 - <<std[466a06c814bbffcc]::thread::Builder>::spawn_unchecked_<rustc_interface[50980e854deb1df]::util::run_in_thread_with_globals<rustc_interface[50980e854deb1df]::util::run_in_thread_pool_with_globals<rustc_interface[50980e854deb1df]::interface::run_compiler<(), rustc_driver_impl[e17e027cba32f02b]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[9c06681427b239fc]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  28:     0x7f39573a85fd - std::sys::pal::unix::thread::Thread::new::thread_start::h0ff23f3bbce37c27
  29:     0x7f3950c4d1d4 - start_thread
                               at /usr/src/debug/glibc-2.41-8.fc42.x86_64/nptl/pthread_create.c:448:8
  30:     0x7f3950ccfcec - __GI___clone3
                               at /usr/src/debug/glibc-2.41-8.fc42.x86_64/misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:78:0
  31:                0x0 - <unknown>


rustc version: 1.90.0-nightly (e9182f195 2025-07-13)
platform: x86_64-unknown-linux-gnu

query stack during panic:
#0 [explicit_implied_const_bounds] computing the implied `[const]` bounds for `Foo::Assoc`
end of query stack

@rustbot label F-const_trait_impl

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.F-const_trait_impl`#![feature(const_trait_impl)]`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