Skip to content

ICE: unexpected ambiguity: CanonicalQueryInput - broken MIR #141478

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
konnorandrews opened this issue May 24, 2025 · 8 comments
Open

ICE: unexpected ambiguity: CanonicalQueryInput - broken MIR #141478

konnorandrews opened this issue May 24, 2025 · 8 comments
Labels
C-bug Category: This is a bug. fixed-by-next-solver Fixed by the next-generation trait solver, `-Znext-solver`. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. S-has-bisection Status: A bisection has been found for this issue S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@konnorandrews
Copy link

Code

I tried to minimize the code but ended up with quite a lot. Clone the below repo and run cargo check.

https://gitlab.com/konnorandrews/supply/-/tree/rustc-ice-ambiguity?ref_type=heads

Meta

rustc --version --verbose:

rustc 1.87.0 (17067e9ac 2025-05-09)
binary: rustc
commit-hash: 17067e9ac6d7ecb70e50f92c1944e545188d2359
commit-date: 2025-05-09
host: x86_64-unknown-linux-gnu
release: 1.87.0
LLVM version: 20.1.1

Also tested on beta and nightly with same error.

Error output

note: no errors encountered even though delayed bugs were created

note: those delayed bugs will now be shown as internal compiler errors

error: internal compiler error: unexpected ambiguity: CanonicalQueryInput { canonical: Canonical { value: ParamEnvAnd { param_env: ParamEnv { caller_bounds: [Binder { value: TraitPredicate(<T as ToProviderRef<'_>>, polarity:Positive), bound_vars: [] }, Binder { value: TraitPredicate(<T as std::marker::Sized>, polarity:Positive), bound_vars: [] }] }, value: AliasTy { args: [Value<i32, Infer, ty_tag::DefaultGroup>, ty_tag::lifetime_list::Lt<'^1, ty_tag::lifetime_list::Lt<'^2, Alias(Projection, AliasTy { args: [T/#1, '^2, &'^3 T/#1], def_id: DefId(0:52 ~ supply[8b9a]::ToProviderRef::LifetimesRef), .. })>>], def_id: DefId(0:38 ~ supply[8b9a]::RequestWithArg::Output), .. } }, max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }, CanonicalVarInfo { kind: Region(U0) }, CanonicalVarInfo { kind: Region(U0) }, CanonicalVarInfo { kind: Region(U0) }] }, typing_mode: Analysis { defining_opaque_types: [] } } Canonical { value: QueryResponse { var_values: CanonicalVarValues { var_values: ['^0, '^1, '^2, '^3] }, region_constraints: QueryRegionConstraints { outlives: [(OutlivesPredicate('^1, '^1), BoringNoLocation), (OutlivesPredicate('^1, '^1), BoringNoLocation), (OutlivesPredicate('^2, '^2), BoringNoLocation), (OutlivesPredicate('^2, '^2), BoringNoLocation), (OutlivesPredicate('^1, '^1), BoringNoLocation), (OutlivesPredicate('^1, '^1), BoringNoLocation), (OutlivesPredicate('^2, '^2), BoringNoLocation), (OutlivesPredicate('^2, '^2), BoringNoLocation), (OutlivesPredicate('^2, '^2), BoringNoLocation), (OutlivesPredicate('^2, '^2), BoringNoLocation), (OutlivesPredicate('^2, '^2), BoringNoLocation), (OutlivesPredicate('^2, '^2), BoringNoLocation), (OutlivesPredicate('^1, '^1), BoringNoLocation), (OutlivesPredicate('^1, '^1), BoringNoLocation), (OutlivesPredicate('^1, '^1), BoringNoLocation), (OutlivesPredicate('^1, '^1), BoringNoLocation), (OutlivesPredicate('^1, '^1), BoringNoLocation), (OutlivesPredicate('^1, '^1), BoringNoLocation), (OutlivesPredicate('^2, '^2), BoringNoLocation), (OutlivesPredicate('^2, '^2), BoringNoLocation), (OutlivesPredicate('^2, '^2), BoringNoLocation), (OutlivesPredicate('^2, '^2), BoringNoLocation), (OutlivesPredicate('^2, '^2), BoringNoLocation), (OutlivesPredicate('^2, '^2), BoringNoLocation), (OutlivesPredicate('^2, '^2), BoringNoLocation), (OutlivesPredicate('^2, '^2), BoringNoLocation), (OutlivesPredicate('^2, '^2), BoringNoLocation), (OutlivesPredicate('^2, '^2), BoringNoLocation), (OutlivesPredicate('^2, '^2), BoringNoLocation), (OutlivesPredicate('^2, '^2), BoringNoLocation), (OutlivesPredicate('^2, '^2), BoringNoLocation), (OutlivesPredicate('^2, '^2), BoringNoLocation), (OutlivesPredicate('^2, '^2), BoringNoLocation), (OutlivesPredicate('^2, '^2), BoringNoLocation), (OutlivesPredicate('^2, '^2), BoringNoLocation), (OutlivesPredicate('^2, '^2), BoringNoLocation), (OutlivesPredicate('^2, '^2), BoringNoLocation), (OutlivesPredicate('^2, '^2), BoringNoLocation), (OutlivesPredicate('^2, '^2), BoringNoLocation), (OutlivesPredicate('^2, '^2), BoringNoLocation), (OutlivesPredicate('^1, '^1), BoringNoLocation), (OutlivesPredicate('^1, '^1), BoringNoLocation), (OutlivesPredicate('^1, '^1), BoringNoLocation), (OutlivesPredicate('^1, '^1), BoringNoLocation), (OutlivesPredicate('^1, '^1), BoringNoLocation), (OutlivesPredicate('^1, '^1), BoringNoLocation), (OutlivesPredicate('^1, '^1), BoringNoLocation), (OutlivesPredicate('^1, '^1), BoringNoLocation), (OutlivesPredicate('^1, '^1), BoringNoLocation), (OutlivesPredicate('^1, '^1), BoringNoLocation), (OutlivesPredicate('^1, '^1), BoringNoLocation), (OutlivesPredicate('^1, '^1), BoringNoLocation), (OutlivesPredicate('^1, '^1), BoringNoLocation), (OutlivesPredicate('^1, '^1), BoringNoLocation), (OutlivesPredicate('^1, '^1), BoringNoLocation), (OutlivesPredicate('^1, '^1), BoringNoLocation), (OutlivesPredicate('^2, '^2), BoringNoLocation), (OutlivesPredicate('^2, '^2), BoringNoLocation), (OutlivesPredicate('^2, '^2), BoringNoLocation), (OutlivesPredicate('^2, '^2), BoringNoLocation), (OutlivesPredicate('^1, '^1), BoringNoLocation), (OutlivesPredicate('^1, '^1), BoringNoLocation), (OutlivesPredicate('^2, '^2), BoringNoLocation), (OutlivesPredicate('^2, '^2), BoringNoLocation), (OutlivesPredicate('^2, '^2), BoringNoLocation), (OutlivesPredicate('^2, '^2), BoringNoLocation), (OutlivesPredicate('^1, '^1), BoringNoLocation), (OutlivesPredicate('^1, '^1), BoringNoLocation), (OutlivesPredicate('^1, '^1), BoringNoLocation), (OutlivesPredicate('^1, '^1), BoringNoLocation), (OutlivesPredicate('^2, '^2), BoringNoLocation), (OutlivesPredicate('^2, '^2), BoringNoLocation), (OutlivesPredicate('^2, '^2), BoringNoLocation), (OutlivesPredicate('^2, '^2), BoringNoLocation), (OutlivesPredicate('^1, '^1), BoringNoLocation), (OutlivesPredicate('^1, '^1), BoringNoLocation), (OutlivesPredicate('^1, '^1), BoringNoLocation), (OutlivesPredicate('^1, '^1), BoringNoLocation), (OutlivesPredicate('^1, '^1), BoringNoLocation), (OutlivesPredicate('^1, '^1), BoringNoLocation), (OutlivesPredicate('^1, '^1), BoringNoLocation), (OutlivesPredicate('^1, '^1), BoringNoLocation), (OutlivesPredicate('^1, '^1), BoringNoLocation), (OutlivesPredicate('^1, '^1), BoringNoLocation), (OutlivesPredicate('^1, '^1), BoringNoLocation), (OutlivesPredicate('^1, '^1), BoringNoLocation), (OutlivesPredicate('^1, '^1), BoringNoLocation), (OutlivesPredicate('^1, '^1), BoringNoLocation), (OutlivesPredicate('^2, '^2), BoringNoLocation), (OutlivesPredicate('^2, '^2), BoringNoLocation), (OutlivesPredicate('^2, '^2), BoringNoLocation), (OutlivesPredicate('^2, '^2), BoringNoLocation), (OutlivesPredicate('^2, '^2), BoringNoLocation), (OutlivesPredicate('^2, '^2), BoringNoLocation), (OutlivesPredicate('^2, '^2), BoringNoLocation), (OutlivesPredicate('^2, '^2), BoringNoLocation), (OutlivesPredicate('^2, '^2), BoringNoLocation), (OutlivesPredicate('^2, '^2), BoringNoLocation), (OutlivesPredicate('^2, '^2), BoringNoLocation), (OutlivesPredicate('^2, '^2), BoringNoLocation), (OutlivesPredicate('^2, '^2), BoringNoLocation), (OutlivesPredicate('^2, '^2), BoringNoLocation), (OutlivesPredicate('^2, '^2), BoringNoLocation), (OutlivesPredicate('^2, '^2), BoringNoLocation), (OutlivesPredicate('^2, '^2), BoringNoLocation), (OutlivesPredicate('^2, '^2), BoringNoLocation), (OutlivesPredicate('^2, '^2), BoringNoLocation), (OutlivesPredicate('^2, '^2), BoringNoLocation), (OutlivesPredicate('^2, '^2), BoringNoLocation), (OutlivesPredicate('^2, '^2), BoringNoLocation), (OutlivesPredicate(ty_tag::num::NOne<ty_tag::num::NZero>, 'static), BoringNoLocation), (OutlivesPredicate(ty_tag::num::NZero, 'static), BoringNoLocation), (OutlivesPredicate(ty_tag::lifetime_list::projection::NRange<ty_tag::num::NOne<ty_tag::num::NZero>, ty_tag::num::NOne<ty_tag::num::NZero>>, 'static), BoringNoLocation), (OutlivesPredicate(ty_tag::num::NOne<ty_tag::num::NZero>, 'static), BoringNoLocation), (OutlivesPredicate(ty_tag::num::NOne<ty_tag::num::NOne<Alias(Projection, AliasTy { args: [Alias(Projection, AliasTy { args: [T/#1, '^2, &'^3 T/#1], def_id: DefId(0:52 ~ supply[8b9a]::ToProviderRef::LifetimesRef), .. })], def_id: DefId(20:902 ~ ty_tag[fb59]::lifetime_list::LifetimeListType::Len), .. })>>, 'static), BoringNoLocation), (OutlivesPredicate(ty_tag::num::NOne<Alias(Projection, AliasTy { args: [Alias(Projection, AliasTy { args: [T/#1, '^2, &'^3 T/#1], def_id: DefId(0:52 ~ supply[8b9a]::ToProviderRef::LifetimesRef), .. })], def_id: DefId(20:902 ~ ty_tag[fb59]::lifetime_list::LifetimeListType::Len), .. })>, 'static), BoringNoLocation), (OutlivesPredicate(ty_tag::num::NOne<ty_tag::num::NZero>, 'static), BoringNoLocation), (OutlivesPredicate(ty_tag::num::NZero, 'static), BoringNoLocation), (OutlivesPredicate(ty_tag::external_tags::core::I32, 'static), BoringNoLocation), (OutlivesPredicate(ty_tag::lifetime_list::projection::NRange<ty_tag::num::NOne<ty_tag::num::NZero>, ty_tag::num::NOne<ty_tag::num::NZero>>, 'static), BoringNoLocation), (OutlivesPredicate(ty_tag::num::NOne<ty_tag::num::NZero>, 'static), BoringNoLocation), (OutlivesPredicate(ty_tag::num::NOne<ty_tag::num::NZero>, 'static), BoringNoLocation), (OutlivesPredicate(ty_tag::num::NZero, 'static), BoringNoLocation), (OutlivesPredicate(ty_tag::lifetime_list::projection::NRange<ty_tag::num::NOne<ty_tag::num::NZero>, ty_tag::num::NOne<ty_tag::num::NZero>>, 'static), BoringNoLocation), (OutlivesPredicate(Alias(Projection, AliasTy { args: [Alias(Projection, AliasTy { args: [T/#1, '^2, &'^3 T/#1], def_id: DefId(0:52 ~ supply[8b9a]::ToProviderRef::LifetimesRef), .. })], def_id: DefId(20:902 ~ ty_tag[fb59]::lifetime_list::LifetimeListType::Len), .. }), 'static), BoringNoLocation)] }, certainty: Ambiguous, opaque_types: [], value: NormalizationResult { normalized_ty: std::option::Option<i32> } }, max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }, CanonicalVarInfo { kind: Region(U0) }, CanonicalVarInfo { kind: Region(U0) }, CanonicalVarInfo { kind: Region(U0) }] }
  |
  = note: delayed at compiler/rustc_trait_selection/src/traits/query/normalize.rs:287:30 - disabled backtrace

error: internal compiler error: error performing operation: fully_perform
  --> src/lib.rs:14:5
   |
14 |     x.to_provider_ref().request::<Value<i32>>();
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
note: delayed at /rustc/17067e9ac6d7ecb70e50f92c1944e545188d2359/compiler/rustc_trait_selection/src/traits/query/type_op/custom.rs:87:25 - disabled backtrace
  --> src/lib.rs:14:5
   |
14 |     x.to_provider_ref().request::<Value<i32>>();
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: internal compiler error: broken MIR in DefId(0:26 ~ supply[8b9a]::pretty_print) (Terminator { source_info: SourceInfo { span: src/lib.rs:14:5: 14:48 (#0), scope: scope[0] }, kind: _2 = <<T as ToProviderRef<'_, &T>>::ProviderRef as RequestExt>::request::<'_, Value<i32>>(move _3) -> [return: bb2, unwind: bb3] }): call dest mismatch (std::option::Option<i32> <- Alias(Projection, AliasTy { args: [Value<i32, Infer, ty_tag::DefaultGroup>, ty_tag::lifetime_list::Lt<'?8, Alias(Projection, AliasTy { args: [Alias(Projection, AliasTy { args: [T/#1, '?6, &'?7 T/#1], def_id: DefId(0:53 ~ supply[8b9a]::ToProviderRef::ProviderRef), .. })], def_id: DefId(0:47 ~ supply[8b9a]::HasLifetimes::Lifetimes), .. })>], def_id: DefId(0:38 ~ supply[8b9a]::RequestWithArg::Output), .. })): NoSolution
  --> src/lib.rs:14:25
   |
14 |     x.to_provider_ref().request::<Value<i32>>();
   |                         ^^^^^^^
   |
note: delayed at compiler/rustc_borrowck/src/type_check/mod.rs:1950:21 - disabled backtrace
  --> src/lib.rs:14:25
   |
14 |     x.to_provider_ref().request::<Value<i32>>();
   |                         ^^^^^^^

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.87.0 (17067e9ac 2025-05-09) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type lib -C embed-bitcode=no -C debuginfo=2 -C incremental=[REDACTED]

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

query stack during panic:
end of query stack
Backtrace

There are three errors so three backtraces.

  = note: delayed at compiler/rustc_trait_selection/src/traits/query/normalize.rs:287:30
             0: <rustc_errors::DiagCtxtInner>::emit_diagnostic
             1: <rustc_errors::DiagCtxtHandle>::emit_diagnostic
             2: <rustc_span::ErrorGuaranteed as rustc_errors::diagnostic::EmissionGuarantee>::emit_producing_guarantee
             3: <rustc_errors::DiagCtxtHandle>::delayed_bug::<alloc::string::String>
             4: <rustc_trait_selection::traits::query::normalize::QueryNormalizer as rustc_type_ir::fold::FallibleTypeFolder<rustc_middle::ty::context::TyCtxt>>::try_fold_ty
             5: <rustc_type_ir::ty_kind::FnSig<rustc_middle::ty::context::TyCtxt> as rustc_type_ir::fold::TypeFoldable<rustc_middle::ty::context::TyCtxt>>::try_fold_with::<rustc_trait_selection::traits::query::normalize::QueryNormalizer>
             6: rustc_traits::type_op::type_op_normalize_fn_sig
             7: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::type_op_normalize_fn_sig::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 8]>>
             8: <rustc_query_impl::query_impl::type_op_normalize_fn_sig::dynamic_query::{closure#2} as core::ops::function::FnOnce<(rustc_middle::ty::context::TyCtxt, rustc_type_ir::canonical::CanonicalQueryInput<rustc_middle::ty::context::TyCtxt, rustc_middle::ty::ParamEnvAnd<rustc_middle::traits::query::type_op::Normalize<rustc_type_ir::ty_kind::FnSig<rustc_middle::ty::context::TyCtxt>>>>)>>::call_once
             9: <rustc_query_system::query::plumbing::execute_job_incr<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::DefaultCache<rustc_type_ir::canonical::CanonicalQueryInput<rustc_middle::ty::context::TyCtxt, rustc_middle::ty::ParamEnvAnd<rustc_type_ir::ty_kind::AliasTy<rustc_middle::ty::context::TyCtxt>>>, rustc_middle::query::erase::Erased<[u8; 8]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt>::{closure#2}::{closure#2} as core::ops::function::FnOnce<((rustc_query_impl::plumbing::QueryCtxt, rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::DefaultCache<rustc_type_ir::canonical::CanonicalQueryInput<rustc_middle::ty::context::TyCtxt, rustc_middle::ty::ParamEnvAnd<rustc_type_ir::ty_kind::AliasTy<rustc_middle::ty::context::TyCtxt>>>, rustc_middle::query::erase::Erased<[u8; 8]>>, false, false, false>), rustc_type_ir::canonical::CanonicalQueryInput<rustc_middle::ty::context::TyCtxt, rustc_middle::ty::ParamEnvAnd<rustc_type_ir::ty_kind::AliasTy<rustc_middle::ty::context::TyCtxt>>>)>>::call_once
            10: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::DefaultCache<rustc_type_ir::canonical::CanonicalQueryInput<rustc_middle::ty::context::TyCtxt, rustc_middle::ty::ParamEnvAnd<rustc_middle::traits::query::type_op::Normalize<rustc_type_ir::ty_kind::FnSig<rustc_middle::ty::context::TyCtxt>>>>, rustc_middle::query::erase::Erased<[u8; 8]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, true>
            11: rustc_query_impl::query_impl::type_op_normalize_fn_sig::get_query_incr::__rust_end_short_backtrace
            12: <rustc_type_ir::ty_kind::FnSig<rustc_middle::ty::context::TyCtxt> as rustc_trait_selection::traits::query::type_op::normalize::Normalizable>::type_op_method
            13: <rustc_middle::ty::ParamEnvAnd<rustc_middle::traits::query::type_op::DeeplyNormalize<rustc_type_ir::ty_kind::FnSig<rustc_middle::ty::context::TyCtxt>>> as rustc_trait_selection::traits::query::type_op::TypeOp>::fully_perform
            14: <rustc_borrowck::type_check::TypeChecker as rustc_middle::mir::visit::Visitor>::visit_body
            15: rustc_borrowck::type_check::type_check
            16: rustc_borrowck::nll::compute_regions
            17: rustc_borrowck::do_mir_borrowck
            18: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::mir_borrowck::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 8]>>
            19: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_data_structures::vec_cache::VecCache<rustc_span::def_id::LocalDefId, rustc_middle::query::erase::Erased<[u8; 8]>, rustc_query_system::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, true>
            20: rustc_query_impl::query_impl::mir_borrowck::get_query_incr::__rust_end_short_backtrace
            21: rustc_interface::passes::run_required_analyses
            22: rustc_interface::passes::analysis
            23: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 0]>>
            24: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::SingleCache<rustc_middle::query::erase::Erased<[u8; 0]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, true>
            25: rustc_query_impl::query_impl::analysis::get_query_incr::__rust_end_short_backtrace
            26: rustc_interface::passes::create_and_enter_global_ctxt::<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
            27: rustc_interface::interface::run_compiler::<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}
            28: std::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface::util::run_in_thread_with_globals<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
            29: <<std::thread::Builder>::spawn_unchecked_<rustc_interface::util::run_in_thread_with_globals<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
            30: std::sys::pal::unix::thread::Thread::new::thread_start
            31: <unknown>
            32: <unknown>
note: delayed at /rustc/17067e9ac6d7ecb70e50f92c1944e545188d2359/compiler/rustc_trait_selection/src/traits/query/type_op/custom.rs:87:25
         0: <rustc_errors::DiagCtxtInner>::emit_diagnostic
         1: <rustc_errors::DiagCtxtHandle>::emit_diagnostic
         2: <rustc_span::ErrorGuaranteed as rustc_errors::diagnostic::EmissionGuarantee>::emit_producing_guarantee
         3: <rustc_errors::DiagCtxtHandle>::span_delayed_bug::<rustc_span::span_encoding::Span, alloc::string::String>
         4: <rustc_middle::ty::ParamEnvAnd<rustc_middle::traits::query::type_op::DeeplyNormalize<rustc_type_ir::ty_kind::FnSig<rustc_middle::ty::context::TyCtxt>>> as rustc_trait_selection::traits::query::type_op::TypeOp>::fully_perform
         5: <rustc_borrowck::type_check::TypeChecker as rustc_middle::mir::visit::Visitor>::visit_body
         6: rustc_borrowck::type_check::type_check
         7: rustc_borrowck::nll::compute_regions
         8: rustc_borrowck::do_mir_borrowck
         9: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::mir_borrowck::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 8]>>
        10: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_data_structures::vec_cache::VecCache<rustc_span::def_id::LocalDefId, rustc_middle::query::erase::Erased<[u8; 8]>, rustc_query_system::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, true>
        11: rustc_query_impl::query_impl::mir_borrowck::get_query_incr::__rust_end_short_backtrace
        12: rustc_interface::passes::run_required_analyses
        13: rustc_interface::passes::analysis
        14: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 0]>>
        15: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::SingleCache<rustc_middle::query::erase::Erased<[u8; 0]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, true>
        16: rustc_query_impl::query_impl::analysis::get_query_incr::__rust_end_short_backtrace
        17: rustc_interface::passes::create_and_enter_global_ctxt::<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
        18: rustc_interface::interface::run_compiler::<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}
        19: std::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface::util::run_in_thread_with_globals<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
        20: <<std::thread::Builder>::spawn_unchecked_<rustc_interface::util::run_in_thread_with_globals<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
        21: std::sys::pal::unix::thread::Thread::new::thread_start
        22: <unknown>
        23: <unknown>
note: delayed at compiler/rustc_borrowck/src/type_check/mod.rs:1950:21
         0: <rustc_errors::DiagCtxtInner>::emit_diagnostic
         1: <rustc_errors::DiagCtxtHandle>::emit_diagnostic
         2: <rustc_span::ErrorGuaranteed as rustc_errors::diagnostic::EmissionGuarantee>::emit_producing_guarantee
         3: <rustc_errors::DiagCtxtHandle>::span_delayed_bug::<rustc_span::span_encoding::Span, alloc::string::String>
         4: <rustc_borrowck::type_check::TypeChecker as rustc_middle::mir::visit::Visitor>::visit_body
         5: rustc_borrowck::type_check::type_check
         6: rustc_borrowck::nll::compute_regions
         7: rustc_borrowck::do_mir_borrowck
         8: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::mir_borrowck::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 8]>>
         9: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_data_structures::vec_cache::VecCache<rustc_span::def_id::LocalDefId, rustc_middle::query::erase::Erased<[u8; 8]>, rustc_query_system::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, true>
        10: rustc_query_impl::query_impl::mir_borrowck::get_query_incr::__rust_end_short_backtrace
        11: rustc_interface::passes::run_required_analyses
        12: rustc_interface::passes::analysis
        13: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 0]>>
        14: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::SingleCache<rustc_middle::query::erase::Erased<[u8; 0]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, true>
        15: rustc_query_impl::query_impl::analysis::get_query_incr::__rust_end_short_backtrace
        16: rustc_interface::passes::create_and_enter_global_ctxt::<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
        17: rustc_interface::interface::run_compiler::<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}
        18: std::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface::util::run_in_thread_with_globals<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
        19: <<std::thread::Builder>::spawn_unchecked_<rustc_interface::util::run_in_thread_with_globals<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
        20: std::sys::pal::unix::thread::Thread::new::thread_start
        21: <unknown>
        22: <unknown>

@konnorandrews konnorandrews added I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. C-bug Category: This is a bug. labels May 24, 2025
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label May 24, 2025
@konnorandrews
Copy link
Author

-Znext-solver=globally does work without an ICE but takes about 20s-30s to check the code.

@konnorandrews
Copy link
Author

Its possible this is a form of #105299 but the reproducer listed in that issue no longer causes an ICE and this generates a different error message in the ICE.

@theemathas

This comment has been minimized.

@theemathas

This comment has been minimized.

@theemathas

This comment has been minimized.

@matthiaskrgr
Copy link
Member

matthiaskrgr commented May 24, 2025

auto-reduced a bit futher 🤷

fn pretty_print<'r, T: ToProviderRef<'r>>() {
    request::<T::ProviderRef, Value>()
}
fn request<T, R: RequestWithArg<PeanoSucc<T>>>() -> R::Output {
    unimplemented!()
}
trait RequestWithArg<P> {
    type Output;
}
impl<P, T> RequestWithArg<P> for T
where
    P: Peano,
{
    type Output = ();
}
trait ToProviderRef<'r> {
    type ProviderRef: Peano;
}
struct Value;
trait Tagged {
    type Tag;
}
trait Unimplemented {}
impl<T: Unimplemented> Tagged for T {
    type Tag = ();
}
struct PeanoSucc<N>(N);
trait Peano: Tagged<Tag = LifetimeListTag<LenOf<Self>>> + SplitAt {}
impl<P: Tagged<Tag = LifetimeListTag<LenOf<P>>>> Peano for P {}
trait SplitAt: PeanoType<Len: Sized> {}
impl<P> SplitAt for P {}
struct Dummy;
trait PeanoType {
    type Len;
}
impl<P> PeanoType for P {
    type Len = Dummy;
}
type LenOf<P> = <P as PeanoType>::Len;
struct LifetimeListTag<N>(N);
impl<P, U> Tagged for PeanoSucc<P>
where
    P: Tagged<Tag = LifetimeListTag<U>>,
{
    type Tag = LifetimeListTag<Dummy>;
}

@moxian
Copy link
Contributor

moxian commented May 26, 2025

Bisection points to nightly-2024-02-11. PRs in range:
 - #120852 (Rollup of 11 pull requests) by matthiaskrgr
   - #120351 (Implement SystemTime for UEFI)
   - #120354 (improve normalization of `Pointee::Metadata`)
   - #120776 (Move path implementations into `sys`)
   - #120790 (better error message on download CI LLVM failure)
   - #120806 (Clippy subtree update)
   - #120815 (Improve `Option::inspect` docs)
   - #120822 (Emit more specific diagnostics when enums fail to cast with `as`)
   - #120827 (Print image input file and checksum in CI only)
   - #120836 (hide impls if trait bound is proven from env)
   - #120844 (Build DebugInfo for async closures)
   - #120851 (Remove duplicate release note)
 - #120862 (Rollup of 6 pull requests) by matthiaskrgr
   - #120584 (For a rigid projection, recursively look at the self type's item bounds to fix the `associated_type_bounds` feature)
   - #120596 ([rustdoc] Correctly generate path for non-local items in source code pages)
   - #120629 (Move some test files)
   - #120846 (Update jobserver-rs to 0.1.28)
   - #120850 (ast_lowering: Fix regression in `use ::{}` imports.)
   - #120853 (Avoid a collection and iteration on empty passes)
 - #120721 (fix `llvm_out` to use the correct LLVM root) by onur-ozkan
 - #120712 (Harmonize `AsyncFn` implementations, make async closures conditionally impl `Fn*` traits) by compiler-errors
 - #120771 (Use `ensure` when the result of the query is not needed beyond its `Result`ness) by oli-obk
 - #120877 (Rollup of 8 pull requests) by matthiaskrgr
   - #117614 (static mut: allow mutable reference to arbitrary types, not just slices and arrays)
   - #120719 (Remove support for `associated_type_bound` nested in `dyn` types)
   - #120764 (Add documentation on `str::starts_with`)
   - #120823 (Clarify that atomic and regular integers can differ in alignment)
   - #120859 (Loosen an assertion to account for stashed errors.)
   - #120865 (Turn the "no saved object file in work product" ICE into a translatable fatal error)
   - #120866 (Remove unnecessary `#![feature(min_specialization)]`)
   - #120870 (Allow restricted trait impls under `#[allow_internal_unstable(min_specialization)]`)
 - #119614 (unstably allow constants to refer to statics and read from immutable statics) by RalfJung

Sounds like one of the two associated_type_bounds PRs (#120584 or, perhaps less likely, #120719)

@cyrgani
Copy link
Contributor

cyrgani commented Jun 2, 2025

simpler:

fn pretty_print<'r, T: ToProviderRef<'r>>() {
    request::<T::ProviderRef, u8>()
}
fn request<T, R: RequestWithArg<PeanoSucc<T>>>() -> R::Output {
    unimplemented!()
}
trait RequestWithArg<P> {
    type Output;
}
impl<P, T> RequestWithArg<P> for T
where
    P: Tagged,
{
    type Output = ();
}
trait ToProviderRef<'r> {
    type ProviderRef: Tagged<Tag: Sized>;
}
trait Tagged {
    type Tag;
}
trait Unimplemented {}
impl<T: Unimplemented> Tagged for T {
    type Tag = ();
}
struct PeanoSucc<N>(N);
impl<P, U> Tagged for PeanoSucc<P>
where
    P: Tagged<Tag = U>,
{
    type Tag = ();
}

@cyrgani cyrgani added S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue S-has-bisection Status: A bisection has been found for this issue fixed-by-next-solver Fixed by the next-generation trait solver, `-Znext-solver`. labels Jun 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. fixed-by-next-solver Fixed by the next-generation trait solver, `-Znext-solver`. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. S-has-bisection Status: A bisection has been found for this issue S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

6 participants