Skip to content

ICE: EvalCtxt is tainted -- nested goals may have been dropped in a previous call to try_evaluate_added_goals` #134905

Closed
@matthiaskrgr

Description

@matthiaskrgr

auto-reduced (treereduce-rust):

trait Iterate<'a> {
    type Ty: Valid;
}
impl<'a, T> Iterate<'a> for T
where
    T: Check,
{
    default type Ty = ();
}

trait Check {}
impl<'a, T> Eq for T where <T as Iterate<'a>>::Ty: Valid {}

trait Valid {}

original:

#![feature(specialization)]
//~^ WARN the feature `specialization` is incomplete

trait Iterate<'a> {
    type Ty: Valid;
    fn mk() -> Self;
}
impl<'a, T> Iterate<'a> for T
where
    T: Check,
{
    default type Ty = ();
    //~^ ERROR the trait bound `(): Valid` is not satisfied
    default fn iterate(self) {}
}

trait Check {}
impl<'a, T> Eq for T where <T as Iterate<'a>>::Ty: Valid {}

trait Valid {}

fn main() {
    Iterate::iterate(0);
}

Version information

rustc 1.85.0-nightly (5c0a6e68c 2024-12-29)
binary: rustc
commit-hash: 5c0a6e68cfdad859615c2888de76505f13e6f01b
commit-date: 2024-12-29
host: x86_64-unknown-linux-gnu
release: 1.85.0-nightly
LLVM version: 19.1.6

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

Program output

error[E0658]: specialization is unstable
 --> /tmp/icemaker_global_tempdir.Z3wFfHKfangs/rustc_testrunner_tmpdir_reporting.uzq8dY128rQv/mvce.rs:8:5
  |
8 |     default type Ty = ();
  |     ^^^^^^^^^^^^^^^^^^^^^
  |
  = note: see issue #31844 <https://github.com/rust-lang/rust/issues/31844> for more information
  = help: add `#![feature(specialization)]` to the crate attributes to enable
  = note: this compiler was built on 2024-12-29; consider upgrading it if it is out of date

error[E0601]: `main` function not found in crate `mvce`
  --> /tmp/icemaker_global_tempdir.Z3wFfHKfangs/rustc_testrunner_tmpdir_reporting.uzq8dY128rQv/mvce.rs:14:15
   |
14 | trait Valid {}
   |               ^ consider adding a `main` function to `/tmp/icemaker_global_tempdir.Z3wFfHKfangs/rustc_testrunner_tmpdir_reporting.uzq8dY128rQv/mvce.rs`

error[E0277]: the trait bound `(): Valid` is not satisfied
  --> /tmp/icemaker_global_tempdir.Z3wFfHKfangs/rustc_testrunner_tmpdir_reporting.uzq8dY128rQv/mvce.rs:8:23
   |
8  |     default type Ty = ();
   |                       ^^ the trait `Valid` is not implemented for `()`
   |
help: this trait has no implementations, consider adding one
  --> /tmp/icemaker_global_tempdir.Z3wFfHKfangs/rustc_testrunner_tmpdir_reporting.uzq8dY128rQv/mvce.rs:14:1
   |
14 | trait Valid {}
   | ^^^^^^^^^^^
note: required by a bound in `Iterate::Ty`
  --> /tmp/icemaker_global_tempdir.Z3wFfHKfangs/rustc_testrunner_tmpdir_reporting.uzq8dY128rQv/mvce.rs:2:14
   |
2  |     type Ty: Valid;
   |              ^^^^^ required by this bound in `Iterate::Ty`

thread 'rustc' panicked at /rustc/5c0a6e68cfdad859615c2888de76505f13e6f01b/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/canonical.rs:88:9:
assertion `left == right` failed: EvalCtxt is tainted -- nested goals may have been dropped in a previous call to `try_evaluate_added_goals!`
  left: Err(NoSolution)
 right: Ok(())
