Skip to content

[ICE]: assumptions on binders: failed to resolve instance for <dyn Derived<()> as Derived<()>>::is_derived #157729

Description

@matthiaskrgr

Code

//@compile-flags: -Zassumptions-on-binders -Znext-solver=globally
// Regression test for #77653
// When monomorphizing `f` we need to prove `dyn Derived<()>: Base<()>`. This
// requires us to normalize the `Base<<() as Proj>::S>` to `Base<()>` when
// comparing the supertrait `Derived<()>` to the expected trait.

//@ build-pass
//@ revisions: current next
//@ ignore-compare-mode-next-solver (explicit revisions)
//@[next] compile-flags: -Znext-solver

trait Proj {
    type S;
}

impl Proj for () {
    type S = ();
}

impl Proj for i32 {
    type S = i32;
}

trait Base<T> {
    fn is_base(&self);
}

trait Derived<B: Proj>: Base<B::S> + Base<()> {
    fn is_derived(&self);
}

fn f<P: Proj>(obj: &dyn Derived<P>) {
    obj.is_derived();
    Base::<P::S>::is_base(obj);
    Base::<()>::is_base(obj);
}

fn main() {
    let x: fn(_) = f::<()>;
    let x: fn(_) = f::<i32>;
}

Meta

rustc --version --verbose:

rustc 1.98.0-nightly (beae78130 2026-06-09)
binary: rustc
commit-hash: beae781308e9ddef13074a03faf57ca2fac59a5b
commit-date: 2026-06-09
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6

Error output

<output>
Backtrace

error: internal compiler error: /rustc-dev/beae781308e9ddef13074a03faf57ca2fac59a5b/compiler/rustc_middle/src/ty/instance.rs:569:21: failed to resolve instance for <dyn Derived<()> as Derived<()>>::is_derived
  --> a.rs:32:5
   |
32 |     obj.is_derived();
   |     ^^^^^^^^^^^^^^^^


