Closed
Description
Code
struct Struct {}
trait Trait {}
impl<'a> Trait for &'a Struct {}
fn main() {
let value = Struct {};
fn func(arg: &Struct) -> &Struct { arg }
fn wrap<F: Fn(&Struct) -> Ret, Ret: Trait>(f: F) {}
wrap(func);
}
Meta
rustc --version --verbose
:
rustc 1.89.0-nightly (777d37277 2025-05-17)
binary: rustc
commit-hash: 777d372772aa3b39ba7273fcb8208a89f2ab0afd
commit-date: 2025-05-17
host: x86_64-unknown-linux-gnu
release: 1.89.0-nightly
LLVM version: 20.1.4
Error output
error: internal compiler error: compiler/rustc_trait_selection/src/solve/select.rs:185:13: didn't expect to assemble trait candidate from Root {
result: Ok(
Canonical {
value: Response {
certainty: Yes,
var_values: CanonicalVarValues {
var_values: [],
},
external_constraints: ExternalConstraints(
ExternalConstraintsData {
region_constraints: [],
opaque_types: [],
normalization_nested_goals: NestedNormalizationGoals(
[],
),
},
),
},
max_universe: U0,
variables: [],
},
),
}
--> <source>:12:10
|
12 | wrap(func);
| ^^^^
Backtrace
thread 'rustc' panicked at compiler/rustc_trait_selection/src/solve/select.rs:185:13:
Box<dyn Any>
stack backtrace:
0: 0x78025376f063 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::ha391d80b5e68e919
1: 0x780253e05977 - core::fmt::write::h1cecefcb305d1155
2: 0x780254ed00d1 - std::io::Write::write_fmt::h41ef61269065dc96
3: 0x78025376eec2 - std::sys::backtrace::BacktraceLock::print::h5ae784575c381c12
4: 0x780253772aba - std::panicking::default_hook::{{closure}}::h72fa7b5ed73b3cb2
5: 0x78025377263f - std::panicking::default_hook::he27598d97fb5e6bc
6: 0x78025279dbb3 - std[13072b276e939a5d]::panicking::update_hook::<alloc[cdfabe42c5865433]::boxed::Box<rustc_driver_impl[b40d209f1534a115]::install_ice_hook::{closure#1}>>::{closure#0}
7: 0x780253773333 - std::panicking::rust_panic_with_hook::h0e25468a64f50749
8: 0x7802527da011 - std[13072b276e939a5d]::panicking::begin_panic::<rustc_errors[e76d1cc800a3cd8b]::ExplicitBug>::{closure#0}
9: 0x7802527cdee6 - std[13072b276e939a5d]::sys::backtrace::__rust_end_short_backtrace::<std[13072b276e939a5d]::panicking::begin_panic<rustc_errors[e76d1cc800a3cd8b]::ExplicitBug>::{closure#0}, !>
10: 0x7802527ca5f9 - std[13072b276e939a5d]::panicking::begin_panic::<rustc_errors[e76d1cc800a3cd8b]::ExplicitBug>
11: 0x7802527e4661 - <rustc_errors[e76d1cc800a3cd8b]::diagnostic::BugAbort as rustc_errors[e76d1cc800a3cd8b]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
12: 0x780252db646c - <rustc_errors[e76d1cc800a3cd8b]::DiagCtxtHandle>::span_bug::<rustc_span[fc860b16118515f6]::span_encoding::Span, alloc[cdfabe42c5865433]::string::String>
13: 0x780252e535b7 - rustc_middle[e21e39dd30abbfc2]::util::bug::opt_span_bug_fmt::<rustc_span[fc860b16118515f6]::span_encoding::Span>::{closure#0}
14: 0x780252e2cdea - rustc_middle[e21e39dd30abbfc2]::ty::context::tls::with_opt::<rustc_middle[e21e39dd30abbfc2]::util::bug::opt_span_bug_fmt<rustc_span[fc860b16118515f6]::span_encoding::Span>::{closure#0}, !>::{closure#0}
15: 0x780252e2cc5b - rustc_middle[e21e39dd30abbfc2]::ty::context::tls::with_context_opt::<rustc_middle[e21e39dd30abbfc2]::ty::context::tls::with_opt<rustc_middle[e21e39dd30abbfc2]::util::bug::opt_span_bug_fmt<rustc_span[fc860b16118515f6]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
16: 0x7802518ff787 - rustc_middle[e21e39dd30abbfc2]::util::bug::span_bug_fmt::<rustc_span[fc860b16118515f6]::span_encoding::Span>
17: 0x7802535f62d8 - rustc_trait_selection[f9a05ecbd46dce9e]::solve::select::to_selection
18: 0x7802535f57d4 - <rustc_trait_selection[f9a05ecbd46dce9e]::solve::select::Select as rustc_trait_selection[f9a05ecbd46dce9e]::solve::inspect::analyse::ProofTreeVisitor>::visit_goal
19: 0x78025362dc22 - <rustc_infer[203a4dcd60087c62]::infer::InferCtxt as rustc_trait_selection[f9a05ecbd46dce9e]::solve::select::InferCtxtSelectExt>::select_in_new_trait_solver
20: 0x7802535e58ed - <rustc_trait_selection[f9a05ecbd46dce9e]::error_reporting::TypeErrCtxt>::report_fulfillment_errors
21: 0x7802540ca9bc - <rustc_hir_typeck[f50ac000c2ae270]::fn_ctxt::FnCtxt>::check_expr_call
22: 0x780254c95def - <rustc_hir_typeck[f50ac000c2ae270]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
23: 0x780250545d83 - <rustc_hir_typeck[f50ac000c2ae270]::fn_ctxt::FnCtxt>::check_expr_block
24: 0x780254c968e7 - <rustc_hir_typeck[f50ac000c2ae270]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
25: 0x7802543f07e5 - rustc_hir_typeck[f50ac000c2ae270]::check::check_fn
26: 0x7802543db351 - rustc_hir_typeck[f50ac000c2ae270]::typeck_with_inspect::{closure#0}
27: 0x7802543da036 - rustc_query_impl[da4220149538f346]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[da4220149538f346]::query_impl::typeck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[e21e39dd30abbfc2]::query::erase::Erased<[u8; 8usize]>>
28: 0x7802540ed426 - rustc_query_system[83aca0075238f65e]::query::plumbing::try_execute_query::<rustc_query_impl[da4220149538f346]::DynamicConfig<rustc_data_structures[548a2e6de72614fc]::vec_cache::VecCache<rustc_span[fc860b16118515f6]::def_id::LocalDefId, rustc_middle[e21e39dd30abbfc2]::query::erase::Erased<[u8; 8usize]>, rustc_query_system[83aca0075238f65e]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[da4220149538f346]::plumbing::QueryCtxt, false>
29: 0x7802540ece92 - rustc_query_impl[da4220149538f346]::query_impl::typeck::get_query_non_incr::__rust_end_short_backtrace
30: 0x7802540eb6c9 - rustc_hir_analysis[ab2364e84e94296d]::check_crate
31: 0x7802542c1bc5 - rustc_interface[e200ad1770586edd]::passes::run_required_analyses
32: 0x780254d7371e - rustc_interface[e200ad1770586edd]::passes::analysis
33: 0x780254d736f5 - rustc_query_impl[da4220149538f346]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[da4220149538f346]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[e21e39dd30abbfc2]::query::erase::Erased<[u8; 0usize]>>
34: 0x780254d757fa - rustc_query_system[83aca0075238f65e]::query::plumbing::try_execute_query::<rustc_query_impl[da4220149538f346]::DynamicConfig<rustc_query_system[83aca0075238f65e]::query::caches::SingleCache<rustc_middle[e21e39dd30abbfc2]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[da4220149538f346]::plumbing::QueryCtxt, false>
35: 0x780254d754cf - rustc_query_impl[da4220149538f346]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
36: 0x780255071587 - rustc_interface[e200ad1770586edd]::passes::create_and_enter_global_ctxt::<core[ce55df5acd2c727e]::option::Option<rustc_interface[e200ad1770586edd]::queries::Linker>, rustc_driver_impl[b40d209f1534a115]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
37: 0x780254f12ca6 - rustc_interface[e200ad1770586edd]::interface::run_compiler::<(), rustc_driver_impl[b40d209f1534a115]::run_compiler::{closure#0}>::{closure#1}
38: 0x780254ec6d7e - std[13072b276e939a5d]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[e200ad1770586edd]::util::run_in_thread_with_globals<rustc_interface[e200ad1770586edd]::util::run_in_thread_pool_with_globals<rustc_interface[e200ad1770586edd]::interface::run_compiler<(), rustc_driver_impl[b40d209f1534a115]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
39: 0x780254ec71eb - <<std[13072b276e939a5d]::thread::Builder>::spawn_unchecked_<rustc_interface[e200ad1770586edd]::util::run_in_thread_with_globals<rustc_interface[e200ad1770586edd]::util::run_in_thread_pool_with_globals<rustc_interface[e200ad1770586edd]::interface::run_compiler<(), rustc_driver_impl[b40d209f1534a115]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[ce55df5acd2c727e]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
40: 0x780254ec85eb - std::sys::pal::unix::thread::Thread::new::thread_start::h705253a14e119c3f
41: 0x78024ea94ac3 - <unknown>
42: 0x78024eb26850 - <unknown>
43: 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: please attach the file at `/app/rustc-ice-2025-05-21T06_59_45-1.txt` to your bug report
note: compiler flags: -C debuginfo=2 -C llvm-args=--x86-asm-syntax=intel --crate-type rlib -Z next-solver
query stack during panic:
#0 [typeck] type-checking `main`
#1 [analysis] running analysis passes on this crate
end of query stack
Metadata
Metadata
Assignees
Labels
Area: Trait systemCategory: This is a bug.Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Relevant to the compiler team, which will review and decide on the PR/issue.Relevant to the types team, which will review and decide on the PR/issue.The Rustc Trait System Refactor Initiative (-Znext-solver)This issue requires a nightly compiler in some way.