stack backtrace:
   0:     0x783919abf5ca - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::hd76018e90f9bbfc3
   1:     0x78391a213466 - core::fmt::write::hed666983d2d54108
   2:     0x78391b14c011 - std::io::Write::write_fmt::hbf0b651b2658b449
   3:     0x783919abf422 - std::sys::backtrace::BacktraceLock::print::h3a9d6ff043e667f2
   4:     0x783919ac1929 - std::panicking::default_hook::{{closure}}::h928484cbba0336ce
   5:     0x783919ac1772 - std::panicking::default_hook::ha8b3bd2f7ee21424
   6:     0x783918c2e1f8 - std[3ebcc71b08131339]::panicking::update_hook::<alloc[740b194b6bfe8ab6]::boxed::Box<rustc_driver_impl[5b4410ee4a2bc4c4]::install_ice_hook::{closure#1}>>::{closure#0}
   7:     0x783919ac20e3 - std::panicking::rust_panic_with_hook::h58dbee9f864d075b
   8:     0x783919ac1dda - std::panicking::begin_panic_handler::{{closure}}::h0bef6691ea876880
   9:     0x783919abfa69 - std::sys::backtrace::__rust_end_short_backtrace::h293ac16534c0773f
  10:     0x783919ac1a9d - rust_begin_unwind
  11:     0x78391679a380 - core::panicking::panic_fmt::h291df79adaba8570
  12:     0x78391865f116 - core::panicking::assert_failed_inner::hc6124cab6b532df5
  13:     0x783919840523 - core[614645412a48dac]::panicking::assert_failed::<core[614645412a48dac]::result::Result<(), rustc_type_ir[57a1164042dbd323]::solve::NoSolution>, core[614645412a48dac]::result::Result<(), rustc_type_ir[57a1164042dbd323]::solve::NoSolution>>
  14:     0x78391ade13e2 - <rustc_next_trait_solver[8d04bf79b6e2d511]::solve::eval_ctxt::EvalCtxt<rustc_trait_selection[e5fd4b86af22d0f3]::solve::delegate::SolverDelegate, rustc_middle[404d2ae367c92b56]::ty::context::TyCtxt>>::evaluate_added_goals_and_make_canonical_response::{closure#0}
  15:     0x7839171d6ebc - <rustc_next_trait_solver[8d04bf79b6e2d511]::solve::eval_ctxt::EvalCtxt<rustc_trait_selection[e5fd4b86af22d0f3]::solve::delegate::SolverDelegate, rustc_middle[404d2ae367c92b56]::ty::context::TyCtxt>>::assemble_and_evaluate_candidates::<rustc_type_ir[57a1164042dbd323]::predicate::TraitPredicate<rustc_middle[404d2ae367c92b56]::ty::context::TyCtxt>>
  16:     0x78391b3f51e7 - <rustc_type_ir[57a1164042dbd323]::search_graph::SearchGraph<rustc_next_trait_solver[8d04bf79b6e2d511]::solve::search_graph::SearchGraphDelegate<rustc_trait_selection[e5fd4b86af22d0f3]::solve::delegate::SolverDelegate>, rustc_middle[404d2ae367c92b56]::ty::context::TyCtxt>>::evaluate_goal_in_task::<&mut <rustc_next_trait_solver[8d04bf79b6e2d511]::solve::eval_ctxt::EvalCtxt<rustc_trait_selection[e5fd4b86af22d0f3]::solve::delegate::SolverDelegate, rustc_middle[404d2ae367c92b56]::ty::context::TyCtxt>>::evaluate_canonical_goal::{closure#0}::{closure#0}::{closure#0}>
  17:     0x78391aded028 - <rustc_type_ir[57a1164042dbd323]::search_graph::SearchGraph<rustc_next_trait_solver[8d04bf79b6e2d511]::solve::search_graph::SearchGraphDelegate<rustc_trait_selection[e5fd4b86af22d0f3]::solve::delegate::SolverDelegate>, rustc_middle[404d2ae367c92b56]::ty::context::TyCtxt>>::with_new_goal::<<rustc_next_trait_solver[8d04bf79b6e2d511]::solve::eval_ctxt::EvalCtxt<rustc_trait_selection[e5fd4b86af22d0f3]::solve::delegate::SolverDelegate, rustc_middle[404d2ae367c92b56]::ty::context::TyCtxt>>::evaluate_canonical_goal::{closure#0}::{closure#0}::{closure#0}>
  18:     0x78391ade4fa2 - <rustc_next_trait_solver[8d04bf79b6e2d511]::solve::eval_ctxt::EvalCtxt<rustc_trait_selection[e5fd4b86af22d0f3]::solve::delegate::SolverDelegate, rustc_middle[404d2ae367c92b56]::ty::context::TyCtxt>>::evaluate_goal_raw
  19:     0x78391ade9f6a - rustc_trait_selection[e5fd4b86af22d0f3]::traits::coherence::overlap
  20:     0x78391a21a626 - <rustc_middle[404d2ae367c92b56]::traits::specialization_graph::Children as rustc_trait_selection[e5fd4b86af22d0f3]::traits::specialize::specialization_graph::ChildrenExt>::insert
  21:     0x78391b05a391 - <rustc_middle[404d2ae367c92b56]::traits::specialization_graph::Graph as rustc_trait_selection[e5fd4b86af22d0f3]::traits::specialize::specialization_graph::GraphExt>::insert
  22:     0x78391a448783 - rustc_trait_selection[e5fd4b86af22d0f3]::traits::specialize::specialization_graph_provider
  23:     0x78391a4484dd - rustc_query_impl[dd07ae5eac7025a4]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[dd07ae5eac7025a4]::query_impl::specialization_graph_of::dynamic_query::{closure#2}::{closure#0}, rustc_middle[404d2ae367c92b56]::query::erase::Erased<[u8; 8usize]>>
  24:     0x78391a2ed91f - rustc_query_system[a6bda300fd750441]::query::plumbing::try_execute_query::<rustc_query_impl[dd07ae5eac7025a4]::DynamicConfig<rustc_query_system[a6bda300fd750441]::query::caches::DefIdCache<rustc_middle[404d2ae367c92b56]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[dd07ae5eac7025a4]::plumbing::QueryCtxt, false>
  25:     0x78391a8d66b5 - rustc_query_impl[dd07ae5eac7025a4]::query_impl::specialization_graph_of::get_query_non_incr::__rust_end_short_backtrace
  26:     0x78391a9af1ad - rustc_hir_analysis[42d91103dadc7b0f]::coherence::coherent_trait
  27:     0x78391a9aef17 - rustc_query_impl[dd07ae5eac7025a4]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[dd07ae5eac7025a4]::query_impl::coherent_trait::dynamic_query::{closure#2}::{closure#0}, rustc_middle[404d2ae367c92b56]::query::erase::Erased<[u8; 1usize]>>
  28:     0x78391a5125eb - rustc_query_system[a6bda300fd750441]::query::plumbing::try_execute_query::<rustc_query_impl[dd07ae5eac7025a4]::DynamicConfig<rustc_query_system[a6bda300fd750441]::query::caches::DefIdCache<rustc_middle[404d2ae367c92b56]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[dd07ae5eac7025a4]::plumbing::QueryCtxt, false>
  29:     0x78391a511622 - rustc_query_impl[dd07ae5eac7025a4]::query_impl::coherent_trait::get_query_non_incr::__rust_end_short_backtrace
  30:     0x78391aaa93cc - rustc_middle[404d2ae367c92b56]::query::plumbing::query_ensure_error_guaranteed::<rustc_query_system[a6bda300fd750441]::query::caches::DefIdCache<rustc_middle[404d2ae367c92b56]::query::erase::Erased<[u8; 1usize]>>, ()>
  31:     0x7839179b8cbd - rustc_hir_analysis[42d91103dadc7b0f]::check::wfcheck::check_well_formed
  32:     0x78391abfc2bb - rustc_query_impl[dd07ae5eac7025a4]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[dd07ae5eac7025a4]::query_impl::check_well_formed::dynamic_query::{closure#2}::{closure#0}, rustc_middle[404d2ae367c92b56]::query::erase::Erased<[u8; 1usize]>>
  33:     0x78391abfbd69 - rustc_query_system[a6bda300fd750441]::query::plumbing::try_execute_query::<rustc_query_impl[dd07ae5eac7025a4]::DynamicConfig<rustc_data_structures[cf63a78d0cde4c59]::vec_cache::VecCache<rustc_span[8931c23d12488321]::def_id::LocalDefId, rustc_middle[404d2ae367c92b56]::query::erase::Erased<[u8; 1usize]>, rustc_query_system[a6bda300fd750441]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[dd07ae5eac7025a4]::plumbing::QueryCtxt, false>
  34:     0x78391abfb7cb - rustc_query_impl[dd07ae5eac7025a4]::query_impl::check_well_formed::get_query_non_incr::__rust_end_short_backtrace
  35:     0x78391abfc52c - rustc_hir_analysis[42d91103dadc7b0f]::check::wfcheck::check_mod_type_wf
  36:     0x78391abfc34b - rustc_query_impl[dd07ae5eac7025a4]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[dd07ae5eac7025a4]::query_impl::check_mod_type_wf::dynamic_query::{closure#2}::{closure#0}, rustc_middle[404d2ae367c92b56]::query::erase::Erased<[u8; 1usize]>>
  37:     0x78391b177188 - rustc_query_system[a6bda300fd750441]::query::plumbing::try_execute_query::<rustc_query_impl[dd07ae5eac7025a4]::DynamicConfig<rustc_query_system[a6bda300fd750441]::query::caches::DefaultCache<rustc_span[8931c23d12488321]::def_id::LocalModDefId, rustc_middle[404d2ae367c92b56]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[dd07ae5eac7025a4]::plumbing::QueryCtxt, false>
  38:     0x78391b176f30 - rustc_query_impl[dd07ae5eac7025a4]::query_impl::check_mod_type_wf::get_query_non_incr::__rust_end_short_backtrace
  39:     0x78391a4f6db8 - rustc_hir_analysis[42d91103dadc7b0f]::check_crate
  40:     0x78391a670068 - rustc_interface[369fa5095bec1a52]::passes::run_required_analyses
  41:     0x78391b1502de - rustc_interface[369fa5095bec1a52]::passes::analysis
  42:     0x78391b1502af - rustc_query_impl[dd07ae5eac7025a4]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[dd07ae5eac7025a4]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[404d2ae367c92b56]::query::erase::Erased<[u8; 0usize]>>
  43:     0x78391b196ad5 - rustc_query_system[a6bda300fd750441]::query::plumbing::try_execute_query::<rustc_query_impl[dd07ae5eac7025a4]::DynamicConfig<rustc_query_system[a6bda300fd750441]::query::caches::SingleCache<rustc_middle[404d2ae367c92b56]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[dd07ae5eac7025a4]::plumbing::QueryCtxt, false>
  44:     0x78391b19680e - rustc_query_impl[dd07ae5eac7025a4]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  45:     0x78391b1e64de - rustc_interface[369fa5095bec1a52]::passes::create_and_enter_global_ctxt::<core[614645412a48dac]::option::Option<rustc_interface[369fa5095bec1a52]::queries::Linker>, rustc_driver_impl[5b4410ee4a2bc4c4]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
  46:     0x78391b1c1da4 - rustc_interface[369fa5095bec1a52]::interface::run_compiler::<(), rustc_driver_impl[5b4410ee4a2bc4c4]::run_compiler::{closure#0}>::{closure#1}
  47:     0x78391b055987 - std[3ebcc71b08131339]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[369fa5095bec1a52]::util::run_in_thread_with_globals<rustc_interface[369fa5095bec1a52]::util::run_in_thread_pool_with_globals<rustc_interface[369fa5095bec1a52]::interface::run_compiler<(), rustc_driver_impl[5b4410ee4a2bc4c4]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  48:     0x78391b055e24 - <<std[3ebcc71b08131339]::thread::Builder>::spawn_unchecked_<rustc_interface[369fa5095bec1a52]::util::run_in_thread_with_globals<rustc_interface[369fa5095bec1a52]::util::run_in_thread_pool_with_globals<rustc_interface[369fa5095bec1a52]::interface::run_compiler<(), rustc_driver_impl[5b4410ee4a2bc4c4]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[614645412a48dac]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  49:     0x78391b0573ef - std::sys::pal::unix::thread::Thread::new::thread_start::h5915fa5c1bb9f309
  50:     0x7839154a339d - <unknown>
  51:     0x78391552849c - <unknown>
  52:                0x0 - <unknown>

error: the compiler unexpectedly panicked. this is a bug.

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.85.0-nightly (5c0a6e68c 2024-12-29) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [specialization_graph_of] building specialization graph of trait `core::cmp::Eq`
#1 [coherent_trait] coherence checking all impls of trait `core::cmp::Eq`
#2 [check_well_formed] checking that `<impl at /tmp/icemaker_global_tempdir.Z3wFfHKfangs/rustc_testrunner_tmpdir_reporting.uzq8dY128rQv/mvce.rs:12:1: 12:57>` is well-formed
#3 [check_mod_type_wf] checking that types are well-formed in top-level module
#4 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 3 previous errors

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

@rustbot label +F-specialization

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-specializationArea: Trait impl specializationC-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 issueT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.T-typesRelevant to the types 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