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.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
error[E0425]: cannot find value `y` in this scope
--> /tmp/icemaker_global_tempdir.BQRYoTH66DXv/rustc_testrunner_tmpdir_reporting.rRbz9telcPFa/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.BQRYoTH66DXv/rustc_testrunner_tmpdir_reporting.rRbz9telcPFa/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.BQRYoTH66DXv/rustc_testrunner_tmpdir_reporting.rRbz9telcPFa/mvce.rs:13:2
|
13 | }
| ^ consider adding a `main` function to `/tmp/icemaker_global_tempdir.BQRYoTH66DXv/rustc_testrunner_tmpdir_reporting.rRbz9telcPFa/mvce.rs`
error: `Dimension` is forbidden as the type of a const generic parameter
--> /tmp/icemaker_global_tempdir.BQRYoTH66DXv/rustc_testrunner_tmpdir_reporting.rRbz9telcPFa/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.BQRYoTH66DXv/rustc_testrunner_tmpdir_reporting.rRbz9telcPFa/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.BQRYoTH66DXv/rustc_testrunner_tmpdir_reporting.rRbz9telcPFa/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.BQRYoTH66DXv/rustc_testrunner_tmpdir_reporting.rRbz9telcPFa/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.BQRYoTH66DXv/rustc_testrunner_tmpdir_reporting.rRbz9telcPFa/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:198: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:198:17:
Box<dyn Any>
stack backtrace:
0: 0x70fab7fb9cc5 - std::backtrace_rs::backtrace::libunwind::trace::h678682a49ad9b996
at /rustc/32a3ed229caaaa6476ee1b0e644dd53579454536/library/std/src/../../backtrace/src/backtrace/libunwind.rs:116:5
1: 0x70fab7fb9cc5 - std::backtrace_rs::backtrace::trace_unsynchronized::hee6fa95bb2553111
at /rustc/32a3ed229caaaa6476ee1b0e644dd53579454536/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
2: 0x70fab7fb9cc5 - std::sys_common::backtrace::_print_fmt::h95e0b5b079a7d050
at /rustc/32a3ed229caaaa6476ee1b0e644dd53579454536/library/std/src/sys_common/backtrace.rs:68:5
3: 0x70fab7fb9cc5 - <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: 0x70fab800a6bb - core::fmt::rt::Argument::fmt::h351d794db9ebf8d4
at /rustc/32a3ed229caaaa6476ee1b0e644dd53579454536/library/core/src/fmt/rt.rs:165:63
5: 0x70fab800a6bb - core::fmt::write::hf6a10f4e291514d0
at /rustc/32a3ed229caaaa6476ee1b0e644dd53579454536/library/core/src/fmt/mod.rs:1168:21
6: 0x70fab7fae99f - std::io::Write::write_fmt::h3774e539b39c6176
at /rustc/32a3ed229caaaa6476ee1b0e644dd53579454536/library/std/src/io/mod.rs:1835:15
7: 0x70fab7fb9a9e - std::sys_common::backtrace::_print::h0766b9d4e4e1a2a5
at /rustc/32a3ed229caaaa6476ee1b0e644dd53579454536/library/std/src/sys_common/backtrace.rs:47:5
8: 0x70fab7fb9a9e - std::sys_common::backtrace::print::hf85a15b68fc127ec
at /rustc/32a3ed229caaaa6476ee1b0e644dd53579454536/library/std/src/sys_common/backtrace.rs:34:9
9: 0x70fab7fbc4d9 - std::panicking::default_hook::{{closure}}::hba9aa02e8bae00f0
10: 0x70fab7fbc27a - std::panicking::default_hook::h1795c37d9b50a345
at /rustc/32a3ed229caaaa6476ee1b0e644dd53579454536/library/std/src/panicking.rs:298:9
11: 0x70fab4740d00 - std[fbc7945dfe4e847c]::panicking::update_hook::<alloc[648a2435367f9e21]::boxed::Box<rustc_driver_impl[4c120566f3914dcc]::install_ice_hook::{closure#0}>>::{closure#0}
12: 0x70fab7fbcc0b - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::hb26c638276518655
at /rustc/32a3ed229caaaa6476ee1b0e644dd53579454536/library/alloc/src/boxed.rs:2077:9
13: 0x70fab7fbcc0b - std::panicking::rust_panic_with_hook::h9450536fa6827029
at /rustc/32a3ed229caaaa6476ee1b0e644dd53579454536/library/std/src/panicking.rs:799:13
14: 0x70fab4770de4 - std[fbc7945dfe4e847c]::panicking::begin_panic::<rustc_errors[29c2300d656916ab]::ExplicitBug>::{closure#0}
15: 0x70fab476d9e6 - std[fbc7945dfe4e847c]::sys_common::backtrace::__rust_end_short_backtrace::<std[fbc7945dfe4e847c]::panicking::begin_panic<rustc_errors[29c2300d656916ab]::ExplicitBug>::{closure#0}, !>
16: 0x70fab476d6c6 - std[fbc7945dfe4e847c]::panicking::begin_panic::<rustc_errors[29c2300d656916ab]::ExplicitBug>
17: 0x70fab477a261 - <rustc_errors[29c2300d656916ab]::diagnostic::BugAbort as rustc_errors[29c2300d656916ab]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
18: 0x70fab4c6827c - rustc_middle[be94168a967605d5]::util::bug::opt_span_bug_fmt::<rustc_span[41e37a1bb73e38bc]::span_encoding::Span>::{closure#0}
19: 0x70fab4c4ad7a - 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: 0x70fab4c4ac1b - 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: 0x70fab2f8e150 - rustc_middle[be94168a967605d5]::util::bug::bug_fmt
22: 0x70fab5c99f78 - <rustc_infer[94dcf74a7bd108a5]::infer::InferCtxt>::super_combine_consts::<rustc_infer[94dcf74a7bd108a5]::infer::relate::type_relating::TypeRelating>
23: 0x70fab6501611 - <rustc_trait_selection[294db240007bd44b]::traits::select::SelectionContext>::match_impl::{closure#0}
24: 0x70fab28f7e71 - <rustc_trait_selection[294db240007bd44b]::traits::select::SelectionContext>::candidate_from_obligation_no_cache
25: 0x70fab291fc30 - <rustc_trait_selection[294db240007bd44b]::traits::select::SelectionContext>::candidate_from_obligation
26: 0x70fab5ffda6d - <rustc_trait_selection[294db240007bd44b]::traits::select::SelectionContext>::evaluate_trait_predicate_recursively
27: 0x70fab5ff56c1 - <rustc_trait_selection[294db240007bd44b]::traits::select::SelectionContext>::evaluate_root_obligation
28: 0x70fab5ff3c93 - rustc_traits[4cf73b45282ec2ed]::evaluate_obligation::evaluate_obligation
29: 0x70fab5ff3629 - rustc_query_impl[c0e0181520bdf354]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[c0e0181520bdf354]::query_impl::evaluate_obligation::dynamic_query::{closure#2}::{closure#0}, rustc_middle[be94168a967605d5]::query::erase::Erased<[u8; 2usize]>>
30: 0x70fab5ff2b92 - rustc_query_system[a635211d769013fd]::query::plumbing::try_execute_query::<rustc_query_impl[c0e0181520bdf354]::DynamicConfig<rustc_query_system[a635211d769013fd]::query::caches::DefaultCache<rustc_type_ir[ed60f3cda1f7a2f8]::canonical::Canonical<rustc_middle[be94168a967605d5]::ty::context::TyCtxt, rustc_middle[be94168a967605d5]::ty::ParamEnvAnd<rustc_middle[be94168a967605d5]::ty::predicate::Predicate>>, rustc_middle[be94168a967605d5]::query::erase::Erased<[u8; 2usize]>>, false, false, false>, rustc_query_impl[c0e0181520bdf354]::plumbing::QueryCtxt, false>
31: 0x70fab5ff27e4 - rustc_query_impl[c0e0181520bdf354]::query_impl::evaluate_obligation::get_query_non_incr::__rust_end_short_backtrace
32: 0x70fab375b114 - <rustc_infer[94dcf74a7bd108a5]::infer::InferCtxt as rustc_trait_selection[294db240007bd44b]::traits::query::evaluate_obligation::InferCtxtExt>::predicate_may_hold
33: 0x70fab63b1705 - <rustc_hir_typeck[27bfc99261d6777a]::fn_ctxt::FnCtxt>::lookup_method_in_trait
34: 0x70fab5c4767a - <rustc_hir_typeck[27bfc99261d6777a]::fn_ctxt::FnCtxt>::check_overloaded_binop
35: 0x70fab65eb93f - <rustc_hir_typeck[27bfc99261d6777a]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
36: 0x70fab65e58ce - <rustc_hir_typeck[27bfc99261d6777a]::fn_ctxt::FnCtxt>::check_block_with_expected
37: 0x70fab65ea937 - <rustc_hir_typeck[27bfc99261d6777a]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
38: 0x70fab5f9e0d4 - rustc_hir_typeck[27bfc99261d6777a]::check::check_fn
39: 0x70fab5f9386c - rustc_hir_typeck[27bfc99261d6777a]::typeck
40: 0x70fab5f932d1 - 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]>>
41: 0x70fab5e5a86e - 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>
42: 0x70fab5e59395 - rustc_query_impl[c0e0181520bdf354]::query_impl::typeck::get_query_non_incr::__rust_end_short_backtrace
43: 0x70fab5e58fcb - <rustc_middle[be94168a967605d5]::hir::map::Map>::par_body_owners::<rustc_hir_analysis[9feabfd3ed563fae]::check_crate::{closure#4}>::{closure#0}
44: 0x70fab5e57a8b - rustc_hir_analysis[9feabfd3ed563fae]::check_crate
45: 0x70fab66275fe - rustc_interface[c870be2efde3492c]::passes::analysis
46: 0x70fab662715b - 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]>>
47: 0x70fab698f725 - 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>
48: 0x70fab698f48f - rustc_query_impl[c0e0181520bdf354]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
49: 0x70fab682120e - rustc_interface[c870be2efde3492c]::interface::run_compiler::<core[6d46e2ae36dee942]::result::Result<(), rustc_span[41e37a1bb73e38bc]::ErrorGuaranteed>, rustc_driver_impl[4c120566f3914dcc]::run_compiler::{closure#0}>::{closure#1}
50: 0x70fab67e23c9 - 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>>
51: 0x70fab67e2172 - <<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}
52: 0x70fab7fc6bfb - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h5d22407a994a8dd7
at /rustc/32a3ed229caaaa6476ee1b0e644dd53579454536/library/alloc/src/boxed.rs:2063:9
53: 0x70fab7fc6bfb - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::he08091f4f7e587cf
at /rustc/32a3ed229caaaa6476ee1b0e644dd53579454536/library/alloc/src/boxed.rs:2063:9
54: 0x70fab7fc6bfb - std::sys::pal::unix::thread::Thread::new::thread_start::h4ffcec4576023b2b
at /rustc/32a3ed229caaaa6476ee1b0e644dd53579454536/library/std/src/sys/pal/unix/thread.rs:108:17
55: 0x70fab14aa1cf - <unknown>
56: 0x70fab152b6ec - <unknown>
57: 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 [evaluate_obligation] evaluating trait selection obligation `Quantity<f32, U>: ~const core::ops::arith::Add<^1_0>`
#1 [typeck] type-checking `add`
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`.
@rustbot label +F-generic_const_exprs
Metadata
Metadata
Assignees
Labels
Category: This is a bug.Call for participation: An issue has been fixed and does not reproduce, but no test has been added.`#![feature(adt_const_params)]``#![feature(effects)]``#![feature(generic_const_exprs)]`Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Relevant to the compiler team, which will review and decide on the PR/issue.This issue requires the use of incomplete features.