ICE: `FloatToFloat/FloatToInt cast: source type usize is not a float type`
Open
Nobody has claimed this yet.
C-bug
F-generic_const_exprs
I-ICE
P-low
S-bug-has-test
S-has-mcve
T-compiler
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
snippet:
#![feature(generic_const_exprs)]
trait Trait {}
struct HasCastInTraitImpl<const N: usize, const M: u128>;
impl<const O: f64> Trait for HasCastInTraitImpl<O, { O as u128 }> {}
pub fn use_trait_impl() {
fn assert_impl<T: Trait>() {}
assert_impl::<HasCastInTraitImpl<13, 13>>();
}
Version information
rustc 1.80.0-nightly (32a3ed229 2024-05-30)
binary: rustc
commit-hash: 32a3ed229caaaa6476ee1b0e644dd53579454536
commit-date: 2024-05-30
host: x86_64-unknown-linux-gnu
release: 1.80.0-nightly
LLVM version: 18.1.6
Command:
/home/matthias/.rustup/toolchains/master/bin/rustc
Program output
warning: the feature `generic_const_exprs` is incomplete and may not be safe to use and/or cause compiler crashes
--> /tmp/icemaker_global_tempdir.24ZAkKJT8e2J/rustc_testrunner_tmpdir_reporting.OPFOglKdOJxp/mvce.rs:1:12
|
1 | #![feature(generic_const_exprs)]
| ^^^^^^^^^^^^^^^^^^^
|
= note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information
= note: `#[warn(incomplete_features)]` on by default
error[E0601]: `main` function not found in crate `mvce`
--> /tmp/icemaker_global_tempdir.24ZAkKJT8e2J/rustc_testrunner_tmpdir_reporting.OPFOglKdOJxp/mvce.rs:12:2
|
12 | }
| ^ consider adding a `main` function to `/tmp/icemaker_global_tempdir.24ZAkKJT8e2J/rustc_testrunner_tmpdir_reporting.OPFOglKdOJxp/mvce.rs`
error: the constant `O` is not of type `usize`
--> /tmp/icemaker_global_tempdir.24ZAkKJT8e2J/rustc_testrunner_tmpdir_reporting.OPFOglKdOJxp/mvce.rs:6:30
|
6 | impl<const O: f64> Trait for HasCastInTraitImpl<O, { O as u128 }> {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `usize`, found `f64`
|
note: required by a bound in `HasCastInTraitImpl`
--> /tmp/icemaker_global_tempdir.24ZAkKJT8e2J/rustc_testrunner_tmpdir_reporting.OPFOglKdOJxp/mvce.rs:5:27
|
5 | struct HasCastInTraitImpl<const N: usize, const M: u128>;
| ^^^^^^^^^^^^^^ required by this bound in `HasCastInTraitImpl`
error: `f64` is forbidden as the type of a const generic parameter
--> /tmp/icemaker_global_tempdir.24ZAkKJT8e2J/rustc_testrunner_tmpdir_reporting.OPFOglKdOJxp/mvce.rs:6:15
|
6 | impl<const O: f64> Trait for HasCastInTraitImpl<O, { O as u128 }> {}
| ^^^
|
= note: the only supported types are integers, `bool` and `char`
error: internal compiler error: compiler/rustc_const_eval/src/interpret/cast.rs:189:13: FloatToFloat/FloatToInt cast: source type usize is not a float type
thread 'rustc' panicked at compiler/rustc_const_eval/src/interpret/cast.rs:189:13:
Box<dyn Any>
stack backtrace:
0: 0x7b9afb23ccc5 - std::backtrace_rs::backtrace::libunwind::trace::h678682a49ad9b996
at /rustc/32a3ed229caaaa6476ee1b0e644dd53579454536/library/std/src/../../backtrace/src/backtrace/libunwind.rs:116:5
1: 0x7b9afb23ccc5 - std::backtrace_rs::backtrace::trace_unsynchronized::hee6fa95bb2553111
at /rustc/32a3ed229caaaa6476ee1b0e644dd53579454536/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
2: 0x7b9afb23ccc5 - std::sys_common::backtrace::_print_fmt::h95e0b5b079a7d050
at /rustc/32a3ed229caaaa6476ee1b0e644dd53579454536/library/std/src/sys_common/backtrace.rs:68:5
3: 0x7b9afb23ccc5 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h5ef0519e3348f4b3
at /rustc/32a3ed229caaaa6476ee1b0e644dd53579454536/library/std/src/sys_common/backtrace.rs:44:22
4: 0x7b9afb28d6bb - core::fmt::rt::Argument::fmt::h351d794db9ebf8d4
at /rustc/32a3ed229caaaa6476ee1b0e644dd53579454536/library/core/src/fmt/rt.rs:165:63
5: 0x7b9afb28d6bb - core::fmt::write::hf6a10f4e291514d0
at /rustc/32a3ed229caaaa6476ee1b0e644dd53579454536/library/core/src/fmt/mod.rs:1168:21
6: 0x7b9afb23199f - std::io::Write::write_fmt::h3774e539b39c6176
at /rustc/32a3ed229caaaa6476ee1b0e644dd53579454536/library/std/src/io/mod.rs:1835:15
7: 0x7b9afb23ca9e - std::sys_common::backtrace::_print::h0766b9d4e4e1a2a5
at /rustc/32a3ed229caaaa6476ee1b0e644dd53579454536/library/std/src/sys_common/backtrace.rs:47:5
8: 0x7b9afb23ca9e - std::sys_common::backtrace::print::hf85a15b68fc127ec
at /rustc/32a3ed229caaaa6476ee1b0e644dd53579454536/library/std/src/sys_common/backtrace.rs:34:9
9: 0x7b9afb23f4d9 - std::panicking::default_hook::{{closure}}::hba9aa02e8bae00f0
10: 0x7b9afb23f27a - std::panicking::default_hook::h1795c37d9b50a345
at /rustc/32a3ed229caaaa6476ee1b0e644dd53579454536/library/std/src/panicking.rs:298:9
11: 0x7b9af7940d00 - std[fbc7945dfe4e847c]::panicking::update_hook::<alloc[648a2435367f9e21]::boxed::Box<rustc_driver_impl[4c120566f3914dcc]::install_ice_hook::{closure#0}>>::{closure#0}
12: 0x7b9afb23fc0b - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::hb26c638276518655
at /rustc/32a3ed229caaaa6476ee1b0e644dd53579454536/library/alloc/src/boxed.rs:2077:9
13: 0x7b9afb23fc0b - std::panicking::rust_panic_with_hook::h9450536fa6827029
at /rustc/32a3ed229caaaa6476ee1b0e644dd53579454536/library/std/src/panicking.rs:799:13
14: 0x7b9af7970de4 - std[fbc7945dfe4e847c]::panicking::begin_panic::<rustc_errors[29c2300d656916ab]::ExplicitBug>::{closure#0}
15: 0x7b9af796d9e6 - std[fbc7945dfe4e847c]::sys_common::backtrace::__rust_end_short_backtrace::<std[fbc7945dfe4e847c]::panicking::begin_panic<rustc_errors[29c2300d656916ab]::ExplicitBug>::{closure#0}, !>
16: 0x7b9af796d6c6 - std[fbc7945dfe4e847c]::panicking::begin_panic::<rustc_errors[29c2300d656916ab]::ExplicitBug>
17: 0x7b9af797a261 - <rustc_errors[29c2300d656916ab]::diagnostic::BugAbort as rustc_errors[29c2300d656916ab]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
18: 0x7b9af7e6827c - rustc_middle[be94168a967605d5]::util::bug::opt_span_bug_fmt::<rustc_span[41e37a1bb73e38bc]::span_encoding::Span>::{closure#0}
19: 0x7b9af7e4ad7a - rustc_middle[be94168a967605d5]::ty::context::tls::with_opt::<rustc_middle[be94168a967605d5]::util::bug::opt_span_bug_fmt<rustc_span[41e37a1bb73e38bc]::span_encoding::Span>::{closure#0}, !>::{closure#0}
20: 0x7b9af7e4ac1b - rustc_middle[be94168a967605d5]::ty::context::tls::with_context_opt::<rustc_middle[be94168a967605d5]::ty::context::tls::with_opt<rustc_middle[be94168a967605d5]::util::bug::opt_span_bug_fmt<rustc_span[41e37a1bb73e38bc]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
21: 0x7b9af618e150 - rustc_middle[be94168a967605d5]::util::bug::bug_fmt
22: 0x7b9af98c33eb - <rustc_const_eval[d725f5dd974c28ec]::interpret::eval_context::InterpCx<rustc_const_eval[d725f5dd974c28ec]::const_eval::machine::CompileTimeInterpreter>>::eval_rvalue_into_place
23: 0x7b9af6d37a4d - rustc_const_eval[d725f5dd974c28ec]::const_eval::eval_queries::eval_to_allocation_raw_provider
24: 0x7b9af93b763c - rustc_query_impl[c0e0181520bdf354]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[c0e0181520bdf354]::query_impl::eval_to_allocation_raw::dynamic_query::{closure#2}::{closure#0}, rustc_middle[be94168a967605d5]::query::erase::Erased<[u8; 24usize]>>
25: 0x7b9af93b6e59 - rustc_query_system[a635211d769013fd]::query::plumbing::try_execute_query::<rustc_query_impl[c0e0181520bdf354]::DynamicConfig<rustc_query_system[a635211d769013fd]::query::caches::DefaultCache<rustc_middle[be94168a967605d5]::ty::ParamEnvAnd<rustc_middle[be94168a967605d5]::mir::interpret::GlobalId>, rustc_middle[be94168a967605d5]::query::erase::Erased<[u8; 24usize]>>, false, false, false>, rustc_query_impl[c0e0181520bdf354]::plumbing::QueryCtxt, false>
26: 0x7b9af93b6a30 - rustc_query_impl[c0e0181520bdf354]::query_impl::eval_to_allocation_raw::get_query_non_incr::__rust_end_short_backtrace
27: 0x7b9af9b6aaf6 - rustc_middle[be94168a967605d5]::query::plumbing::query_get_at::<rustc_query_system[a635211d769013fd]::query::caches::DefaultCache<rustc_middle[be94168a967605d5]::ty::ParamEnvAnd<rustc_middle[be94168a967605d5]::mir::interpret::GlobalId>, rustc_middle[be94168a967605d5]::query::erase::Erased<[u8; 24usize]>>>
28: 0x7b9af9b6adb5 - rustc_const_eval[d725f5dd974c28ec]::const_eval::valtrees::eval_to_valtree
29: 0x7b9af9b6ad49 - <rustc_const_eval[d725f5dd974c28ec]::provide::{closure#0} as core[6d46e2ae36dee942]::ops::function::FnOnce<(rustc_middle[be94168a967605d5]::ty::context::TyCtxt, rustc_middle[be94168a967605d5]::ty::ParamEnvAnd<rustc_middle[be94168a967605d5]::mir::interpret::GlobalId>)>>::call_once
30: 0x7b9af9b6ad00 - rustc_query_impl[c0e0181520bdf354]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[c0e0181520bdf354]::query_impl::eval_to_valtree::dynamic_query::{closure#2}::{closure#0}, rustc_middle[be94168a967605d5]::query::erase::Erased<[u8; 24usize]>>
31: 0x7b9af9b6acc1 - <rustc_query_impl[c0e0181520bdf354]::query_impl::eval_to_valtree::dynamic_query::{closure#2} as core[6d46e2ae36dee942]::ops::function::FnOnce<(rustc_middle[be94168a967605d5]::ty::context::TyCtxt, rustc_middle[be94168a967605d5]::ty::ParamEnvAnd<rustc_middle[be94168a967605d5]::mir::interpret::GlobalId>)>>::call_once
32: 0x7b9af93b6f34 - rustc_query_system[a635211d769013fd]::query::plumbing::try_execute_query::<rustc_query_impl[c0e0181520bdf354]::DynamicConfig<rustc_query_system[a635211d769013fd]::query::caches::DefaultCache<rustc_middle[be94168a967605d5]::ty::ParamEnvAnd<rustc_middle[be94168a967605d5]::mir::interpret::GlobalId>, rustc_middle[be94168a967605d5]::query::erase::Erased<[u8; 24usize]>>, false, false, false>, rustc_query_impl[c0e0181520bdf354]::plumbing::QueryCtxt, false>
33: 0x7b9af93b6858 - rustc_query_impl[c0e0181520bdf354]::query_impl::eval_to_valtree::get_query_non_incr::__rust_end_short_backtrace
34: 0x7b9af97c86f1 - rustc_middle[be94168a967605d5]::query::plumbing::query_get_at::<rustc_query_system[a635211d769013fd]::query::caches::DefaultCache<rustc_middle[be94168a967605d5]::ty::ParamEnvAnd<rustc_middle[be94168a967605d5]::mir::interpret::GlobalId>, rustc_middle[be94168a967605d5]::query::erase::Erased<[u8; 24usize]>>>
35: 0x7b9af98e0bf3 - <rustc_middle[be94168a967605d5]::ty::context::TyCtxt>::const_eval_global_id_for_typeck
36: 0x7b9af98e11c2 - <rustc_middle[be94168a967605d5]::ty::context::TyCtxt>::const_eval_resolve_for_typeck
37: 0x7b9af7ca0162 - <rustc_infer[94dcf74a7bd108a5]::infer::InferCtxt>::const_eval_resolve
38: 0x7b9afa6bde47 - rustc_trait_selection[294db240007bd44b]::traits::const_evaluatable::is_const_evaluatable.cold
39: 0x7b9af58eb8d3 - <rustc_trait_selection[294db240007bd44b]::traits::fulfill::FulfillProcessor as rustc_data_structures[db4c5959faeb11bb]::obligation_forest::ObligationProcessor>::process_obligation
40: 0x7b9af8e05cf6 - <rustc_data_structures[db4c5959faeb11bb]::obligation_forest::ObligationForest<rustc_trait_selection[294db240007bd44b]::traits::fulfill::PendingPredicateObligation>>::process_obligations::<rustc_trait_selection[294db240007bd44b]::traits::fulfill::FulfillProcessor>
41: 0x7b9af5a5bc99 - <rustc_hir_typeck[27bfc99261d6777a]::fn_ctxt::FnCtxt>::confirm_builtin_call
42: 0x7b9af97e9f77 - <rustc_hir_typeck[27bfc99261d6777a]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
43: 0x7b9af97e57f3 - <rustc_hir_typeck[27bfc99261d6777a]::fn_ctxt::FnCtxt>::check_block_with_expected
44: 0x7b9af97ea937 - <rustc_hir_typeck[27bfc99261d6777a]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
45: 0x7b9af919e0d4 - rustc_hir_typeck[27bfc99261d6777a]::check::check_fn
46: 0x7b9af919386c - rustc_hir_typeck[27bfc99261d6777a]::typeck
47: 0x7b9af91932d1 - rustc_query_impl[c0e0181520bdf354]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[c0e0181520bdf354]::query_impl::typeck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[be94168a967605d5]::query::erase::Erased<[u8; 8usize]>>
48: 0x7b9af905a86e - rustc_query_system[a635211d769013fd]::query::plumbing::try_execute_query::<rustc_query_impl[c0e0181520bdf354]::DynamicConfig<rustc_query_system[a635211d769013fd]::query::caches::VecCache<rustc_span[41e37a1bb73e38bc]::def_id::LocalDefId, rustc_middle[be94168a967605d5]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[c0e0181520bdf354]::plumbing::QueryCtxt, false>
49: 0x7b9af9059395 - rustc_query_impl[c0e0181520bdf354]::query_impl::typeck::get_query_non_incr::__rust_end_short_backtrace
50: 0x7b9af9058fcb - <rustc_middle[be94168a967605d5]::hir::map::Map>::par_body_owners::<rustc_hir_analysis[9feabfd3ed563fae]::check_crate::{closure#4}>::{closure#0}
51: 0x7b9af9057a8b - rustc_hir_analysis[9feabfd3ed563fae]::check_crate
52: 0x7b9af98275fe - rustc_interface[c870be2efde3492c]::passes::analysis
53: 0x7b9af982715b - rustc_query_impl[c0e0181520bdf354]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[c0e0181520bdf354]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[be94168a967605d5]::query::erase::Erased<[u8; 1usize]>>
54: 0x7b9af9b8f725 - rustc_query_system[a635211d769013fd]::query::plumbing::try_execute_query::<rustc_query_impl[c0e0181520bdf354]::DynamicConfig<rustc_query_system[a635211d769013fd]::query::caches::SingleCache<rustc_middle[be94168a967605d5]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[c0e0181520bdf354]::plumbing::QueryCtxt, false>
55: 0x7b9af9b8f48f - rustc_query_impl[c0e0181520bdf354]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
56: 0x7b9af9a2120e - rustc_interface[c870be2efde3492c]::interface::run_compiler::<core[6d46e2ae36dee942]::result::Result<(), rustc_span[41e37a1bb73e38bc]::ErrorGuaranteed>, rustc_driver_impl[4c120566f3914dcc]::run_compiler::{closure#0}>::{closure#1}
57: 0x7b9af99e23c9 - std[fbc7945dfe4e847c]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[c870be2efde3492c]::util::run_in_thread_with_globals<rustc_interface[c870be2efde3492c]::util::run_in_thread_pool_with_globals<rustc_interface[c870be2efde3492c]::interface::run_compiler<core[6d46e2ae36dee942]::result::Result<(), rustc_span[41e37a1bb73e38bc]::ErrorGuaranteed>, rustc_driver_impl[4c120566f3914dcc]::run_compiler::{closure#0}>::{closure#1}, core[6d46e2ae36dee942]::result::Result<(), rustc_span[41e37a1bb73e38bc]::ErrorGuaranteed>>::{closure#0}, core[6d46e2ae36dee942]::result::Result<(), rustc_span[41e37a1bb73e38bc]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[6d46e2ae36dee942]::result::Result<(), rustc_span[41e37a1bb73e38bc]::ErrorGuaranteed>>
58: 0x7b9af99e2172 - <<std[fbc7945dfe4e847c]::thread::Builder>::spawn_unchecked_<rustc_interface[c870be2efde3492c]::util::run_in_thread_with_globals<rustc_interface[c870be2efde3492c]::util::run_in_thread_pool_with_globals<rustc_interface[c870be2efde3492c]::interface::run_compiler<core[6d46e2ae36dee942]::result::Result<(), rustc_span[41e37a1bb73e38bc]::ErrorGuaranteed>, rustc_driver_impl[4c120566f3914dcc]::run_compiler::{closure#0}>::{closure#1}, core[6d46e2ae36dee942]::result::Result<(), rustc_span[41e37a1bb73e38bc]::ErrorGuaranteed>>::{closure#0}, core[6d46e2ae36dee942]::result::Result<(), rustc_span[41e37a1bb73e38bc]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[6d46e2ae36dee942]::result::Result<(), rustc_span[41e37a1bb73e38bc]::ErrorGuaranteed>>::{closure#2} as core[6d46e2ae36dee942]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
59: 0x7b9afb249bfb - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h5d22407a994a8dd7
at /rustc/32a3ed229caaaa6476ee1b0e644dd53579454536/library/alloc/src/boxed.rs:2063:9
60: 0x7b9afb249bfb - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::he08091f4f7e587cf
at /rustc/32a3ed229caaaa6476ee1b0e644dd53579454536/library/alloc/src/boxed.rs:2063:9
61: 0x7b9afb249bfb - std::sys::pal::unix::thread::Thread::new::thread_start::h4ffcec4576023b2b
at /rustc/32a3ed229caaaa6476ee1b0e644dd53579454536/library/std/src/sys/pal/unix/thread.rs:108:17
62: 0x7b9af46aa1cf - <unknown>
63: 0x7b9af472b6ec - <unknown>
64: 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.80.0-nightly (32a3ed229 2024-05-30) running on x86_64-unknown-linux-gnu
query stack during panic:
#0 [eval_to_allocation_raw] const-evaluating + checking `<impl at /tmp/icemaker_global_tempdir.24ZAkKJT8e2J/rustc_testrunner_tmpdir_reporting.OPFOglKdOJxp/mvce.rs:6:1: 6:66>::{constant#0}`
#1 [eval_to_valtree] evaluating type-level constant
end of query stack
error: aborting due to 4 previous errors; 1 warning emitted
For more information about this error, try `rustc --explain E0601`.
@rustbot label +F-generic_const_exprs
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Run the supplied ice.rs reproducer with rustc, then inspect compiler/rustc_const_eval/src/interpret/cast.rs around line 189 and the const-evaluation path shown in the backtrace. Done means the reproducer produces regular diagnostics without an internal compiler error or panic, with coverage for this case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100