-
-
Notifications
You must be signed in to change notification settings - Fork 14.3k
Closed as duplicate of#132519
Closed as duplicate of#132519
Copy link
Labels
C-bugCategory: This is a bug.Category: This is a bug.F-specialization`#![feature(specialization)]``#![feature(specialization)]`I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.This issue may need triage. Remove it if it has been sufficiently triaged.
Description
I found an ICE when fuzzing specialization combined with RPITIT (-> impl Sized).
It seems that when a where clause in a specializing impl refers to an unresolved type (name resolution failure), the compiler fails to recover gracefully and asserts during generic parameter translation in the specialization graph verification.
I tried this code:
#![feature(specialization)]
trait Base {
fn call(&self) -> impl Sized;
}
default impl<T> Base for T
where
T: Copy,
{
fn call(&self) -> T {
*self
}
}
#[derive(Copy, Clone)]
struct Item;
impl Base for Item
where
T: Base,
{}
fn main() {
Item.call();
}I expected to see this happen:
The compiler should emit error[E0425]: cannot find type T in this scope and exit gracefully (or continue analysis without crashing).
Instead, this happened:
The compiler panicked with an internal compiler error.
Meta
rustc --version --verbose:
rustc 1.94.0-nightly (e29fcf45e 2026-01-04)
binary: rustc
commit-hash: e29fcf45e4ae686d77b490bf07320f0d3a2cf35f
commit-date: 2026-01-04
host: x86_64-unknown-linux-gnu
release: 1.94.0-nightly
LLVM version: 21.1.8
Backtrace
thread 'rustc' panicked at /rustc-dev/e29fcf45e4ae686d77b490bf07320f0d3a2cf35f/compiler/rustc_trait_selection/src/traits/specialize/mod.rs:133:21:
Box<dyn Any>
stack backtrace:
0: 0x7fdf5a019c0b - <std[eaa43e369792efb9]::backtrace::Backtrace>::create
1: 0x7fdf5a019b55 - <std[eaa43e369792efb9]::backtrace::Backtrace>::force_capture
2: 0x7fdf590115b7 - std[eaa43e369792efb9]::panicking::update_hook::<alloc[83e7320d2ee5a6b1]::boxed::Box<rustc_driver_impl[5af842e777d449e6]::install_ice_hook::{closure#1}>>::{closure#0}
3: 0x7fdf5a02c4b2 - std[eaa43e369792efb9]::panicking::panic_with_hook
4: 0x7fdf5904de81 - std[eaa43e369792efb9]::panicking::begin_panic::<rustc_errors[3cfa44cd230a06eb]::ExplicitBug>::{closure#0}
5: 0x7fdf5903e4e6 - std[eaa43e369792efb9]::sys::backtrace::__rust_end_short_backtrace::<std[eaa43e369792efb9]::panicking::begin_panic<rustc_errors[3cfa44cd230a06eb]::ExplicitBug>::{closure#0}, !>
6: 0x7fdf5903e11c - std[eaa43e369792efb9]::panicking::begin_panic::<rustc_errors[3cfa44cd230a06eb]::ExplicitBug>
7: 0x7fdf5906bd21 - <rustc_errors[3cfa44cd230a06eb]::diagnostic::BugAbort as rustc_errors[3cfa44cd230a06eb]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
8: 0x7fdf59619ea9 - rustc_middle[829e5443847148d]::util::bug::opt_span_bug_fmt::<rustc_span[14443e5baae9ab13]::span_encoding::Span>::{closure#0}
9: 0x7fdf5961a032 - rustc_middle[829e5443847148d]::ty::context::tls::with_opt::<rustc_middle[829e5443847148d]::util::bug::opt_span_bug_fmt<rustc_span[14443e5baae9ab13]::span_encoding::Span>::{closure#0}, !>::{closure#0}
10: 0x7fdf5960b65b - rustc_middle[829e5443847148d]::ty::context::tls::with_context_opt::<rustc_middle[829e5443847148d]::ty::context::tls::with_opt<rustc_middle[829e5443847148d]::util::bug::opt_span_bug_fmt<rustc_span[14443e5baae9ab13]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
11: 0x7fdf57063aa4 - rustc_middle[829e5443847148d]::util::bug::bug_fmt
12: 0x7fdf5a897fcd - rustc_trait_selection[feb4a4f4d9146cdf]::traits::project::confirm_candidate
13: 0x7fdf5a877c8b - rustc_trait_selection[feb4a4f4d9146cdf]::traits::project::normalize_projection_term
14: 0x7fdf5a8758de - <rustc_trait_selection[feb4a4f4d9146cdf]::traits::normalize::AssocTypeNormalizer as rustc_type_ir[241df8ba430ad1e5]::fold::TypeFolder<rustc_middle[829e5443847148d]::ty::context::TyCtxt>>::fold_ty
15: 0x7fdf5a87131a - <rustc_type_ir[241df8ba430ad1e5]::ty_kind::FnSig<rustc_middle[829e5443847148d]::ty::context::TyCtxt> as rustc_type_ir[241df8ba430ad1e5]::fold::TypeFoldable<rustc_middle[829e5443847148d]::ty::context::TyCtxt>>::fold_with::<rustc_trait_selection[feb4a4f4d9146cdf]::traits::normalize::AssocTypeNormalizer>
16: 0x7fdf5ad52bb0 - <rustc_hir_typeck[d22ab1ec3d18caa2]::method::confirm::ConfirmContext>::confirm
17: 0x7fdf5aa073a7 - <rustc_hir_typeck[d22ab1ec3d18caa2]::fn_ctxt::FnCtxt>::check_expr_method_call
18: 0x7fdf5aa3cce5 - <rustc_hir_typeck[d22ab1ec3d18caa2]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
19: 0x7fdf5aa37e42 - <rustc_hir_typeck[d22ab1ec3d18caa2]::fn_ctxt::FnCtxt>::check_expr_block
20: 0x7fdf5aa3cd01 - <rustc_hir_typeck[d22ab1ec3d18caa2]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
21: 0x7fdf5aa1d405 - rustc_hir_typeck[d22ab1ec3d18caa2]::check::check_fn
22: 0x7fdf5b2f8973 - rustc_hir_typeck[d22ab1ec3d18caa2]::typeck_with_inspect::{closure#0}
23: 0x7fdf5b2f72f4 - rustc_query_impl[1b717c0605046cd0]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[1b717c0605046cd0]::query_impl::typeck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[829e5443847148d]::query::erase::Erased<[u8; 8usize]>>
24: 0x7fdf5a83e337 - rustc_query_system[5c35911b3dd767e9]::query::plumbing::try_execute_query::<rustc_query_impl[1b717c0605046cd0]::DynamicConfig<rustc_data_structures[4e9b1f6e439fd3ef]::vec_cache::VecCache<rustc_span[14443e5baae9ab13]::def_id::LocalDefId, rustc_middle[829e5443847148d]::query::erase::Erased<[u8; 8usize]>, rustc_query_system[5c35911b3dd767e9]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[1b717c0605046cd0]::plumbing::QueryCtxt, false>
25: 0x7fdf5a83dc09 - rustc_query_impl[1b717c0605046cd0]::query_impl::typeck::get_query_non_incr::__rust_end_short_backtrace
26: 0x7fdf5b070ead - <rustc_middle[829e5443847148d]::ty::context::TyCtxt>::par_hir_body_owners::<rustc_hir_analysis[37999fc34f267976]::check_crate::{closure#2}>::{closure#0}
27: 0x7fdf5b0708a1 - rustc_hir_analysis[37999fc34f267976]::check_crate
28: 0x7fdf5b54a19b - rustc_interface[eaf9095e0de5b742]::passes::analysis
29: 0x7fdf5b549df5 - rustc_query_impl[1b717c0605046cd0]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[1b717c0605046cd0]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[829e5443847148d]::query::erase::Erased<[u8; 0usize]>>
30: 0x7fdf5b7e57a6 - rustc_query_system[5c35911b3dd767e9]::query::plumbing::try_execute_query::<rustc_query_impl[1b717c0605046cd0]::DynamicConfig<rustc_query_system[5c35911b3dd767e9]::query::caches::SingleCache<rustc_middle[829e5443847148d]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[1b717c0605046cd0]::plumbing::QueryCtxt, false>
31: 0x7fdf5b7e5376 - rustc_query_impl[1b717c0605046cd0]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
32: 0x7fdf5b995cd1 - <rustc_interface[eaf9095e0de5b742]::passes::create_and_enter_global_ctxt<core[4141bff0bf9ca9dd]::option::Option<rustc_interface[eaf9095e0de5b742]::queries::Linker>, rustc_driver_impl[5af842e777d449e6]::run_compiler::{closure#0}::{closure#2}>::{closure#2} as core[4141bff0bf9ca9dd]::ops::function::FnOnce<(&rustc_session[ea1eec3ed26e42d5]::session::Session, rustc_middle[829e5443847148d]::ty::context::CurrentGcx, alloc[83e7320d2ee5a6b1]::sync::Arc<rustc_data_structures[4e9b1f6e439fd3ef]::jobserver::Proxy>, &std[eaa43e369792efb9]::sync::once_lock::OnceLock<rustc_middle[829e5443847148d]::ty::context::GlobalCtxt>, &rustc_data_structures[4e9b1f6e439fd3ef]::sync::worker_local::WorkerLocal<rustc_middle[829e5443847148d]::arena::Arena>, &rustc_data_structures[4e9b1f6e439fd3ef]::sync::worker_local::WorkerLocal<rustc_hir[67c6535075053fb5]::Arena>, rustc_driver_impl[5af842e777d449e6]::run_compiler::{closure#0}::{closure#2})>>::call_once::{shim:vtable#0}
33: 0x7fdf5b86e398 - rustc_interface[eaf9095e0de5b742]::interface::run_compiler::<(), rustc_driver_impl[5af842e777d449e6]::run_compiler::{closure#0}>::{closure#1}
34: 0x7fdf5b6f7e8e - std[eaa43e369792efb9]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[eaf9095e0de5b742]::util::run_in_thread_with_globals<rustc_interface[eaf9095e0de5b742]::util::run_in_thread_pool_with_globals<rustc_interface[eaf9095e0de5b742]::interface::run_compiler<(), rustc_driver_impl[5af842e777d449e6]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
35: 0x7fdf5b6f7c60 - <std[eaa43e369792efb9]::thread::lifecycle::spawn_unchecked<rustc_interface[eaf9095e0de5b742]::util::run_in_thread_with_globals<rustc_interface[eaf9095e0de5b742]::util::run_in_thread_pool_with_globals<rustc_interface[eaf9095e0de5b742]::interface::run_compiler<(), rustc_driver_impl[5af842e777d449e6]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[4141bff0bf9ca9dd]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
36: 0x7fdf5b6f6038 - <std[eaa43e369792efb9]::sys::thread::unix::Thread>::new::thread_start
37: 0x7fdf55094ac3 - start_thread
at ./nptl/pthread_create.c:442:8
38: 0x7fdf551268c0 - __GI___clone3
at ./misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:81:0
39: 0x0 - <unknown>
rustc version: 1.94.0-nightly (e29fcf45e 2026-01-04)
platform: x86_64-unknown-linux-gnu
query stack during panic:
#0 [typeck] type-checking `main`
#1 [analysis] running analysis passes on crate `after`
end of query stack
Metadata
Metadata
Assignees
Labels
C-bugCategory: This is a bug.Category: This is a bug.F-specialization`#![feature(specialization)]``#![feature(specialization)]`I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.This issue may need triage. Remove it if it has been sufficiently triaged.