Closed
Description
snippet:
#![feature(generic_const_exprs)]
use std::ops::Add;
pub struct Dimension;
pub struct Quantity<S, const D: Dimension>(S);
impl<const D: Dimension, LHS, RHS> Add<LHS, D> for Quantity<LHS, { Dimension }> {}
pub fn add<const U: Dimension>(x: Quantity<f32, U>) -> Quantity<f32, U> {
x + y
}
Version information
rustc 1.79.0-nightly (13e63f749 2024-04-19)
binary: rustc
commit-hash: 13e63f7490109eecf905fa51190eacbe8051aefd
commit-date: 2024-04-19
host: x86_64-unknown-linux-gnu
release: 1.79.0-nightly
LLVM version: 18.1.4
Command:
/home/matthias/.rustup/toolchains/master/bin/rustc
Program output
error[E0425]: cannot find value `y` in this scope
--> /tmp/icemaker_global_tempdir.238HcpoyMYrj/rustc_testrunner_tmpdir_reporting.djwOrNP1QTCg/mvce.rs:12:9
|
11 | pub fn add<const U: Dimension>(x: Quantity<f32, U>) -> Quantity<f32, U> {
| - similarly named const parameter `U` defined here
12 | x + y
| ^ help: a const parameter with a similar name exists: `U`
warning: the feature `generic_const_exprs` is incomplete and may not be safe to use and/or cause compiler crashes
--> /tmp/icemaker_global_tempdir.238HcpoyMYrj/rustc_testrunner_tmpdir_reporting.djwOrNP1QTCg/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.238HcpoyMYrj/rustc_testrunner_tmpdir_reporting.djwOrNP1QTCg/mvce.rs:13:2
|
13 | }
| ^ consider adding a `main` function to `/tmp/icemaker_global_tempdir.238HcpoyMYrj/rustc_testrunner_tmpdir_reporting.djwOrNP1QTCg/mvce.rs`
error: `Dimension` is forbidden as the type of a const generic parameter
--> /tmp/icemaker_global_tempdir.238HcpoyMYrj/rustc_testrunner_tmpdir_reporting.djwOrNP1QTCg/mvce.rs:7:33
|
7 | pub struct Quantity<S, const D: Dimension>(S);
| ^^^^^^^^^
|
= note: the only supported types are integers, `bool` and `char`
help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types
|
3 + #![feature(adt_const_params)]
|
error[E0107]: trait takes at most 1 generic argument but 2 generic arguments were supplied
--> /tmp/icemaker_global_tempdir.238HcpoyMYrj/rustc_testrunner_tmpdir_reporting.djwOrNP1QTCg/mvce.rs:9:36
|
9 | impl<const D: Dimension, LHS, RHS> Add<LHS, D> for Quantity<LHS, { Dimension }> {}
| ^^^ expected at most 1 generic argument
|
note: trait defined here, with at most 1 generic parameter: `Rhs`
--> /home/matthias/.rustup/toolchains/master/lib/rustlib/src/rust/library/core/src/ops/arith.rs:77:11
|
77 | pub trait Add<Rhs = Self> {
| ^^^ ----------
error[E0207]: the type parameter `RHS` is not constrained by the impl trait, self type, or predicates
--> /tmp/icemaker_global_tempdir.238HcpoyMYrj/rustc_testrunner_tmpdir_reporting.djwOrNP1QTCg/mvce.rs:9:31
|
9 | impl<const D: Dimension, LHS, RHS> Add<LHS, D> for Quantity<LHS, { Dimension }> {}
| ^^^ unconstrained type parameter
error: `Dimension` is forbidden as the type of a const generic parameter
--> /tmp/icemaker_global_tempdir.238HcpoyMYrj/rustc_testrunner_tmpdir_reporting.djwOrNP1QTCg/mvce.rs:9:15
|
9 | impl<const D: Dimension, LHS, RHS> Add<LHS, D> for Quantity<LHS, { Dimension }> {}
| ^^^^^^^^^
|
= note: the only supported types are integers, `bool` and `char`
help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types
|
3 + #![feature(adt_const_params)]
|
error: `Dimension` is forbidden as the type of a const generic parameter
--> /tmp/icemaker_global_tempdir.238HcpoyMYrj/rustc_testrunner_tmpdir_reporting.djwOrNP1QTCg/mvce.rs:11:21
|
11 | pub fn add<const U: Dimension>(x: Quantity<f32, U>) -> Quantity<f32, U> {
| ^^^^^^^^^
|
= note: the only supported types are integers, `bool` and `char`
help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types
|
3 + #![feature(adt_const_params)]
|
error: internal compiler error: compiler/rustc_infer/src/infer/relate/combine.rs:218:17: tried to combine ConstKind::Infer/ConstKind::Infer(InferConst::Var): ?0e: bool and ?0c: Dimension
thread 'rustc' panicked at compiler/rustc_infer/src/infer/relate/combine.rs:218:17:
Box<dyn Any>
stack backtrace:
0: 0x70f2a720ba75 - std::backtrace_rs::backtrace::libunwind::trace::ha8c9b07da08ff29f
at /rustc/13e63f7490109eecf905fa51190eacbe8051aefd/library/std/src/../../backtrace/src/backtrace/libunwind.rs:105:5
1: 0x70f2a720ba75 - std::backtrace_rs::backtrace::trace_unsynchronized::h88b77157367fcdbe
at /rustc/13e63f7490109eecf905fa51190eacbe8051aefd/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
2: 0x70f2a720ba75 - std::sys_common::backtrace::_print_fmt::hea56b38e54fb92e3
at /rustc/13e63f7490109eecf905fa51190eacbe8051aefd/library/std/src/sys_common/backtrace.rs:68:5
3: 0x70f2a720ba75 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hd602b1809ea2b2a5
at /rustc/13e63f7490109eecf905fa51190eacbe8051aefd/library/std/src/sys_common/backtrace.rs:44:22
4: 0x70f2a725aceb - core::fmt::rt::Argument::fmt::h62340eb90b1c87a5
at /rustc/13e63f7490109eecf905fa51190eacbe8051aefd/library/core/src/fmt/rt.rs:165:63
5: 0x70f2a725aceb - core::fmt::write::hd8cf97ba7b2f9e9b
at /rustc/13e63f7490109eecf905fa51190eacbe8051aefd/library/core/src/fmt/mod.rs:1157:21
6: 0x70f2a72005ff - std::io::Write::write_fmt::h6c685f4679b9e915
at /rustc/13e63f7490109eecf905fa51190eacbe8051aefd/library/std/src/io/mod.rs:1832:15
7: 0x70f2a720b84e - std::sys_common::backtrace::_print::hd9c2ac426a3dbd1c
at /rustc/13e63f7490109eecf905fa51190eacbe8051aefd/library/std/src/sys_common/backtrace.rs:47:5
8: 0x70f2a720b84e - std::sys_common::backtrace::print::h7bbdd9953597c8e0
at /rustc/13e63f7490109eecf905fa51190eacbe8051aefd/library/std/src/sys_common/backtrace.rs:34:9
9: 0x70f2a720e1b9 - std::panicking::default_hook::{{closure}}::hde25fbbdd81a41c5
10: 0x70f2a720defd - std::panicking::default_hook::h4ad8db4b2d78fdfd
at /rustc/13e63f7490109eecf905fa51190eacbe8051aefd/library/std/src/panicking.rs:291:9
11: 0x70f2a3c0bb0c - std[3a7515f9f343dc41]::panicking::update_hook::<alloc[4812e9b6fdfe5c0f]::boxed::Box<rustc_driver_impl[7e01e62ceaa0f3bd]::install_ice_hook::{closure#0}>>::{closure#0}
12: 0x70f2a720e8b6 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::ha867ea15cf1ece79
at /rustc/13e63f7490109eecf905fa51190eacbe8051aefd/library/alloc/src/boxed.rs:2036:9
13: 0x70f2a720e8b6 - std::panicking::rust_panic_with_hook::h38462a8904eacfd3
at /rustc/13e63f7490109eecf905fa51190eacbe8051aefd/library/std/src/panicking.rs:792:13
14: 0x70f2a3c3be14 - std[3a7515f9f343dc41]::panicking::begin_panic::<rustc_errors[342f12710b53d715]::ExplicitBug>::{closure#0}
15: 0x70f2a3c38a96 - std[3a7515f9f343dc41]::sys_common::backtrace::__rust_end_short_backtrace::<std[3a7515f9f343dc41]::panicking::begin_panic<rustc_errors[342f12710b53d715]::ExplicitBug>::{closure#0}, !>
16: 0x70f2a3c38776 - std[3a7515f9f343dc41]::panicking::begin_panic::<rustc_errors[342f12710b53d715]::ExplicitBug>
17: 0x70f2a3c44d31 - <rustc_errors[342f12710b53d715]::diagnostic::BugAbort as rustc_errors[342f12710b53d715]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
18: 0x70f2a40ee87c - rustc_middle[9f70d05f0880cb49]::util::bug::opt_span_bug_fmt::<rustc_span[5b895301fccec34d]::span_encoding::Span>::{closure#0}
19: 0x70f2a40d6f6a - rustc_middle[9f70d05f0880cb49]::ty::context::tls::with_opt::<rustc_middle[9f70d05f0880cb49]::util::bug::opt_span_bug_fmt<rustc_span[5b895301fccec34d]::span_encoding::Span>::{closure#0}, !>::{closure#0}
20: 0x70f2a40d6e0b - rustc_middle[9f70d05f0880cb49]::ty::context::tls::with_context_opt::<rustc_middle[9f70d05f0880cb49]::ty::context::tls::with_opt<rustc_middle[9f70d05f0880cb49]::util::bug::opt_span_bug_fmt<rustc_span[5b895301fccec34d]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
21: 0x70f2a2488730 - rustc_middle[9f70d05f0880cb49]::util::bug::bug_fmt
22: 0x70f2a51c09c6 - <rustc_infer[d392145922f729ae]::infer::InferCtxt>::super_combine_consts::<rustc_infer[d392145922f729ae]::infer::relate::type_relating::TypeRelating>
23: 0x70f2a576b128 - <rustc_trait_selection[907d3d2a5430c87]::traits::select::SelectionContext>::match_impl::{closure#0}
24: 0x70f2a1cd6401 - <rustc_trait_selection[907d3d2a5430c87]::traits::select::SelectionContext>::assemble_candidates_from_impls
25: 0x70f2a1cae490 - <rustc_trait_selection[907d3d2a5430c87]::traits::select::SelectionContext>::candidate_from_obligation_no_cache
26: 0x70f2a24ac0b6 - <rustc_trait_selection[907d3d2a5430c87]::traits::select::SelectionContext>::candidate_from_obligation
27: 0x70f2a574f61d - <rustc_trait_selection[907d3d2a5430c87]::traits::select::SelectionContext>::evaluate_trait_predicate_recursively
28: 0x70f2a5747392 - <rustc_trait_selection[907d3d2a5430c87]::traits::select::SelectionContext>::evaluate_root_obligation
29: 0x70f2a57457d1 - rustc_traits[53e42f50b8e79099]::evaluate_obligation::evaluate_obligation
30: 0x70f2a5745169 - rustc_query_impl[1d56237bde1e3cf]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[1d56237bde1e3cf]::query_impl::evaluate_obligation::dynamic_query::{closure#2}::{closure#0}, rustc_middle[9f70d05f0880cb49]::query::erase::Erased<[u8; 2usize]>>
31: 0x70f2a5744699 - rustc_query_system[8dca229a75e3ed4f]::query::plumbing::try_execute_query::<rustc_query_impl[1d56237bde1e3cf]::DynamicConfig<rustc_query_system[8dca229a75e3ed4f]::query::caches::DefaultCache<rustc_type_ir[74778dcbd53ce3ac]::canonical::Canonical<rustc_middle[9f70d05f0880cb49]::ty::context::TyCtxt, rustc_middle[9f70d05f0880cb49]::ty::ParamEnvAnd<rustc_middle[9f70d05f0880cb49]::ty::predicate::Predicate>>, rustc_middle[9f70d05f0880cb49]::query::erase::Erased<[u8; 2usize]>>, false, false, false>, rustc_query_impl[1d56237bde1e3cf]::plumbing::QueryCtxt, false>
32: 0x70f2a57442da - rustc_query_impl[1d56237bde1e3cf]::query_impl::evaluate_obligation::get_query_non_incr::__rust_end_short_backtrace
33: 0x70f2a2aff393 - <rustc_infer[d392145922f729ae]::infer::InferCtxt as rustc_trait_selection[907d3d2a5430c87]::traits::query::evaluate_obligation::InferCtxtExt>::predicate_may_hold
34: 0x70f2a55b2576 - <rustc_hir_typeck[939ad14c3525d91d]::fn_ctxt::FnCtxt>::lookup_method_in_trait
35: 0x70f2a558b0f3 - <rustc_hir_typeck[939ad14c3525d91d]::fn_ctxt::FnCtxt>::check_overloaded_binop
36: 0x70f2a5b101f2 - <rustc_hir_typeck[939ad14c3525d91d]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
37: 0x70f2a5b08886 - <rustc_hir_typeck[939ad14c3525d91d]::fn_ctxt::FnCtxt>::check_block_with_expected
38: 0x70f2a5b0ebf6 - <rustc_hir_typeck[939ad14c3525d91d]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
39: 0x70f2a522f02a - rustc_hir_typeck[939ad14c3525d91d]::check::check_fn
40: 0x70f2a52242e1 - rustc_hir_typeck[939ad14c3525d91d]::typeck
41: 0x70f2a5223c95 - rustc_query_impl[1d56237bde1e3cf]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[1d56237bde1e3cf]::query_impl::typeck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[9f70d05f0880cb49]::query::erase::Erased<[u8; 8usize]>>
42: 0x70f2a52115b1 - rustc_query_system[8dca229a75e3ed4f]::query::plumbing::try_execute_query::<rustc_query_impl[1d56237bde1e3cf]::DynamicConfig<rustc_query_system[8dca229a75e3ed4f]::query::caches::VecCache<rustc_span[5b895301fccec34d]::def_id::LocalDefId, rustc_middle[9f70d05f0880cb49]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[1d56237bde1e3cf]::plumbing::QueryCtxt, false>
43: 0x70f2a520ff8c - rustc_query_impl[1d56237bde1e3cf]::query_impl::typeck::get_query_non_incr::__rust_end_short_backtrace
44: 0x70f2a520fb5a - <rustc_middle[9f70d05f0880cb49]::hir::map::Map>::par_body_owners::<rustc_hir_analysis[156b0fa72c4118da]::check_crate::{closure#4}>::{closure#0}
45: 0x70f2a520e84d - rustc_hir_analysis[156b0fa72c4118da]::check_crate
46: 0x70f2a55d4bfa - rustc_interface[54c114a5fe2550b3]::passes::analysis
47: 0x70f2a55d4755 - rustc_query_impl[1d56237bde1e3cf]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[1d56237bde1e3cf]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[9f70d05f0880cb49]::query::erase::Erased<[u8; 1usize]>>
48: 0x70f2a5da0765 - rustc_query_system[8dca229a75e3ed4f]::query::plumbing::try_execute_query::<rustc_query_impl[1d56237bde1e3cf]::DynamicConfig<rustc_query_system[8dca229a75e3ed4f]::query::caches::SingleCache<rustc_middle[9f70d05f0880cb49]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[1d56237bde1e3cf]::plumbing::QueryCtxt, false>
49: 0x70f2a5da04c9 - rustc_query_impl[1d56237bde1e3cf]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
50: 0x70f2a5c04a19 - rustc_interface[54c114a5fe2550b3]::interface::run_compiler::<core[19d803e10bedb259]::result::Result<(), rustc_span[5b895301fccec34d]::ErrorGuaranteed>, rustc_driver_impl[7e01e62ceaa0f3bd]::run_compiler::{closure#0}>::{closure#1}
51: 0x70f2a5bec6a7 - std[3a7515f9f343dc41]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[54c114a5fe2550b3]::util::run_in_thread_with_globals<rustc_interface[54c114a5fe2550b3]::util::run_in_thread_pool_with_globals<rustc_interface[54c114a5fe2550b3]::interface::run_compiler<core[19d803e10bedb259]::result::Result<(), rustc_span[5b895301fccec34d]::ErrorGuaranteed>, rustc_driver_impl[7e01e62ceaa0f3bd]::run_compiler::{closure#0}>::{closure#1}, core[19d803e10bedb259]::result::Result<(), rustc_span[5b895301fccec34d]::ErrorGuaranteed>>::{closure#0}, core[19d803e10bedb259]::result::Result<(), rustc_span[5b895301fccec34d]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[19d803e10bedb259]::result::Result<(), rustc_span[5b895301fccec34d]::ErrorGuaranteed>>
52: 0x70f2a5bec46a - <<std[3a7515f9f343dc41]::thread::Builder>::spawn_unchecked_<rustc_interface[54c114a5fe2550b3]::util::run_in_thread_with_globals<rustc_interface[54c114a5fe2550b3]::util::run_in_thread_pool_with_globals<rustc_interface[54c114a5fe2550b3]::interface::run_compiler<core[19d803e10bedb259]::result::Result<(), rustc_span[5b895301fccec34d]::ErrorGuaranteed>, rustc_driver_impl[7e01e62ceaa0f3bd]::run_compiler::{closure#0}>::{closure#1}, core[19d803e10bedb259]::result::Result<(), rustc_span[5b895301fccec34d]::ErrorGuaranteed>>::{closure#0}, core[19d803e10bedb259]::result::Result<(), rustc_span[5b895301fccec34d]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[19d803e10bedb259]::result::Result<(), rustc_span[5b895301fccec34d]::ErrorGuaranteed>>::{closure#2} as core[19d803e10bedb259]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
53: 0x70f2a721878b - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h86765e31d66056c2
at /rustc/13e63f7490109eecf905fa51190eacbe8051aefd/library/alloc/src/boxed.rs:2022:9
54: 0x70f2a721878b - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::he77e1cc2b11985d8
at /rustc/13e63f7490109eecf905fa51190eacbe8051aefd/library/alloc/src/boxed.rs:2022:9
55: 0x70f2a721878b - std::sys::pal::unix::thread::Thread::new::thread_start::h478135d5001d4398
at /rustc/13e63f7490109eecf905fa51190eacbe8051aefd/library/std/src/sys/pal/unix/thread.rs:108:17
56: 0x70f2a0aa955a - <unknown>
57: 0x70f2a0b26a3c - <unknown>
58: 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.79.0-nightly (13e63f749 2024-04-19) running on x86_64-unknown-linux-gnu
query stack during panic:
#0 [evaluate_obligation] evaluating trait selection obligation `Quantity<f32, U>: ~const core::ops::arith::Add<^1_0>`
#1 [typeck] type-checking `add`
#2 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 8 previous errors; 1 warning emitted
Some errors have detailed explanations: E0107, E0207, E0425, E0601.
For more information about an error, try `rustc --explain E0107`.