thread 'rustc' (1430124) panicked at /rustc-dev/beae781308e9ddef13074a03faf57ca2fac59a5b/compiler/rustc_middle/src/ty/instance.rs:569:21:
Box<dyn Any>
stack backtrace:
   0:     0x7fd0880a0dd9 - <<std[210f122337a7df4c]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[56696922243b1362]::fmt::Display>::fmt
   1:     0x7fd088817988 - core[56696922243b1362]::fmt::write
   2:     0x7fd0880b6e66 - <std[210f122337a7df4c]::sys::stdio::unix::Stderr as std[210f122337a7df4c]::io::Write>::write_fmt
   3:     0x7fd08807656e - std[210f122337a7df4c]::panicking::default_hook::{closure#0}
   4:     0x7fd088093d33 - std[210f122337a7df4c]::panicking::default_hook
   5:     0x7fd086e840d1 - std[210f122337a7df4c]::panicking::update_hook::<alloc[87f39702ba754b16]::boxed::Box<rustc_driver_impl[17e5fc0182803539]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x7fd088094012 - std[210f122337a7df4c]::panicking::panic_with_hook
   7:     0x7fd086eb1d41 - std[210f122337a7df4c]::panicking::begin_panic::<rustc_errors[c58c3e91abb3cebc]::ExplicitBug>::{closure#0}
   8:     0x7fd086eaaab6 - std[210f122337a7df4c]::sys::backtrace::__rust_end_short_backtrace::<std[210f122337a7df4c]::panicking::begin_panic<rustc_errors[c58c3e91abb3cebc]::ExplicitBug>::{closure#0}, !>
   9:     0x7fd086ea8a47 - std[210f122337a7df4c]::panicking::begin_panic::<rustc_errors[c58c3e91abb3cebc]::ExplicitBug>
  10:     0x7fd086ebcd71 - <rustc_errors[c58c3e91abb3cebc]::diagnostic::BugAbort as rustc_errors[c58c3e91abb3cebc]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  11:     0x7fd0875245ec - <rustc_errors[c58c3e91abb3cebc]::DiagCtxtHandle>::span_bug::<rustc_span[1164d50c362b2714]::span_encoding::Span, alloc[87f39702ba754b16]::string::String>
  12:     0x7fd08754fa66 - rustc_middle[f785d3947f0fb584]::util::bug::opt_span_bug_fmt::<rustc_span[1164d50c362b2714]::span_encoding::Span>::{closure#0}
  13:     0x7fd08754fbf2 - rustc_middle[f785d3947f0fb584]::ty::context::tls::with_opt::<rustc_middle[f785d3947f0fb584]::util::bug::opt_span_bug_fmt<rustc_span[1164d50c362b2714]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  14:     0x7fd08753e77b - rustc_middle[f785d3947f0fb584]::ty::context::tls::with_context_opt::<rustc_middle[f785d3947f0fb584]::ty::context::tls::with_opt<rustc_middle[f785d3947f0fb584]::util::bug::opt_span_bug_fmt<rustc_span[1164d50c362b2714]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  15:     0x7fd084b3f618 - rustc_middle[f785d3947f0fb584]::util::bug::span_bug_fmt::<rustc_span[1164d50c362b2714]::span_encoding::Span>
  16:     0x7fd0897f4748 - <rustc_middle[f785d3947f0fb584]::ty::instance::Instance>::expect_resolve
  17:     0x7fd0892bd669 - <rustc_monomorphize[ccd7379517a8b282]::collector::MirUsedCollector as rustc_middle[f785d3947f0fb584]::mir::visit::Visitor>::visit_terminator
  18:     0x7fd0892b6a03 - rustc_monomorphize[ccd7379517a8b282]::collector::items_of_instance
  19:     0x7fd0892b6411 - rustc_query_impl[6a84ebe04ccf7fcc]::query_impl::items_of_instance::invoke_provider_fn::__rust_begin_short_backtrace
  20:     0x7fd0892b30ae - rustc_query_impl[6a84ebe04ccf7fcc]::execution::try_execute_query::<rustc_middle[f785d3947f0fb584]::query::caches::DefaultCache<(rustc_middle[f785d3947f0fb584]::ty::instance::Instance, rustc_middle[f785d3947f0fb584]::mono::CollectionMode), rustc_middle[f785d3947f0fb584]::query::erase::ErasedData<[u8; 32usize]>>, false>
  21:     0x7fd0892b2d17 - rustc_query_impl[6a84ebe04ccf7fcc]::query_impl::items_of_instance::execute_query_non_incr::__rust_end_short_backtrace
  22:     0x7fd0897276f1 - rustc_monomorphize[ccd7379517a8b282]::collector::collect_items_rec
  23:     0x7fd0897294f7 - rustc_monomorphize[ccd7379517a8b282]::collector::collect_items_rec
  24:     0x7fd08971f13f - rustc_monomorphize[ccd7379517a8b282]::collector::collect_crate_mono_items::{closure#1}::{closure#0}
  25:     0x7fd08971fdf7 - rustc_monomorphize[ccd7379517a8b282]::partitioning::collect_and_partition_mono_items
  26:     0x7fd08971faaa - rustc_query_impl[6a84ebe04ccf7fcc]::query_impl::collect_and_partition_mono_items::invoke_provider_fn::__rust_begin_short_backtrace
  27:     0x7fd0899d27ae - rustc_query_impl[6a84ebe04ccf7fcc]::execution::try_execute_query::<rustc_middle[f785d3947f0fb584]::query::caches::SingleCache<rustc_middle[f785d3947f0fb584]::query::erase::ErasedData<[u8; 24usize]>>, false>
  28:     0x7fd0899d2544 - rustc_query_impl[6a84ebe04ccf7fcc]::query_impl::collect_and_partition_mono_items::execute_query_non_incr::__rust_end_short_backtrace
  29:     0x7fd089a9eef2 - rustc_codegen_ssa[b5faf784774b9c59]::base::codegen_crate::<rustc_codegen_llvm[d170d6b482ddc43e]::LlvmCodegenBackend, rustc_codegen_llvm[d170d6b482ddc43e]::ModuleLlvm>
  30:     0x7fd089a9ec0d - <rustc_codegen_llvm[d170d6b482ddc43e]::LlvmCodegenBackend as rustc_codegen_ssa[b5faf784774b9c59]::traits::backend::CodegenBackend>::codegen_crate
  31:     0x7fd089987b5c - <rustc_interface[fcb53972e547428a]::queries::Linker>::codegen_and_build_linker
  32:     0x7fd0899821da - rustc_interface[fcb53972e547428a]::interface::run_compiler::<(), rustc_driver_impl[17e5fc0182803539]::run_compiler::{closure#0}>::{closure#1}
  33:     0x7fd089a0547a - std[210f122337a7df4c]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[fcb53972e547428a]::util::run_in_thread_with_globals<rustc_interface[fcb53972e547428a]::util::run_in_thread_pool_with_globals<rustc_interface[fcb53972e547428a]::interface::run_compiler<(), rustc_driver_impl[17e5fc0182803539]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  34:     0x7fd089a0522d - <std[210f122337a7df4c]::thread::lifecycle::spawn_unchecked<rustc_interface[fcb53972e547428a]::util::run_in_thread_with_globals<rustc_interface[fcb53972e547428a]::util::run_in_thread_pool_with_globals<rustc_interface[fcb53972e547428a]::interface::run_compiler<(), rustc_driver_impl[17e5fc0182803539]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[56696922243b1362]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  35:     0x7fd08975ec92 - <std[210f122337a7df4c]::sys::thread::unix::Thread>::new::thread_start
  36:     0x7fd082e981b9 - <unknown>
  37:     0x7fd082f1d21c - <unknown>
  38:                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 `/tmp/assumptions/rustc-ice-2026-06-10T20_20_57-1430114.txt` to your bug report

note: rustc 1.98.0-nightly (beae78130 2026-06-09) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z assumptions-on-binders -Z next-solver=globally

query stack during panic:
#0 [items_of_instance] collecting items used by `f::<()>`
#1 [collect_and_partition_mono_items] collect_and_partition_mono_items
end of query stack
error: aborting due to 1 previous error; 2 warnings emitted

Metadata

Metadata

Assignees

No one assigned

    Labels

    -Zassumptions-on-bindersUnstable option: `-Zassumptions-on-bindersC-bugCategory: This is a bug.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.WG-trait-system-refactorThe Rustc Trait System Refactor Initiative (-Znext-solver)needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions