Skip to content

[ICE]: incremental compilation error with evaluate_obligation #159932

Description

@YaxinCheng

Code

Run the following test twice, the first time keep let _ = cloned_a.bar().await; effective (not commented out). Then comment it out, without running cargo clean, run it again with let results = cloned_a.bar().await; commented out.

This is a bug in incremental compilation, so you gotta trigger incremental compilation

use tokio::sync::oneshot;

pub struct A;

impl A {
    pub async fn bar(&self) -> anyhow::Result<Vec<usize>> {
        let mut receivers = Vec::new();
        let (_, rx) = oneshot::channel::<usize>();
        receivers.push(rx);

        // The async closure returning a Result, combined with mapping into try_join_all
        let received = receivers.into_iter().map(async |receiver| receiver.await);

        // Awaiting this forces the compiler to track the Map iterator across an await point
        let result = futures::future::try_join_all(received).await?;

        Ok(result)
    }
}

// The ICE is triggered during tests (or anywhere tokio::spawn is used)
#[tokio::test]
async fn test_trigger_ice() {
    let a = std::sync::Arc::new(A);
    let cloned_a = a.clone();

    // tokio::spawn requires the future to be `Send`.
    // When rustc tries to prove the `Map` iterator from acquire_full is `Send`, it panics.
    tokio::spawn(async move {
        // run it once with this code. Then comment this out
        let _ = cloned_a.bar().await;

        // then again with the code below commented out.
        // let results = cloned_a.bar().await;
    });
}

Meta

rustc --version --verbose:

rustc 1.97.0 (2d8144b78 2026-07-07)
binary: rustc
commit-hash: 2d8144b7880597b6e6d3dfd63a9a9efae3f533d3
commit-date: 2026-07-07
host: aarch64-apple-darwin
release: 1.97.0
LLVM version: 22.1.6

Error output

error: internal compiler error: encountered incremental compilation error with evaluate_obligation(60f016ea56cb4f11-f6f9439a770d03aa)
  |
  = note: please follow the instructions below to create a bug report with the provided information
  = note: for incremental compilation bugs, having a reproduction is vital
  = note: an ideal reproduction consists of the code before and some patch that then triggers the bug when applied and compiled again
  = note: as a workaround, you can run `cargo clean -p inc_comp_ice` or `cargo clean` to allow your project to compile

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: rustc 1.97.0 (2d8144b78 2026-07-07) running on aarch64-apple-darwin
note: compiler flags: -C embed-bitcode=no -C debuginfo=2 -C split-debuginfo=unpacked -C incremental=[REDACTED]
note: some of the compiler flags provided by cargo are hidden
query stack during panic:
#0 [evaluate_obligation] evaluating trait selection obligation `core::iter::adapters::map::Map<alloc::vec::into_iter::IntoIter<tokio::sync::oneshot::Receiver<usize>>, {async closure@src/lib.rs:13:50: 13:66}>: core::iter::traits::collect::IntoIterator`
#1 [type_op_prove_predicate] evaluating `type_op_prove_predicate` `ProvePredicate { predicate: Binder { value: TraitPredicate(<core::iter::adapters::map::Map<alloc::vec::into_iter::IntoIter<tokio::sync::oneshot::Receiver<usize>>, {async closure@src/lib.rs:13:50: 13:66}> as core::iter::traits::collect::IntoIterator>, polarity:Positive), bound_vars: [] } }`
#2 [mir_borrowck] borrow-checking `<impl at src/lib.rs:6:1: 6:7>::bar`
#3 [type_of_opaque] computing type of opaque `<impl at src/lib.rs:6:1: 6:7>::bar::{opaque#0}`
#4 [evaluate_obligation] evaluating trait selection obligation `{async block@src/lib.rs:30:18: 30:28}: core::marker::Send`
#5 [check_coroutine_obligations] verify auto trait bounds for coroutine interior type `test_trigger_ice`
#6 [mir_borrowck] borrow-checking `test_trigger_ice`
#7 [analysis] running analysis passes on crate `inc_comp_ice`
end of query stack

Backtrace

RUST_BACKTRACE=1 cargo build does not trigger it, only RUST_BACKTRACE=1 cargo test does

RUST_BACKTRACE=1 cargo test
   Compiling inc_comp_ice v0.1.0 (/Users/cheng/Developer/Rust/inc_comp_ice)
error: internal compiler error: encountered incremental compilation error with evaluate_obligation(6d1fbefc43bc968a-6f133a3d498f8932)
  |
  = note: please follow the instructions below to create a bug report with the provided information
  = note: for incremental compilation bugs, having a reproduction is vital
  = note: an ideal reproduction consists of the code before and some patch that then triggers the bug when applied and compiled again
  = note: as a workaround, you can run `cargo clean -p inc_comp_ice` or `cargo clean` to allow your project to compile


thread 'rustc' (3174755) panicked at /rustc-dev/8bab26f4f68e0e26f0bb7960be334d5b520ea452/compiler/rustc_middle/src/verify_ich.rs:82:9:
Found unstable fingerprints for evaluate_obligation(6d1fbefc43bc968a-6f133a3d498f8932): Ok(EvaluatedToOk)
stack backtrace:
   0: __rustc::rust_begin_unwind
   1: core::panicking::panic_fmt
   2: rustc_middle::verify_ich::incremental_verify_ich_failed
   3: rustc_middle::verify_ich::incremental_verify_ich::<rustc_middle::query::erase::ErasedData<[u8; 2]>>
   4: rustc_query_impl::execution::try_execute_query::<rustc_middle::query::caches::DefaultCache<rustc_type_ir::canonical::CanonicalQueryInput<rustc_middle::ty::context::TyCtxt, rustc_middle::ty::ParamEnvAnd<rustc_middle::ty::predicate::Predicate>>, rustc_middle::query::erase::ErasedData<[u8; 2]>>, true>
   5: <rustc_infer::infer::InferCtxt as rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt>::evaluate_obligation
   6: <rustc_infer::infer::InferCtxt as rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt>::evaluate_obligation_no_overflow
   7: <rustc_trait_selection::traits::fulfill::FulfillProcessor>::process_trait_obligation
   8: <rustc_trait_selection::traits::fulfill::FulfillProcessor as rustc_data_structures::obligation_forest::ObligationProcessor>::process_obligation
   9: <rustc_data_structures::obligation_forest::ObligationForest<rustc_trait_selection::traits::fulfill::PendingPredicateObligation>>::process_obligations::<rustc_trait_selection::traits::fulfill::FulfillProcessor>
  10: <rustc_trait_selection::traits::fulfill::FulfillmentContext<rustc_infer::traits::engine::ScrubbedTraitError> as rustc_infer::traits::engine::TraitEngine<rustc_infer::traits::engine::ScrubbedTraitError>>::try_evaluate_obligations
  11: <rustc_trait_selection::traits::fulfill::FulfillmentContext<rustc_infer::traits::engine::ScrubbedTraitError> as rustc_infer::traits::engine::TraitEngine<rustc_infer::traits::engine::ScrubbedTraitError>>::evaluate_obligations_error_on_ambiguity
  12: <rustc_trait_selection::traits::engine::ObligationCtxt>::make_canonicalized_query_response::<()>
  13: rustc_traits::type_op::type_op_prove_predicate
  14: rustc_query_impl::execution::try_execute_query::<rustc_middle::query::caches::DefaultCache<rustc_type_ir::canonical::CanonicalQueryInput<rustc_middle::ty::context::TyCtxt, rustc_middle::ty::ParamEnvAnd<rustc_middle::traits::query::type_op::ProvePredicate>>, rustc_middle::query::erase::ErasedData<[u8; 8]>>, true>
  15: <rustc_middle::traits::query::type_op::ProvePredicate as rustc_trait_selection::traits::query::type_op::QueryTypeOp>::perform_query
  16: <rustc_borrowck::type_check::TypeChecker>::fully_perform_op::<(), rustc_middle::ty::ParamEnvAnd<rustc_middle::traits::query::type_op::ProvePredicate>>
  17: <rustc_borrowck::type_check::TypeChecker>::normalize_and_prove_instantiated_predicates
  18: <rustc_borrowck::type_check::TypeChecker as rustc_middle::mir::visit::Visitor>::visit_const_operand
  19: <rustc_borrowck::type_check::TypeChecker as rustc_middle::mir::visit::Visitor>::visit_operand
  20: <rustc_borrowck::type_check::TypeChecker as rustc_middle::mir::visit::Visitor>::visit_terminator
  21: <rustc_borrowck::type_check::TypeChecker as rustc_middle::mir::visit::Visitor>::visit_body
  22: rustc_borrowck::type_check::type_check
  23: rustc_borrowck::borrowck_collect_region_constraints
  24: <rustc_borrowck::root_cx::BorrowCheckRootCtxt>::do_mir_borrowck
  25: rustc_borrowck::mir_borrowck
  26: rustc_query_impl::execution::try_execute_query::<rustc_data_structures::vec_cache::VecCache<rustc_span::def_id::LocalDefId, rustc_middle::query::erase::ErasedData<[u8; 8]>, rustc_middle::dep_graph::graph::DepNodeIndex>, true>
  27: rustc_hir_analysis::collect::type_of::opaque::find_opaque_ty_constraints_for_rpit
  28: rustc_hir_analysis::collect::type_of::type_of_opaque
  29: rustc_query_impl::execution::try_execute_query::<rustc_middle::query::caches::DefIdCache<rustc_middle::query::erase::ErasedData<[u8; 8]>>, true>
  30: <rustc_trait_selection::traits::select::SelectionContext>::confirm_auto_impl_candidate::{closure#0}
  31: <rustc_trait_selection::traits::select::SelectionContext>::confirm_candidate
  32: <rustc_trait_selection::traits::select::SelectionContext>::evaluate_candidate::{closure#0}::{closure#0}
  33: <rustc_trait_selection::traits::select::SelectionContext>::evaluation_probe::<<rustc_trait_selection::traits::select::SelectionContext>::evaluate_candidate::{closure#0}::{closure#0}>
  34: <rustc_trait_selection::traits::select::SelectionContext>::evaluate_trait_predicate_recursively::{closure#0}::{closure#1}
  35: <rustc_trait_selection::traits::select::SelectionContext>::evaluate_trait_predicate_recursively
  36: <rustc_trait_selection::traits::select::SelectionContext>::evaluate_predicate_recursively::{closure#0}::{closure#0}
  37: <rustc_trait_selection::traits::select::SelectionContext>::evaluate_predicate_recursively
  38: <rustc_trait_selection::traits::select::SelectionContext>::evaluate_candidate::{closure#0}::{closure#0}
  39: <rustc_trait_selection::traits::select::SelectionContext>::evaluation_probe::<<rustc_trait_selection::traits::select::SelectionContext>::evaluate_candidate::{closure#0}::{closure#0}>
  40: <rustc_trait_selection::traits::select::SelectionContext>::evaluate_trait_predicate_recursively::{closure#0}::{closure#1}
  41: <rustc_trait_selection::traits::select::SelectionContext>::evaluate_trait_predicate_recursively
  42: <rustc_trait_selection::traits::select::SelectionContext>::evaluate_predicate_recursively::{closure#0}::{closure#0}
  43: <rustc_trait_selection::traits::select::SelectionContext>::evaluate_predicate_recursively
  44: <rustc_trait_selection::traits::select::SelectionContext>::evaluate_candidate::{closure#0}::{closure#0}
  45: <rustc_trait_selection::traits::select::SelectionContext>::evaluation_probe::<<rustc_trait_selection::traits::select::SelectionContext>::evaluate_candidate::{closure#0}::{closure#0}>
  46: <rustc_trait_selection::traits::select::SelectionContext>::evaluate_trait_predicate_recursively::{closure#0}::{closure#1}
  47: <rustc_trait_selection::traits::select::SelectionContext>::evaluate_trait_predicate_recursively
  48: <rustc_trait_selection::traits::select::SelectionContext>::evaluate_predicate_recursively::{closure#0}::{closure#0}
  49: <rustc_trait_selection::traits::select::SelectionContext>::evaluate_predicate_recursively
  50: <rustc_trait_selection::traits::select::SelectionContext>::evaluation_probe::<<rustc_trait_selection::traits::select::SelectionContext>::evaluate_root_obligation::{closure#0}>::{closure#0}
  51: <rustc_trait_selection::traits::select::SelectionContext>::evaluate_root_obligation
  52: rustc_traits::evaluate_obligation::evaluate_obligation
      [... omitted 1 frame ...]
  53: <rustc_infer::infer::InferCtxt as rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt>::evaluate_obligation
  54: <rustc_infer::infer::InferCtxt as rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt>::evaluate_obligation_no_overflow
  55: <rustc_trait_selection::traits::fulfill::FulfillProcessor>::process_trait_obligation
  56: <rustc_trait_selection::traits::fulfill::FulfillProcessor as rustc_data_structures::obligation_forest::ObligationProcessor>::process_obligation
  57: <rustc_data_structures::obligation_forest::ObligationForest<rustc_trait_selection::traits::fulfill::PendingPredicateObligation>>::process_obligations::<rustc_trait_selection::traits::fulfill::FulfillProcessor>
  58: <rustc_trait_selection::traits::fulfill::FulfillmentContext<rustc_trait_selection::traits::FulfillmentError> as rustc_infer::traits::engine::TraitEngine<rustc_trait_selection::traits::FulfillmentError>>::try_evaluate_obligations
  59: <rustc_trait_selection::traits::fulfill::FulfillmentContext<rustc_trait_selection::traits::FulfillmentError> as rustc_infer::traits::engine::TraitEngine<rustc_trait_selection::traits::FulfillmentError>>::evaluate_obligations_error_on_ambiguity
  60: rustc_hir_analysis::check::check::check_coroutine_obligations
      [... omitted 6 frames ...]
  61: <rustc_middle::ty::context::TyCtxt>::par_hir_body_owners::<rustc_interface::passes::run_required_analyses::{closure#2}::{closure#0}>::{closure#0}
  62: rustc_interface::passes::analysis
  63: rustc_query_impl::execution::try_execute_query::<rustc_middle::query::caches::SingleCache<rustc_middle::query::erase::ErasedData<[u8; 0]>>, true>
  64: rustc_interface::passes::create_and_enter_global_ctxt::<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2}>
  65: rustc_interface::interface::run_compiler::<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

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: rustc 1.97.1 (8bab26f4f 2026-07-14) running on aarch64-apple-darwin

note: compiler flags: -C embed-bitcode=no -C debuginfo=2 -C split-debuginfo=unpacked -C incremental=[REDACTED]

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
#0 [evaluate_obligation] evaluating trait selection obligation `core::iter::adapters::map::Map<alloc::vec::into_iter::IntoIter<tokio::sync::oneshot::Receiver<usize>>, {async closure@src/lib.rs:12:50: 12:66}>: core::iter::traits::collect::IntoIterator`
#1 [type_op_prove_predicate] evaluating `type_op_prove_predicate` `ProvePredicate { predicate: Binder { value: TraitPredicate(<core::iter::adapters::map::Map<alloc::vec::into_iter::IntoIter<tokio::sync::oneshot::Receiver<usize>>, {async closure@src/lib.rs:12:50: 12:66}> as core::iter::traits::collect::IntoIterator>, polarity:Positive), bound_vars: [] } }`
#2 [mir_borrowck] borrow-checking `<impl at src/lib.rs:5:1: 5:7>::bar`
#3 [type_of_opaque] computing type of opaque `<impl at src/lib.rs:5:1: 5:7>::bar::{opaque#0}`
#4 [evaluate_obligation] evaluating trait selection obligation `{async block@src/lib.rs:29:18: 29:28}: core::marker::Send`
#5 [check_coroutine_obligations] verify auto trait bounds for coroutine interior type `test_trigger_ice`
#6 [analysis] running analysis passes on crate `inc_comp_ice`
end of query stack
there was a panic while trying to force a dep node
try_mark_green dep node stack:
#0 mir_borrowck(inc_comp_ice[5cd8]::test_trigger_ice#1)
end of try_mark_green dep node stack
warning: unused variable: `labels`
  --> src/lib.rs:34:13
   |
34 |         let labels = cloned_pool.bar().await;
   |             ^^^^^^ help: if this is intentional, prefix it with an underscore: `_labels`
   |
   = note: `#[warn(unused_variables)]` (part of `#[warn(unused)]`) on by default

warning: `inc_comp_ice` (lib test) generated 1 warning
error: could not compile `inc_comp_ice` (lib test) due to 1 previous error; 1 warning emitted

Activity

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-incr-compArea: Incremental compilationC-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.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