Skip to content

ICE should not select host obligation in old solver in intercrate mode #149703

@matthiaskrgr

Description

@matthiaskrgr

auto-reduced (treereduce-rust):

trait X {}

trait Z {
    type Assoc: Y;
}
struct A<T>(T);

impl<T: const FnOnce(()) -> i32> Z for A<T> {}

impl<T> From<<A<A<T>> as Z>::Assoc> for T {}

original:

trait X {}

trait Z {
    type Assoc: Y;
}
struct A<T>(T);

impl<T: const FnOnce(()) -> i32> Z for A<T> {
    type Assoc = T;
}

impl<T> From<<A<A<T>> as Z>::Assoc> for T {}

Version information

rustc 1.93.0-nightly (66428d92b 2025-12-05)
binary: rustc
commit-hash: 66428d92bec337ed4785d695d0127276a482278c
commit-date: 2025-12-05
host: x86_64-unknown-linux-gnu
release: 1.93.0-nightly
LLVM version: 21.1.5

Possibly related line of code:

pub fn evaluate_host_effect_obligation<'tcx>(
selcx: &mut SelectionContext<'_, 'tcx>,
obligation: &HostEffectObligation<'tcx>,
) -> Result<ThinVec<PredicateObligation<'tcx>>, EvaluationFailure> {
if matches!(selcx.infcx.typing_mode(), TypingMode::Coherence) {
span_bug!(
obligation.cause.span,
"should not select host obligation in old solver in intercrate mode"
);
}
let ref obligation = selcx.infcx.resolve_vars_if_possible(obligation.clone());

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

Program output

error[E0405]: cannot find trait `Y` in this scope
 --> /tmp/icemaker_global_tempdir.bAeSV9EYs3Nh/rustc_testrunner_tmpdir_reporting.9b7fonKIt25S/mvce.rs:4:17
  |
1 | trait X {}
  | ------- similarly named trait `X` defined here
...
4 |     type Assoc: Y;
  |                 ^ help: a trait with a similar name exists: `X`

error[E0658]: const trait impls are experimental
 --> /tmp/icemaker_global_tempdir.bAeSV9EYs3Nh/rustc_testrunner_tmpdir_reporting.9b7fonKIt25S/mvce.rs:8:9
  |
8 | impl<T: const FnOnce(()) -> i32> Z for A<T> {}
  |         ^^^^^
  |
  = note: see issue #143874 <https://github.com/rust-lang/rust/issues/143874> for more information
  = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable
  = note: this compiler was built on 2025-12-05; consider upgrading it if it is out of date

error[E0601]: `main` function not found in crate `mvce`
  --> /tmp/icemaker_global_tempdir.bAeSV9EYs3Nh/rustc_testrunner_tmpdir_reporting.9b7fonKIt25S/mvce.rs:10:45
   |
10 | impl<T> From<<A<A<T>> as Z>::Assoc> for T {}
   |                                             ^ consider adding a `main` function to `/tmp/icemaker_global_tempdir.bAeSV9EYs3Nh/rustc_testrunner_tmpdir_reporting.9b7fonKIt25S/mvce.rs`

error[E0658]: use of unstable const library feature `const_trait_impl`
 --> /tmp/icemaker_global_tempdir.bAeSV9EYs3Nh/rustc_testrunner_tmpdir_reporting.9b7fonKIt25S/mvce.rs:8:15
  |
8 | impl<T: const FnOnce(()) -> i32> Z for A<T> {}
  |         ----- ^^^^^^^^^^^^^^^^^
  |         |
  |         trait is not stable as const yet
  |
  = note: see issue #143874 <https://github.com/rust-lang/rust/issues/143874> for more information
  = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable
  = note: this compiler was built on 2025-12-05; consider upgrading it if it is out of date

