Repository navigation
[ICE]: did not expect successful goal when collecting ambiguity errors for #161669
Copy link
Copy link
Closed
Closed
Copy link
Labels
C-bugCategory: This is a bug.Category: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.WG-trait-system-refactorThe Rustc Trait System Refactor Initiative (-Znext-solver)The Rustc Trait System Refactor Initiative (-Znext-solver)
Description
snippet:
//@compile-flags: --edition=2024
trait MyTrait {}
struct D;
impl<'de> DeserTrait<'de> for &'de DeserStruct {}
trait DeserTrait<'DeserStruct> {}
struct DeserStruct;
impl<'de> DeserTrait<'de> for &'static MyTrait {}
fn test() -> impl Send {
let deserializer = DeserStruct;
let graph = testfn(&deserializer);
graph
}
pub fn testfn<'de, D: DeserTrait<'de>>(_deserializer: D) -> impl MyTrait + 'static {
MyStruct
}Version information
rustc 1.100.0-nightly (347a1dbf4 2026-08-24)
binary: rustc
commit-hash: 347a1dbf428ab92f284e3afafacfa7eb46341a5d
commit-date: 2026-08-24
host: x86_64-unknown-linux-gnu
release: 1.100.0-nightly
LLVM version: 23.1.0
Possibly related line of code:
rust/compiler/rustc_trait_selection/src/solve/fulfill/derive_errors.rs
Lines 118 to 130 in 347a1db
| // inference guidance that makes other goals go from ambig -> pass, for example. | |
| // | |
| // FIXME: We should probably just look into overflows here. | |
| false, | |
| ), | |
| Ok(GoalEvaluation { certainty: Certainty::Yes, .. }) => { | |
| span_bug!( | |
| root_obligation.cause.span, | |
| "did not expect successful goal when collecting ambiguity errors for `{:?}`", | |
| infcx.resolve_vars_if_possible(root_obligation.predicate), | |
| ) | |
| } | |
| Err(_) => { |
Command:
/home/matthias/.rustup/toolchains/master/bin/rustc --edition=2024
Program output
error[E0425]: cannot find value `MyStruct` in this scope
--> /tmp/icemaker_global_tempdir.gylpnR9gPvzU/rustc_testrunner_tmpdir_reporting.3NNlYTxae64C/mvce.rs:16:5
|
16 | MyStruct
| ^^^^^^^^ not found in this scope
error[E0601]: `main` function not found in crate `mvce`
--> /tmp/icemaker_global_tempdir.gylpnR9gPvzU/rustc_testrunner_tmpdir_reporting.3NNlYTxae64C/mvce.rs:17:2
|
17 | }
| ^ consider adding a `main` function to `/tmp/icemaker_global_tempdir.gylpnR9gPvzU/rustc_testrunner_tmpdir_reporting.3NNlYTxae64C/mvce.rs`
error[E0782]: expected a type, found a trait
--> /tmp/icemaker_global_tempdir.gylpnR9gPvzU/rustc_testrunner_tmpdir_reporting.3NNlYTxae64C/mvce.rs:7:40
|
7 | impl<'de> DeserTrait<'de> for &'static MyTrait {}
| ^^^^^^^
|
help: you can add the `dyn` keyword if you want a trait object
|
7 | impl<'de> DeserTrait<'de> for &'static dyn MyTrait {}
| +++
error: internal compiler error: /rustc-dev/347a1dbf428ab92f284e3afafacfa7eb46341a5d/compiler/rustc_trait_selection/src/solve/fulfill/derive_errors.rs:124:17: did not expect successful goal when collecting ambiguity errors for `Binder { value: ProjectionClause(Alias { kind: OpaqueTy { def_id: DefId(0:15 ~ mvce[d1ce]::test::{opaque#0}) }, args: [], .. }, Term::Ty(Alias(Yes, Alias { kind: Opaque { def_id: DefId(0:19 ~ mvce[d1ce]::testfn::{opaque#0}) }, args: ['?4, &'?2 DeserStruct, '?0], .. }))), bound_vars: [] }`
--> /tmp/icemaker_global_tempdir.gylpnR9gPvzU/rustc_testrunner_tmpdir_reporting.3NNlYTxae64C/mvce.rs:9:14
|
9 | fn test() -> impl Send {
| ^^^^^^^^^
thread 'rustc' (1293205) panicked at /rustc-dev/347a1dbf428ab92f284e3afafacfa7eb46341a5d/compiler/rustc_trait_selection/src/solve/fulfill/derive_errors.rs:124:17:
Box<dyn Any>
stack backtrace:
0: 0x7f8092c0cea6 - <<std[9230f834c194ccdf]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[4eb08f46c2e819d3]::fmt::Display>::fmt
1: 0x7f809320bdcf - core[4eb08f46c2e819d3]::fmt::write
2: 0x7f8092c2211c - <std[9230f834c194ccdf]::sys::stdio::unix::Stderr as core[4eb08f46c2e819d3]::io::write::Write>::write_fmt
3: 0x7f8092be027a - std[9230f834c194ccdf]::panicking::default_hook::{closure#0}
4: 0x7f8092c01103 - std[9230f834c194ccdf]::panicking::default_hook
5: 0x7f8091bb2aaf - std[9230f834c194ccdf]::panicking::update_hook::<alloc[55cb97d1958a6aa2]::boxed::Box<rustc_driver_impl[bc520c4b5b23925f]::install_ice_hook::{closure#1}>>::{closure#0}
6: 0x7f8092c015a2 - std[9230f834c194ccdf]::panicking::panic_with_hook
7: 0x7f8091be1024 - std[9230f834c194ccdf]::panicking::begin_panic::<rustc_errors[15685f120c8ae9c5]::ExplicitBug>::{closure#0}
8: 0x7f8091bd9d76 - std[9230f834c194ccdf]::sys::backtrace::__rust_end_short_backtrace::<std[9230f834c194ccdf]::panicking::begin_panic<rustc_errors[15685f120c8ae9c5]::ExplicitBug>::{closure#0}, !>
9: 0x7f8091bd9aab - std[9230f834c194ccdf]::panicking::begin_panic::<rustc_errors[15685f120c8ae9c5]::ExplicitBug>
10: 0x7f8091beca71 - <rustc_errors[15685f120c8ae9c5]::diagnostic::BugAbort as rustc_errors[15685f120c8ae9c5]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
11: 0x7f809212b98c - <rustc_errors[15685f120c8ae9c5]::DiagCtxtHandle>::span_bug::<rustc_span[e39204562324ff34]::span_encoding::Span, alloc[55cb97d1958a6aa2]::string::String>
12: 0x7f8092158e66 - rustc_middle[c236f446234024]::util::bug::opt_span_bug_fmt::<rustc_span[e39204562324ff34]::span_encoding::Span>::{closure#0}
13: 0x7f8092159282 - rustc_middle[c236f446234024]::ty::context::tls::with_opt::<rustc_middle[c236f446234024]::util::bug::opt_span_bug_fmt<rustc_span[e39204562324ff34]::span_encoding::Span>::{closure#0}, !>::{closure#0}
14: 0x7f80921448b0 - rustc_middle[c236f446234024]::ty::context::tls::with_context_opt::<rustc_middle[c236f446234024]::ty::context::tls::with_opt<rustc_middle[c236f446234024]::util::bug::opt_span_bug_fmt<rustc_span[e39204562324ff34]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
15: 0x7f808f089268 - rustc_middle[c236f446234024]::util::bug::span_bug_fmt::<rustc_span[e39204562324ff34]::span_encoding::Span>
16: 0x7f80943f71c4 - <rustc_trait_selection[c1480eec3b03e870]::traits::FulfillmentError as rustc_infer[7d238bc1b973467a]::traits::engine::FromSolverError<rustc_trait_selection[c1480eec3b03e870]::solve::fulfill::NextSolverError>>::from_solver_error
17: 0x7f80943f5995 - <core[4eb08f46c2e819d3]::iter::adapters::map::Map<core[4eb08f46c2e819d3]::iter::adapters::chain::Chain<core[4eb08f46c2e819d3]::iter::adapters::map::Map<thin_vec[a87c3356013a0ff2]::Drain<(rustc_infer[7d238bc1b973467a]::traits::Obligation<rustc_middle[c236f446234024]::ty::predicate::Predicate>, core[4eb08f46c2e819d3]::option::Option<rustc_type_ir[b40821e6cb839fb2]::solve::GoalStalledOn<rustc_middle[c236f446234024]::ty::context::TyCtxt>>)>, rustc_trait_selection[c1480eec3b03e870]::solve::fulfill::collect_remaining_errors_impl<rustc_trait_selection[c1480eec3b03e870]::traits::FulfillmentError>::{closure#0}>, core[4eb08f46c2e819d3]::iter::adapters::map::Map<alloc[55cb97d1958a6aa2]::vec::drain::Drain<rustc_infer[7d238bc1b973467a]::traits::Obligation<rustc_middle[c236f446234024]::ty::predicate::Predicate>>, rustc_trait_selection[c1480eec3b03e870]::solve::fulfill::collect_remaining_errors_impl<rustc_trait_selection[c1480eec3b03e870]::traits::FulfillmentError>::{closure#1}>>, rustc_trait_selection[c1480eec3b03e870]::solve::fulfill::collect_remaining_errors_impl<rustc_trait_selection[c1480eec3b03e870]::traits::FulfillmentError>::{closure#2}> as core[4eb08f46c2e819d3]::iter::traits::iterator::Iterator>::next
18: 0x7f80943f566f - rustc_trait_selection[c1480eec3b03e870]::solve::fulfill::collect_remaining_errors_impl::<rustc_trait_selection[c1480eec3b03e870]::traits::FulfillmentError>
19: 0x7f8093ffc181 - rustc_hir_typeck[aa98e27d71a07d05]::typeck_with_inspect::{closure#0}
20: 0x7f8093fee2f0 - rustc_query_impl[dcec05902d583e42]::query_vtables::typeck_root::invoke_provider_fn::__rust_begin_short_backtrace
21: 0x7f8093fca975 - rustc_query_impl[dcec05902d583e42]::execution::try_execute_query::<rustc_data_structures[fb83bf40da15a652]::vec_cache::VecCache<rustc_span[e39204562324ff34]::def_id::LocalDefId, rustc_middle[c236f446234024]::query::erase::ErasedData<[u8; 8usize]>, rustc_middle[c236f446234024]::dep_graph::graph::DepNodeIndex>, false>
22: 0x7f8093fca5e7 - rustc_query_impl[dcec05902d583e42]::query_vtables::typeck_root::execute_query_non_incr::__rust_end_short_backtrace
23: 0x7f8093ef6c93 - rustc_mir_build[b681dc2ffd80ac32]::thir::pattern::check_match::check_match
24: 0x7f8093ef5dbd - rustc_query_impl[dcec05902d583e42]::query_vtables::check_match::invoke_provider_fn::__rust_begin_short_backtrace
25: 0x7f8093f1c35f - rustc_query_impl[dcec05902d583e42]::execution::try_execute_query::<rustc_data_structures[fb83bf40da15a652]::vec_cache::VecCache<rustc_span[e39204562324ff34]::def_id::LocalDefId, rustc_middle[c236f446234024]::query::erase::ErasedData<[u8; 1usize]>, rustc_middle[c236f446234024]::dep_graph::graph::DepNodeIndex>, false>
26: 0x7f8093f1c0d5 - rustc_query_impl[dcec05902d583e42]::query_vtables::check_match::execute_query_non_incr::__rust_end_short_backtrace
27: 0x7f8093d01866 - rustc_mir_build[b681dc2ffd80ac32]::builder::build_mir_inner_impl
28: 0x7f8093233e74 - rustc_mir_transform[cfc0ec162cbc1f8d]::mir_built
29: 0x7f8093fca975 - rustc_query_impl[dcec05902d583e42]::execution::try_execute_query::<rustc_data_structures[fb83bf40da15a652]::vec_cache::VecCache<rustc_span[e39204562324ff34]::def_id::LocalDefId, rustc_middle[c236f446234024]::query::erase::ErasedData<[u8; 8usize]>, rustc_middle[c236f446234024]::dep_graph::graph::DepNodeIndex>, false>
30: 0x7f8093fca667 - rustc_query_impl[dcec05902d583e42]::query_vtables::mir_built::execute_query_non_incr::__rust_end_short_backtrace
31: 0x7f809322652b - rustc_mir_transform[cfc0ec162cbc1f8d]::ffi_unwind_calls::has_ffi_unwind_calls
32: 0x7f8093225eed - rustc_query_impl[dcec05902d583e42]::query_vtables::has_ffi_unwind_calls::invoke_provider_fn::__rust_begin_short_backtrace
33: 0x7f8093f1c35f - rustc_query_impl[dcec05902d583e42]::execution::try_execute_query::<rustc_data_structures[fb83bf40da15a652]::vec_cache::VecCache<rustc_span[e39204562324ff34]::def_id::LocalDefId, rustc_middle[c236f446234024]::query::erase::ErasedData<[u8; 1usize]>, rustc_middle[c236f446234024]::dep_graph::graph::DepNodeIndex>, false>
34: 0x7f8093f1c095 - rustc_query_impl[dcec05902d583e42]::query_vtables::has_ffi_unwind_calls::execute_query_non_incr::__rust_end_short_backtrace
35: 0x7f8093b91891 - rustc_mir_transform[cfc0ec162cbc1f8d]::mir_promoted
36: 0x7f8093b91712 - rustc_query_impl[dcec05902d583e42]::query_vtables::mir_promoted::invoke_provider_fn::__rust_begin_short_backtrace
37: 0x7f80938fe403 - rustc_query_impl[dcec05902d583e42]::execution::try_execute_query::<rustc_data_structures[fb83bf40da15a652]::vec_cache::VecCache<rustc_span[e39204562324ff34]::def_id::LocalDefId, rustc_middle[c236f446234024]::query::erase::ErasedData<[u8; 16usize]>, rustc_middle[c236f446234024]::dep_graph::graph::DepNodeIndex>, false>
38: 0x7f80938fdd67 - rustc_query_impl[dcec05902d583e42]::query_vtables::mir_promoted::execute_query_non_incr::__rust_end_short_backtrace
39: 0x7f80944b6151 - rustc_borrowck[346cca818372af1]::mir_borrowck
40: 0x7f80944b5f99 - rustc_query_impl[dcec05902d583e42]::query_vtables::mir_borrowck::invoke_provider_fn::__rust_begin_short_backtrace
41: 0x7f8093fca975 - rustc_query_impl[dcec05902d583e42]::execution::try_execute_query::<rustc_data_structures[fb83bf40da15a652]::vec_cache::VecCache<rustc_span[e39204562324ff34]::def_id::LocalDefId, rustc_middle[c236f446234024]::query::erase::ErasedData<[u8; 8usize]>, rustc_middle[c236f446234024]::dep_graph::graph::DepNodeIndex>, false>
42: 0x7f8093fca4e7 - rustc_query_impl[dcec05902d583e42]::query_vtables::mir_borrowck::execute_query_non_incr::__rust_end_short_backtrace
43: 0x7f80946151bd - rustc_hir_analysis[c40ba00d12ac69e2]::collect::type_of::opaque::find_opaque_ty_constraints_for_rpit
44: 0x7f8094614e82 - rustc_hir_analysis[c40ba00d12ac69e2]::collect::type_of::type_of_opaque
45: 0x7f8093272cfd - rustc_query_impl[dcec05902d583e42]::execution::try_execute_query::<rustc_middle[c236f446234024]::query::caches::DefIdCache<rustc_middle[c236f446234024]::query::erase::ErasedData<[u8; 8usize]>>, false>
46: 0x7f8093737600 - rustc_query_impl[dcec05902d583e42]::query_vtables::type_of_opaque::execute_query_non_incr::__rust_end_short_backtrace
47: 0x7f809373b6f8 - rustc_hir_analysis[c40ba00d12ac69e2]::collect::type_of::type_of
48: 0x7f8093744926 - rustc_query_impl[dcec05902d583e42]::query_vtables::type_of::invoke_provider_fn::__rust_begin_short_backtrace
49: 0x7f8093272cfd - rustc_query_impl[dcec05902d583e42]::execution::try_execute_query::<rustc_middle[c236f446234024]::query::caches::DefIdCache<rustc_middle[c236f446234024]::query::erase::ErasedData<[u8; 8usize]>>, false>
50: 0x7f80932729a3 - rustc_query_impl[dcec05902d583e42]::query_vtables::type_of::execute_query_non_incr::__rust_end_short_backtrace
51: 0x7f80946156d1 - rustc_hir_analysis[c40ba00d12ac69e2]::check::check::check_opaque
52: 0x7f8093f26069 - rustc_hir_analysis[c40ba00d12ac69e2]::check::check::check_item_type
53: 0x7f8093f1cd26 - rustc_hir_analysis[c40ba00d12ac69e2]::check::wfcheck::check_well_formed
54: 0x7f8093f1cd07 - rustc_query_impl[dcec05902d583e42]::query_vtables::check_well_formed::invoke_provider_fn::__rust_begin_short_backtrace
55: 0x7f8093f1c35f - rustc_query_impl[dcec05902d583e42]::execution::try_execute_query::<rustc_data_structures[fb83bf40da15a652]::vec_cache::VecCache<rustc_span[e39204562324ff34]::def_id::LocalDefId, rustc_middle[c236f446234024]::query::erase::ErasedData<[u8; 1usize]>, rustc_middle[c236f446234024]::dep_graph::graph::DepNodeIndex>, false>
56: 0x7f8093f1c0f1 - rustc_query_impl[dcec05902d583e42]::query_vtables::check_well_formed::execute_query_non_incr::__rust_end_short_backtrace
57: 0x7f8093f118b8 - <rustc_middle[c236f446234024]::hir::ModuleItems>::par_opaques::<rustc_hir_analysis[c40ba00d12ac69e2]::check::wfcheck::check_type_wf::{closure#5}>
58: 0x7f8093f1a41a - rustc_hir_analysis[c40ba00d12ac69e2]::check::wfcheck::check_type_wf
59: 0x7f8093f19377 - rustc_query_impl[dcec05902d583e42]::query_vtables::check_type_wf::invoke_provider_fn::__rust_begin_short_backtrace
60: 0x7f80943a0749 - rustc_query_impl[dcec05902d583e42]::execution::try_execute_query::<rustc_middle[c236f446234024]::query::caches::SingleCache<rustc_middle[c236f446234024]::query::erase::ErasedData<[u8; 1usize]>>, false>
61: 0x7f80943a052d - rustc_query_impl[dcec05902d583e42]::query_vtables::check_type_wf::execute_query_non_incr::__rust_end_short_backtrace
62: 0x7f8093a98164 - rustc_hir_analysis[c40ba00d12ac69e2]::check_crate
63: 0x7f8093fcbeba - rustc_interface[f5a0feaa47580fd8]::passes::analysis
64: 0x7f80943a204a - rustc_query_impl[dcec05902d583e42]::execution::try_execute_query::<rustc_middle[c236f446234024]::query::caches::SingleCache<rustc_middle[c236f446234024]::query::erase::ErasedData<[u8; 0usize]>>, false>
65: 0x7f80943a1deb - rustc_query_impl[dcec05902d583e42]::query_vtables::analysis::execute_query_non_incr::__rust_end_short_backtrace
66: 0x7f809451692e - rustc_interface[f5a0feaa47580fd8]::interface::run_compiler::<(), rustc_driver_impl[bc520c4b5b23925f]::run_compiler::{closure#0}>::{closure#2}
67: 0x7f8094564882 - std[9230f834c194ccdf]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[f5a0feaa47580fd8]::util::run_in_thread_with_globals<rustc_interface[f5a0feaa47580fd8]::util::run_in_thread_pool_with_globals<rustc_interface[f5a0feaa47580fd8]::interface::run_compiler<(), rustc_driver_impl[bc520c4b5b23925f]::run_compiler::{closure#0}>::{closure#2}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
68: 0x7f809456462d - <std[9230f834c194ccdf]::thread::lifecycle::spawn_unchecked<rustc_interface[f5a0feaa47580fd8]::util::run_in_thread_with_globals<rustc_interface[f5a0feaa47580fd8]::util::run_in_thread_pool_with_globals<rustc_interface[f5a0feaa47580fd8]::interface::run_compiler<(), rustc_driver_impl[bc520c4b5b23925f]::run_compiler::{closure#0}>::{closure#2}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[4eb08f46c2e819d3]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
69: 0x7f809456219d - <std[9230f834c194ccdf]::sys::thread::unix::Thread>::new::thread_start
70: 0x7f808d897739 - <unknown>
71: 0x7f808d91bedc - <unknown>
72: 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.100.0-nightly (347a1dbf4 2026-08-24) running on x86_64-unknown-linux-gnu
note: compiler flags: -Z dump-mir-dir=dir
query stack during panic:
#0 [typeck_root] type-checking `test`
#1 [check_match] match-checking `test`
#2 [mir_built] building MIR for `test`
#3 [has_ffi_unwind_calls] checking if `test` contains FFI-unwind calls
#4 [mir_promoted] promoting constants in MIR for `test`
#5 [mir_borrowck] borrow-checking `test`
#6 [type_of_opaque] computing type of opaque `test::{opaque#0}`
#7 [type_of] computing type of `test::{opaque#0}`
#8 [check_well_formed] checking that `test::{opaque#0}` is well-formed
#9 [check_type_wf] checking that types are well-formed
#10 [analysis] running analysis passes on crate `mvce`
end of query stack
error: aborting due to 4 previous errors
Some errors have detailed explanations: E0425, E0601, E0782.
For more information about an error, try `rustc --explain E0425`.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
C-bugCategory: This is a bug.Category: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.WG-trait-system-refactorThe Rustc Trait System Refactor Initiative (-Znext-solver)The Rustc Trait System Refactor Initiative (-Znext-solver)
Activity
matthiaskrgr commentedon Aug 24, 2026
adding in the
dynfixes the ICE and makes it compilematthiaskrgr commentedon Aug 24, 2026
bit smaller
matthiaskrgr commentedon Aug 24, 2026
on beta this compiles on edition 2015, 2018, errors on 21, 24
on nightly this compiles with 2015, 2018 and errors + ICEs on 2021, 2024
Rollup merge of rust-lang#162182 - amirHdev:skip-stale-stalled-obliga…
Unrolled build for #162182 in rollup 162406
Rollup merge of #162182 - amirHdev:skip-stale-stalled-obligations, r=…