Open
Description
auto-reduced (treereduce-rust):
#![feature(specialization)]
trait Spec {
type Assoc;
}
default impl<T, U> Spec for T
where
T: IntoIterator<Item = U>,
{
type Assoc = U;
}
impl<T> Spec for [T; 0] {}
fn main() {
let x: <[_; 0] as Spec>::Assoc = 1;
}
original:
//@ revisions: current next
//@ ignore-compare-mode-next-solver (explicit revisions)
//@[next] compile-flags: -Znext-solver
//@[next] check-pass
//@[current] known-bug: unknown
//@[current] failure-status: 101
//~^ ERROR defaults for generic parameters are not allowed in `for<...>` binders
// Tests that rebasing from the concrete impl to the default impl also processes the
// `[u32; 0]: IntoIterator<Item = ?U>` predicate to constrain the `?U` impl arg.
// This test also makes sure that we don't do anything weird when rebasing the args
// is ambiguous.
#![feature(specialization)]
//[next]~^ WARN the feature `specialization` is incomplete
trait Spec {
type Assoc;
}
default impl<T, U> Spec for T where T: IntoIterator<Item = U> {
type Assoc = U;
}
impl<T> Spec for [T; 0] {}
fn main() {
let x: <[_; 0] as Spec>::Assoc = 1;
}
Version information
rustc 1.84.0-nightly (ef972a346 2024-11-02)
binary: rustc
commit-hash: ef972a346668ed4234d1a43ed4ad7ca4e9c58d51
commit-date: 2024-11-02
host: x86_64-unknown-linux-gnu
release: 1.84.0-nightly
LLVM version: 19.1.1
Possibly related line of code:
rust/compiler/rustc_trait_selection/src/traits/specialize/mod.rs
Lines 121 to 133 in ef972a3
Command:
/home/matthias/.rustup/toolchains/master/bin/rustc
Program output
warning: the feature `specialization` is incomplete and may not be safe to use and/or cause compiler crashes
--> /tmp/icemaker_global_tempdir.jxbDO1GMyC8v/rustc_testrunner_tmpdir_reporting.X0a6Q55Ph3Zn/mvce.rs:1:12
|
1 | #![feature(specialization)]
| ^^^^^^^^^^^^^^
|
= note: see issue #31844 <https://github.com/rust-lang/rust/issues/31844> for more information
= help: consider using `min_specialization` instead, which is more stable and complete
= note: `#[warn(incomplete_features)]` on by default
error: internal compiler error: compiler/rustc_trait_selection/src/traits/specialize/mod.rs:127:21: When translating generic parameters from DefId(0:9 ~ mvce[4f49]::{impl#1}) to DefId(0:5 ~ mvce[4f49]::{impl#0}), the expected specialization failed to hold
thread 'rustc' panicked at compiler/rustc_trait_selection/src/traits/specialize/mod.rs:127:21:
Box<dyn Any>
stack backtrace:
0: 0x7737134584aa - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::hce429173f4835cf6
1: 0x773713c040ca - core::fmt::write::hd474fbdfe63c8008
2: 0x77371507b011 - std::io::Write::write_fmt::ha6b1be51a74d6c82
3: 0x773713458302 - std::sys::backtrace::BacktraceLock::print::h9a37e75f7192ac21
4: 0x77371345a806 - std::panicking::default_hook::{{closure}}::hd9ac8cf20a0b7897
5: 0x77371345a650 - std::panicking::default_hook::hdde16dcfa738c4aa
6: 0x7737124ddb49 - std[85c38ff02e03f0e6]::panicking::update_hook::<alloc[39d8aefd6e9d2d6]::boxed::Box<rustc_driver_impl[8ea1370c87ac4c52]::install_ice_hook::{closure#0}>>::{closure#0}
7: 0x77371345af18 - std::panicking::rust_panic_with_hook::h6eef9cc88a2d4e79
8: 0x773712517231 - std[85c38ff02e03f0e6]::panicking::begin_panic::<rustc_errors[a3358f633eebb703]::ExplicitBug>::{closure#0}
9: 0x77371250a206 - std[85c38ff02e03f0e6]::sys::backtrace::__rust_end_short_backtrace::<std[85c38ff02e03f0e6]::panicking::begin_panic<rustc_errors[a3358f633eebb703]::ExplicitBug>::{closure#0}, !>
10: 0x773712505829 - std[85c38ff02e03f0e6]::panicking::begin_panic::<rustc_errors[a3358f633eebb703]::ExplicitBug>
11: 0x773712520e01 - <rustc_errors[a3358f633eebb703]::diagnostic::BugAbort as rustc_errors[a3358f633eebb703]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
12: 0x773712b9a363 - rustc_middle[b16c40c3cb132ea9]::util::bug::opt_span_bug_fmt::<rustc_span[94bdfa138cad1541]::span_encoding::Span>::{closure#0}
13: 0x773712b8095a - rustc_middle[b16c40c3cb132ea9]::ty::context::tls::with_opt::<rustc_middle[b16c40c3cb132ea9]::util::bug::opt_span_bug_fmt<rustc_span[94bdfa138cad1541]::span_encoding::Span>::{closure#0}, !>::{closure#0}
14: 0x773712b807eb - rustc_middle[b16c40c3cb132ea9]::ty::context::tls::with_context_opt::<rustc_middle[b16c40c3cb132ea9]::ty::context::tls::with_opt<rustc_middle[b16c40c3cb132ea9]::util::bug::opt_span_bug_fmt<rustc_span[94bdfa138cad1541]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
15: 0x773710ccf260 - rustc_middle[b16c40c3cb132ea9]::util::bug::bug_fmt
16: 0x773713c65283 - rustc_trait_selection[7d6948a7a05ac95]::traits::specialize::translate_args_with_cause::<rustc_trait_selection[7d6948a7a05ac95]::traits::specialize::translate_args::{closure#0}>
17: 0x77371469a013 - rustc_trait_selection[7d6948a7a05ac95]::traits::project::opt_normalize_projection_term
18: 0x7737146931df - <rustc_trait_selection[7d6948a7a05ac95]::traits::normalize::AssocTypeNormalizer as rustc_type_ir[45f01c5603667543]::fold::TypeFolder<rustc_middle[b16c40c3cb132ea9]::ty::context::TyCtxt>>::fold_ty
19: 0x773713f06b53 - <rustc_hir_typeck[643602d1ca0da9fa]::fn_ctxt::FnCtxt>::normalize::<rustc_middle[b16c40c3cb132ea9]::ty::Ty>
20: 0x7737145c13fb - <dyn rustc_hir_analysis[614b5c894f29c678]::hir_ty_lowering::HirTyLowerer>::lower_ty
21: 0x7737147b4fa9 - <rustc_hir_typeck[643602d1ca0da9fa]::gather_locals::GatherLocalsVisitor>::declare
22: 0x773713f2336d - <rustc_hir_typeck[643602d1ca0da9fa]::gather_locals::GatherLocalsVisitor as rustc_hir[885137f5f5b6a9f]::intravisit::Visitor>::visit_expr
23: 0x773713f24f19 - rustc_hir_typeck[643602d1ca0da9fa]::check::check_fn
24: 0x773713f1b2f5 - rustc_hir_typeck[643602d1ca0da9fa]::typeck
25: 0x773713f1ac93 - rustc_query_impl[c0318c643aee4f05]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[c0318c643aee4f05]::query_impl::typeck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[b16c40c3cb132ea9]::query::erase::Erased<[u8; 8usize]>>
26: 0x773714321d81 - rustc_query_system[708ef94f36d60214]::query::plumbing::try_execute_query::<rustc_query_impl[c0318c643aee4f05]::DynamicConfig<rustc_query_system[708ef94f36d60214]::query::caches::VecCache<rustc_span[94bdfa138cad1541]::def_id::LocalDefId, rustc_middle[b16c40c3cb132ea9]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[c0318c643aee4f05]::plumbing::QueryCtxt, false>
27: 0x77371432024d - rustc_query_impl[c0318c643aee4f05]::query_impl::typeck::get_query_non_incr::__rust_end_short_backtrace
28: 0x77371431fec7 - <rustc_middle[b16c40c3cb132ea9]::hir::map::Map>::par_body_owners::<rustc_hir_analysis[614b5c894f29c678]::check_crate::{closure#4}>::{closure#0}
29: 0x77371431de99 - rustc_hir_analysis[614b5c894f29c678]::check_crate
30: 0x7737140e384a - rustc_interface[46946d42a40348f7]::passes::run_required_analyses
31: 0x7737147d451e - rustc_interface[46946d42a40348f7]::passes::analysis
32: 0x7737147d44ef - rustc_query_impl[c0318c643aee4f05]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[c0318c643aee4f05]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[b16c40c3cb132ea9]::query::erase::Erased<[u8; 1usize]>>
33: 0x773714ba1bae - rustc_query_system[708ef94f36d60214]::query::plumbing::try_execute_query::<rustc_query_impl[c0318c643aee4f05]::DynamicConfig<rustc_query_system[708ef94f36d60214]::query::caches::SingleCache<rustc_middle[b16c40c3cb132ea9]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[c0318c643aee4f05]::plumbing::QueryCtxt, false>
34: 0x773714ba188e - rustc_query_impl[c0318c643aee4f05]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
35: 0x773714a65292 - rustc_interface[46946d42a40348f7]::interface::run_compiler::<core[d9ceb9bc2a384707]::result::Result<(), rustc_span[94bdfa138cad1541]::ErrorGuaranteed>, rustc_driver_impl[8ea1370c87ac4c52]::run_compiler::{closure#0}>::{closure#1}
36: 0x773714af0590 - std[85c38ff02e03f0e6]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[46946d42a40348f7]::util::run_in_thread_with_globals<rustc_interface[46946d42a40348f7]::util::run_in_thread_pool_with_globals<rustc_interface[46946d42a40348f7]::interface::run_compiler<core[d9ceb9bc2a384707]::result::Result<(), rustc_span[94bdfa138cad1541]::ErrorGuaranteed>, rustc_driver_impl[8ea1370c87ac4c52]::run_compiler::{closure#0}>::{closure#1}, core[d9ceb9bc2a384707]::result::Result<(), rustc_span[94bdfa138cad1541]::ErrorGuaranteed>>::{closure#0}, core[d9ceb9bc2a384707]::result::Result<(), rustc_span[94bdfa138cad1541]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[d9ceb9bc2a384707]::result::Result<(), rustc_span[94bdfa138cad1541]::ErrorGuaranteed>>
37: 0x773714af09ab - <<std[85c38ff02e03f0e6]::thread::Builder>::spawn_unchecked_<rustc_interface[46946d42a40348f7]::util::run_in_thread_with_globals<rustc_interface[46946d42a40348f7]::util::run_in_thread_pool_with_globals<rustc_interface[46946d42a40348f7]::interface::run_compiler<core[d9ceb9bc2a384707]::result::Result<(), rustc_span[94bdfa138cad1541]::ErrorGuaranteed>, rustc_driver_impl[8ea1370c87ac4c52]::run_compiler::{closure#0}>::{closure#1}, core[d9ceb9bc2a384707]::result::Result<(), rustc_span[94bdfa138cad1541]::ErrorGuaranteed>>::{closure#0}, core[d9ceb9bc2a384707]::result::Result<(), rustc_span[94bdfa138cad1541]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[d9ceb9bc2a384707]::result::Result<(), rustc_span[94bdfa138cad1541]::ErrorGuaranteed>>::{closure#1} as core[d9ceb9bc2a384707]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
38: 0x773714af1479 - std::sys::pal::unix::thread::Thread::new::thread_start::h00969398ad9e9953
39: 0x77371631139d - <unknown>
40: 0x77371639649c - <unknown>
41: 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.84.0-nightly (ef972a346 2024-11-02) running on x86_64-unknown-linux-gnu
query stack during panic:
#0 [typeck] type-checking `main`
#1 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 1 previous error; 1 warning emitted
@rustbot label +F-specialization
Metadata
Metadata
Assignees
Labels
Category: This is a bug.`#![feature(specialization)]`Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Status: This bug is tracked inside the repo by a `known-bug` test.Status: A Minimal Complete and Verifiable Example has been found for this issueRelevant to the compiler team, which will review and decide on the PR/issue.This issue requires the use of incomplete features.