error[E0046]: not all trait items implemented, missing: `Assoc`
 --> /tmp/icemaker_global_tempdir.bAeSV9EYs3Nh/rustc_testrunner_tmpdir_reporting.9b7fonKIt25S/mvce.rs:8:1
  |
4 |     type Assoc: Y;
  |     ------------- `Assoc` from trait
...
8 | impl<T: const FnOnce(()) -> i32> Z for A<T> {}
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `Assoc` in implementation

error: internal compiler error: compiler/rustc_trait_selection/src/traits/effects.rs:29:9: should not select host obligation in old solver in intercrate mode


thread 'rustc' (1929049) panicked at compiler/rustc_trait_selection/src/traits/effects.rs:29:9:
Box<dyn Any>
stack backtrace:
   0:     0x7f566e26f6b3 - <<std[d1cf8494b7637499]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[7a5baad27c58ac9b]::fmt::Display>::fmt
   1:     0x7f566e811848 - core[7a5baad27c58ac9b]::fmt::write
   2:     0x7f566e285ed6 - <std[d1cf8494b7637499]::sys::stdio::unix::Stderr as std[d1cf8494b7637499]::io::Write>::write_fmt
   3:     0x7f566e245e78 - std[d1cf8494b7637499]::panicking::default_hook::{closure#0}
   4:     0x7f566e263583 - std[d1cf8494b7637499]::panicking::default_hook
   5:     0x7f566d2cfec7 - std[d1cf8494b7637499]::panicking::update_hook::<alloc[fc8570482610e41]::boxed::Box<rustc_driver_impl[9b4b378bd639d3bd]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x7f566e263862 - std[d1cf8494b7637499]::panicking::panic_with_hook
   7:     0x7f566d30bf41 - std[d1cf8494b7637499]::panicking::begin_panic::<rustc_errors[888950e5e47c8ba6]::ExplicitBug>::{closure#0}
   8:     0x7f566d2fc596 - std[d1cf8494b7637499]::sys::backtrace::__rust_end_short_backtrace::<std[d1cf8494b7637499]::panicking::begin_panic<rustc_errors[888950e5e47c8ba6]::ExplicitBug>::{closure#0}, !>
   9:     0x7f566d2fc1cf - std[d1cf8494b7637499]::panicking::begin_panic::<rustc_errors[888950e5e47c8ba6]::ExplicitBug>
  10:     0x7f566d329641 - <rustc_errors[888950e5e47c8ba6]::diagnostic::BugAbort as rustc_errors[888950e5e47c8ba6]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  11:     0x7f566d86a94c - <rustc_errors[888950e5e47c8ba6]::DiagCtxtHandle>::span_bug::<rustc_span[a0d314e698c4c838]::span_encoding::Span, alloc[fc8570482610e41]::string::String>
  12:     0x7f566d88b936 - rustc_middle[35056dba64335523]::util::bug::opt_span_bug_fmt::<rustc_span[a0d314e698c4c838]::span_encoding::Span>::{closure#0}
  13:     0x7f566d88bae2 - rustc_middle[35056dba64335523]::ty::context::tls::with_opt::<rustc_middle[35056dba64335523]::util::bug::opt_span_bug_fmt<rustc_span[a0d314e698c4c838]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  14:     0x7f566d87cdbb - rustc_middle[35056dba64335523]::ty::context::tls::with_context_opt::<rustc_middle[35056dba64335523]::ty::context::tls::with_opt<rustc_middle[35056dba64335523]::util::bug::opt_span_bug_fmt<rustc_span[a0d314e698c4c838]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  15:     0x7f566be0c638 - rustc_middle[35056dba64335523]::util::bug::span_bug_fmt::<rustc_span[a0d314e698c4c838]::span_encoding::Span>
  16:     0x7f566ed9b7ee - rustc_trait_selection[bfbaae654e06ec63]::traits::effects::evaluate_host_effect_obligation
  17:     0x7f566f06e387 - <rustc_trait_selection[bfbaae654e06ec63]::traits::fulfill::FulfillProcessor as rustc_data_structures[adb2697dbf3e0adc]::obligation_forest::ObligationProcessor>::process_obligation
  18:     0x7f566e804764 - <rustc_data_structures[adb2697dbf3e0adc]::obligation_forest::ObligationForest<rustc_trait_selection[bfbaae654e06ec63]::traits::fulfill::PendingPredicateObligation>>::process_obligations::<rustc_trait_selection[bfbaae654e06ec63]::traits::fulfill::FulfillProcessor>
  19:     0x7f566f181aba - <rustc_trait_selection[bfbaae654e06ec63]::traits::fulfill::FulfillmentContext<rustc_infer[4ccc06062613e9a]::traits::engine::ScrubbedTraitError> as rustc_infer[4ccc06062613e9a]::traits::engine::TraitEngine<rustc_infer[4ccc06062613e9a]::traits::engine::ScrubbedTraitError>>::try_evaluate_obligations
  20:     0x7f566ee1f4c1 - <rustc_next_trait_solver[c4031e005c555ac1]::coherence::OrphanChecker<rustc_infer[4ccc06062613e9a]::infer::InferCtxt, rustc_middle[35056dba64335523]::ty::context::TyCtxt, rustc_hir_analysis[c90d90e42cbb1186]::coherence::orphan::orphan_check::{closure#0}::{closure#0}> as rustc_type_ir[45ed6e391ddc621c]::visit::TypeVisitor<rustc_middle[35056dba64335523]::ty::context::TyCtxt>>::visit_ty
  21:     0x7f566d40e33f - <rustc_type_ir[45ed6e391ddc621c]::predicate::TraitRef<rustc_middle[35056dba64335523]::ty::context::TyCtxt> as rustc_type_ir[45ed6e391ddc621c]::visit::TypeVisitable<rustc_middle[35056dba64335523]::ty::context::TyCtxt>>::visit_with::<rustc_next_trait_solver[c4031e005c555ac1]::coherence::OrphanChecker<rustc_infer[4ccc06062613e9a]::infer::InferCtxt, rustc_middle[35056dba64335523]::ty::context::TyCtxt, rustc_hir_analysis[c90d90e42cbb1186]::coherence::orphan::orphan_check::{closure#0}::{closure#0}>>
  22:     0x7f566ee1f101 - rustc_hir_analysis[c90d90e42cbb1186]::coherence::orphan::orphan_check
  23:     0x7f566ee1f727 - rustc_hir_analysis[c90d90e42cbb1186]::coherence::orphan::orphan_check_impl
  24:     0x7f566ee1f60d - rustc_query_impl[ac86e4dc6825f939]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[ac86e4dc6825f939]::query_impl::orphan_check_impl::dynamic_query::{closure#2}::{closure#0}, rustc_middle[35056dba64335523]::query::erase::Erased<[u8; 1usize]>>
  25:     0x7f566ef865ed - rustc_query_system[59d0c891baa5ac40]::query::plumbing::try_execute_query::<rustc_query_impl[ac86e4dc6825f939]::DynamicConfig<rustc_data_structures[adb2697dbf3e0adc]::vec_cache::VecCache<rustc_span[a0d314e698c4c838]::def_id::LocalDefId, rustc_middle[35056dba64335523]::query::erase::Erased<[u8; 1usize]>, rustc_query_system[59d0c891baa5ac40]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[ac86e4dc6825f939]::plumbing::QueryCtxt, false>
  26:     0x7f566ef85f8f - rustc_query_impl[ac86e4dc6825f939]::query_impl::orphan_check_impl::get_query_non_incr::__rust_end_short_backtrace
  27:     0x7f566e952b51 - rustc_hir_analysis[c90d90e42cbb1186]::coherence::coherent_trait
  28:     0x7f566e952695 - rustc_query_impl[ac86e4dc6825f939]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[ac86e4dc6825f939]::query_impl::coherent_trait::dynamic_query::{closure#2}::{closure#0}, rustc_middle[35056dba64335523]::query::erase::Erased<[u8; 1usize]>>
  29:     0x7f566ed77be3 - rustc_query_system[59d0c891baa5ac40]::query::plumbing::try_execute_query::<rustc_query_impl[ac86e4dc6825f939]::DynamicConfig<rustc_query_system[59d0c891baa5ac40]::query::caches::DefIdCache<rustc_middle[35056dba64335523]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[ac86e4dc6825f939]::plumbing::QueryCtxt, false>
  30:     0x7f566ed76ca4 - rustc_query_impl[ac86e4dc6825f939]::query_impl::coherent_trait::get_query_non_incr::__rust_end_short_backtrace
  31:     0x7f566ef8bbd5 - rustc_hir_analysis[c90d90e42cbb1186]::check::check::check_item_type
  32:     0x7f566ef86ff6 - rustc_hir_analysis[c90d90e42cbb1186]::check::wfcheck::check_well_formed
  33:     0x7f566ef86fd7 - rustc_query_impl[ac86e4dc6825f939]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[ac86e4dc6825f939]::query_impl::check_well_formed::dynamic_query::{closure#2}::{closure#0}, rustc_middle[35056dba64335523]::query::erase::Erased<[u8; 1usize]>>
  34:     0x7f566ef8684d - rustc_query_system[59d0c891baa5ac40]::query::plumbing::try_execute_query::<rustc_query_impl[ac86e4dc6825f939]::DynamicConfig<rustc_data_structures[adb2697dbf3e0adc]::vec_cache::VecCache<rustc_span[a0d314e698c4c838]::def_id::LocalDefId, rustc_middle[35056dba64335523]::query::erase::Erased<[u8; 1usize]>, rustc_query_system[59d0c891baa5ac40]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[ac86e4dc6825f939]::plumbing::QueryCtxt, false>
  35:     0x7f566ef86356 - rustc_query_impl[ac86e4dc6825f939]::query_impl::check_well_formed::get_query_non_incr::__rust_end_short_backtrace
  36:     0x7f566ef83af0 - rustc_hir_analysis[c90d90e42cbb1186]::check::wfcheck::check_type_wf
  37:     0x7f566ef839e1 - rustc_query_impl[ac86e4dc6825f939]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[ac86e4dc6825f939]::query_impl::check_type_wf::dynamic_query::{closure#2}::{closure#0}, rustc_middle[35056dba64335523]::query::erase::Erased<[u8; 1usize]>>
  38:     0x7f566f961348 - rustc_query_system[59d0c891baa5ac40]::query::plumbing::try_execute_query::<rustc_query_impl[ac86e4dc6825f939]::DynamicConfig<rustc_query_system[59d0c891baa5ac40]::query::caches::SingleCache<rustc_middle[35056dba64335523]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[ac86e4dc6825f939]::plumbing::QueryCtxt, false>
  39:     0x7f566f96110e - rustc_query_impl[ac86e4dc6825f939]::query_impl::check_type_wf::get_query_non_incr::__rust_end_short_backtrace
  40:     0x7f566f3eb4ba - rustc_hir_analysis[c90d90e42cbb1186]::check_crate
  41:     0x7f566ea96e95 - rustc_interface[a570f551ea6bf79f]::passes::analysis
  42:     0x7f566ea96b5b - rustc_query_impl[ac86e4dc6825f939]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[ac86e4dc6825f939]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[35056dba64335523]::query::erase::Erased<[u8; 0usize]>>
  43:     0x7f566f964388 - rustc_query_system[59d0c891baa5ac40]::query::plumbing::try_execute_query::<rustc_query_impl[ac86e4dc6825f939]::DynamicConfig<rustc_query_system[59d0c891baa5ac40]::query::caches::SingleCache<rustc_middle[35056dba64335523]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[ac86e4dc6825f939]::plumbing::QueryCtxt, false>
  44:     0x7f566f963fbe - rustc_query_impl[ac86e4dc6825f939]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  45:     0x7f566faf6410 - <rustc_interface[a570f551ea6bf79f]::passes::create_and_enter_global_ctxt<core[7a5baad27c58ac9b]::option::Option<rustc_interface[a570f551ea6bf79f]::queries::Linker>, rustc_driver_impl[9b4b378bd639d3bd]::run_compiler::{closure#0}::{closure#2}>::{closure#2} as core[7a5baad27c58ac9b]::ops::function::FnOnce<(&rustc_session[61d9c53fe18acc9a]::session::Session, rustc_middle[35056dba64335523]::ty::context::CurrentGcx, alloc[fc8570482610e41]::sync::Arc<rustc_data_structures[adb2697dbf3e0adc]::jobserver::Proxy>, &std[d1cf8494b7637499]::sync::once_lock::OnceLock<rustc_middle[35056dba64335523]::ty::context::GlobalCtxt>, &rustc_data_structures[adb2697dbf3e0adc]::sync::worker_local::WorkerLocal<rustc_middle[35056dba64335523]::arena::Arena>, &rustc_data_structures[adb2697dbf3e0adc]::sync::worker_local::WorkerLocal<rustc_hir[670b2116001876c4]::Arena>, rustc_driver_impl[9b4b378bd639d3bd]::run_compiler::{closure#0}::{closure#2})>>::call_once::{shim:vtable#0}
  46:     0x7f566f9b8c85 - rustc_interface[a570f551ea6bf79f]::interface::run_compiler::<(), rustc_driver_impl[9b4b378bd639d3bd]::run_compiler::{closure#0}>::{closure#1}
  47:     0x7f566f90e1d6 - std[d1cf8494b7637499]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[a570f551ea6bf79f]::util::run_in_thread_with_globals<rustc_interface[a570f551ea6bf79f]::util::run_in_thread_pool_with_globals<rustc_interface[a570f551ea6bf79f]::interface::run_compiler<(), rustc_driver_impl[9b4b378bd639d3bd]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  48:     0x7f566f90dfa9 - <std[d1cf8494b7637499]::thread::lifecycle::spawn_unchecked<rustc_interface[a570f551ea6bf79f]::util::run_in_thread_with_globals<rustc_interface[a570f551ea6bf79f]::util::run_in_thread_pool_with_globals<rustc_interface[a570f551ea6bf79f]::interface::run_compiler<(), rustc_driver_impl[9b4b378bd639d3bd]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[7a5baad27c58ac9b]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  49:     0x7f566f90c3f8 - <std[d1cf8494b7637499]::sys::thread::unix::Thread>::new::thread_start
  50:     0x7f56694969cb - <unknown>
  51:     0x7f566951aa0c - <unknown>
  52:                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: rustc 1.93.0-nightly (66428d92b 2025-12-05) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [orphan_check_impl] checking whether impl `<impl at /tmp/icemaker_global_tempdir.bAeSV9EYs3Nh/rustc_testrunner_tmpdir_reporting.9b7fonKIt25S/mvce.rs:10:1: 10:42>` follows the orphan rules
#1 [coherent_trait] coherence checking all impls of trait `core::convert::From`
#2 [check_well_formed] checking that `<impl at /tmp/icemaker_global_tempdir.bAeSV9EYs3Nh/rustc_testrunner_tmpdir_reporting.9b7fonKIt25S/mvce.rs:10:1: 10:42>` is well-formed
#3 [check_type_wf] checking that types are well-formed
#4 [analysis] running analysis passes on crate `mvce`
end of query stack
error: aborting due to 6 previous errors

Some errors have detailed explanations: E0046, E0405, E0601, E0658.
For more information about an error, try `rustc --explain E0046`.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️S-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issueT-compilerRelevant to the compiler 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