Closed
Description
When anonymous value is used as generic parameter, the compiler panics with thread 'rustc' panicked at 'Box<dyn Any>', compiler\rustc_errors\src\lib.rs:1425:13
.
However if a value is bound to a const variable, it works.
Code
#![feature(adt_const_params)]
const ZERO: f64 = 0.0;
pub struct Foo<const X: f64> {}
fn main() {
let _ = Foo::<0.0> {}; // fails
let _ = Foo::<ZERO> {}; // passes
}
Meta
rustc --version --verbose
:
rustc 1.64.0-nightly (46b8c23f3 2022-07-01)
binary: rustc
commit-hash: 46b8c23f3eb5e4d0e0aa27eb3f20d5b8fc3ed51f
commit-date: 2022-07-01
host: x86_64-pc-windows-msvc
release: 1.64.0-nightly
LLVM version: 14.0.6
Error output
warning: Error finalizing incremental compilation session directory (...)
error: internal compiler error: no errors encountered even though `delay_span_bug` issued
error: internal compiler error: Const::from_anon_const: couldn't lit_to_const TypeError
--> src\main.rs:6:19
|
6 | let _ = Foo::<0.0> {};
| ^^^
|
= note: delayed at compiler\rustc_middle\src\ty\consts.rs:128:30
thread 'rustc' panicked at 'Box<dyn Any>', compiler\rustc_errors\src\lib.rs:1425:13
stack backtrace:
0: 0x7fffcceea08f - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::haf1ad183bbfbc238
1: 0x7fffccf2454a - core::fmt::write::ha9a2f4b5fc2cd03e
2: 0x7fffccedc589 - <std::io::IoSliceMut as core::fmt::Debug>::fmt::h934bac5f9f732b9e
3: 0x7fffcceed97b - std::panicking::default_hook::hf57e8e79b218be44
4: 0x7fffcceed5fb - std::panicking::default_hook::hf57e8e79b218be44
5: 0x7fffcd517186 - rustc_driver[5cf3877d393213b7]::pretty::print_after_hir_lowering
6: 0x7fffcceee122 - std::panicking::rust_panic_with_hook::hd2f9d78204050d72
7: 0x7fffd1d13905 - <rustc_errors[768570d7a0d53115]::snippet::Style as core[179685c4f861d119]::fmt::Debug>::fmt
8: 0x7fffd1d0f889 - <rustc_errors[768570d7a0d53115]::snippet::Style as core[179685c4f861d119]::fmt::Debug>::fmt
9: 0x7fffd2057b69 - rustc_query_system[598cd9cddcda72da]::query::job::report_cycle
10: 0x7fffd1cbee69 - <rustc_feature[4dbba36b93aa7032]::builtin_attrs::AttributeType as core[179685c4f861d119]::fmt::Debug>::fmt
11: 0x7fffd1cc2bac - <rustc_errors[768570d7a0d53115]::HandlerInner as core[179685c4f861d119]::ops::drop::Drop>::drop
12: 0x7fffcd4919d4 - <chalk_engine[44566aa7495cc23f]::TableIndex>::increment
13: 0x7fffcd49ca9a - <chalk_engine[44566aa7495cc23f]::TableIndex>::increment
14: 0x7fffcd52812d - <rustc_driver[5cf3877d393213b7]::Compilation as core[179685c4f861d119]::fmt::Debug>::fmt
15: 0x7fffcd525b39 - <rustc_driver[5cf3877d393213b7]::Compilation as core[179685c4f861d119]::fmt::Debug>::fmt
16: 0x7fffcd4a63ed - <chalk_engine[44566aa7495cc23f]::TableIndex>::increment
17: 0x7fffcd4d0186 - <rustc_driver[5cf3877d393213b7]::args::Error as core[179685c4f861d119]::fmt::Debug>::fmt
18: 0x7fffcd4d0a08 - <rustc_driver[5cf3877d393213b7]::args::Error as core[179685c4f861d119]::fmt::Debug>::fmt
19: 0x7fffccefe8fc - std::sys::windows::thread::Thread::new::h9a2ca89e45b8574f
20: 0x7ff84b087034 - BaseThreadInitThunk
21: 0x7ff84cf82651 - RtlUserThreadStart
note: the compiler unexpectedly panicked. this is a bug.
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.64.0-nightly (46b8c23f3 2022-07-01) running on x86_64-pc-windows-msvc
note: compiler flags: --crate-type bin -C embed-bitcode=no -C debuginfo=2 -C incremental
note: some of the compiler flags provided by cargo are hidden
query stack during panic:
end of query stack
warning: `rustc-bug-const-generic` (bin "rustc-bug-const-generic") generated 2 warnings
error: could not compile `rustc-bug-const-generic`; 2 warnings emitted