-
-
Notifications
You must be signed in to change notification settings - Fork 14.2k
Open
Labels
C-bugCategory: This is a bug.Category: This is a bug.F-adt_const_params`#![feature(adt_const_params)]``#![feature(adt_const_params)]`F-generic_const_exprs`#![feature(generic_const_exprs)]``#![feature(generic_const_exprs)]`F-min_generic_const_args`#![feature(min_generic_const_args)]``#![feature(min_generic_const_args)]`I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
may be dup of #150354
auto-reduced (treereduce-rust):
//@compile-flags: --edition=2024
#![feature(generic_const_exprs)]
#![feature(min_generic_const_args, adt_const_params)]
enum Option<T> {
Some(T),
None,
}
fn foo<const N: Option<u32>>() {}
fn bar<T>() {
foo::<{ Some::<u32> { 0: const {} } }>();
}original code
original:
#![feature(min_generic_const_args, adt_const_params)]
#![expect(incomplete_features)]
#[derive(Eq, N1, std::marker::ConstParamTy)]
enum Option<T> {
Some(T),
None,
}
use Option::Some;
fn foo<const N: Option<u32>>() {}
trait Tr {
#[type_const()]
//~^ ERROR malformed
//~| ERROR experimental
const N: usize;
}
fn bar<T>() {
// the initializer of `_0` is a `N` which is a legal const argument
// so this is ok.
foo::<{ Some::<u32> { 0: N } }>();
// this is allowed as mgca supports uses of assoc consts in the
// type system. ie `<T as Trait>::ASSOC` is a legal const argument
foo::<{ Some::<u32> { 0: N + 1 } }>();
// this on the other hand is not allowed as `N + 1` is not a legal
// const argument
foo::<{ Some::<u32> { 0: N + 1 } }>();
//~^ ERROR: complex const arguments must be placed inside of a `const` block
// this also is not allowed as generic parameters cannot be used
// in anon const const args
foo::<{ Some::<u32> { 0: const { N + 5_usize } } }>();
//~^ ERROR: generic parameters may not be used in const operations
}
fn main() {}Version information
rustc 1.94.0-nightly (efa32de15 2025-12-24)
binary: rustc
commit-hash: efa32de15b394620520f24781d8c55d4df6fa106
commit-date: 2025-12-24
host: x86_64-unknown-linux-gnu
release: 1.94.0-nightly
LLVM version: 21.1.8
Possibly related line of code:
rust/compiler/rustc_middle/src/ty/consts.rs
Lines 252 to 264 in efa32de
| } | |
| /// Panics if `self.kind != ty::ConstKind::Value`. | |
| pub fn to_value(self) -> ty::Value<'tcx> { | |
| match self.kind() { | |
| ty::ConstKind::Value(cv) => cv, | |
| _ => bug!("expected ConstKind::Value, got {:?}", self.kind()), | |
| } | |
| } | |
| /// Attempts to convert to a value. | |
| /// | |
| /// Note that this does not normalize the constant. |
Command:
/home/matthias/.rustup/toolchains/master/bin/rustc --edition=2024 -Zcrate-attr=feature(generic_const_exprs)
Program output
warning: the feature `min_generic_const_args` is incomplete and may not be safe to use and/or cause compiler crashes
--> /tmp/icemaker_global_tempdir.co1336ymRBvg/rustc_testrunner_tmpdir_reporting.OZjcV00ko7Dn/mvce.rs:1:12
|
1 | #![feature(min_generic_const_args, adt_const_params)]
| ^^^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #132980 <https://github.com/rust-lang/rust/issues/132980> for more information
= note: `#[warn(incomplete_features)]` on by default
warning: the feature `generic_const_exprs` is incomplete and may not be safe to use and/or cause compiler crashes
--> <crate attribute>:1:12
|
1 | #![feature(generic_const_exprs)]
| ^^^^^^^^^^^^^^^^^^^
|
= note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information
error[E0601]: `main` function not found in crate `mvce`
--> /tmp/icemaker_global_tempdir.co1336ymRBvg/rustc_testrunner_tmpdir_reporting.OZjcV00ko7Dn/mvce.rs:12:2
|
12 | }
| ^ consider adding a `main` function to `/tmp/icemaker_global_tempdir.co1336ymRBvg/rustc_testrunner_tmpdir_reporting.OZjcV00ko7Dn/mvce.rs`
error[E0741]: `Option<u32>` must implement `ConstParamTy` to be used as the type of a const generic parameter
--> /tmp/icemaker_global_tempdir.co1336ymRBvg/rustc_testrunner_tmpdir_reporting.OZjcV00ko7Dn/mvce.rs:8:17
|
8 | fn foo<const N: Option<u32>>() {}
| ^^^^^^^^^^^
|
help: add `#[derive(ConstParamTy, PartialEq, Eq)]` to the enum
|
3 + #[derive(ConstParamTy, PartialEq, Eq)]
4 | enum Option<T> {
|
error[E0308]: mismatched types
--> /tmp/icemaker_global_tempdir.co1336ymRBvg/rustc_testrunner_tmpdir_reporting.OZjcV00ko7Dn/mvce.rs:11:36
|
11 | foo::<{ Some::<u32> { 0: const {} } }>();
| ^^ expected `u32`, found `()`
error: internal compiler error: /rustc-dev/efa32de15b394620520f24781d8c55d4df6fa106/compiler/rustc_middle/src/ty/consts.rs:258:18: expected ConstKind::Value, got UnevaluatedConst { def: DefId(0:14 ~ mvce[0f08]::bar::{constant#0}), args: [T/#0] }
thread 'rustc' (3462838) panicked at /rustc-dev/efa32de15b394620520f24781d8c55d4df6fa106/compiler/rustc_middle/src/ty/consts.rs:258:18:
Box<dyn Any>
stack backtrace:
0: 0x7f77b285fda3 - <<std[8a52549f710fb415]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[9df9debe8b3ae22c]::fmt::Display>::fmt
1: 0x7f77b3010648 - core[9df9debe8b3ae22c]::fmt::write
2: 0x7f77b28764f6 - <std[8a52549f710fb415]::sys::stdio::unix::Stderr as std[8a52549f710fb415]::io::Write>::write_fmt
3: 0x7f77b2836548 - std[8a52549f710fb415]::panicking::default_hook::{closure#0}
4: 0x7f77b2853c13 - std[8a52549f710fb415]::panicking::default_hook
5: 0x7f77b182d377 - std[8a52549f710fb415]::panicking::update_hook::<alloc[d3a84aa4019980d4]::boxed::Box<rustc_driver_impl[84ab8a953ff30580]::install_ice_hook::{closure#1}>>::{closure#0}
6: 0x7f77b2853ef2 - std[8a52549f710fb415]::panicking::panic_with_hook
7: 0x7f77b186a4c1 - std[8a52549f710fb415]::panicking::begin_panic::<rustc_errors[699e0d49929a30bc]::ExplicitBug>::{closure#0}
8: 0x7f77b185aa06 - std[8a52549f710fb415]::sys::backtrace::__rust_end_short_backtrace::<std[8a52549f710fb415]::panicking::begin_panic<rustc_errors[699e0d49929a30bc]::ExplicitBug>::{closure#0}, !>
9: 0x7f77b1857da9 - std[8a52549f710fb415]::panicking::begin_panic::<rustc_errors[699e0d49929a30bc]::ExplicitBug>
10: 0x7f77b18884b1 - <rustc_errors[699e0d49929a30bc]::diagnostic::BugAbort as rustc_errors[699e0d49929a30bc]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
11: 0x7f77b1e37099 - rustc_middle[6c8ebc09c5dee75c]::util::bug::opt_span_bug_fmt::<rustc_span[f43d92d060b6ef6a]::span_encoding::Span>::{closure#0}
12: 0x7f77b1e37222 - rustc_middle[6c8ebc09c5dee75c]::ty::context::tls::with_opt::<rustc_middle[6c8ebc09c5dee75c]::util::bug::opt_span_bug_fmt<rustc_span[f43d92d060b6ef6a]::span_encoding::Span>::{closure#0}, !>::{closure#0}
13: 0x7f77b1e280fb - rustc_middle[6c8ebc09c5dee75c]::ty::context::tls::with_context_opt::<rustc_middle[6c8ebc09c5dee75c]::ty::context::tls::with_opt<rustc_middle[6c8ebc09c5dee75c]::util::bug::opt_span_bug_fmt<rustc_span[f43d92d060b6ef6a]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
14: 0x7f77af83a3c4 - rustc_middle[6c8ebc09c5dee75c]::util::bug::bug_fmt
15: 0x7f77b1e46a3d - <rustc_middle[6c8ebc09c5dee75c]::ty::consts::Const>::to_value
16: 0x7f77b27adca9 - rustc_ty_utils[4ecae0266dc2b209]::consts::destructure_const
17: 0x7f77b2234546 - rustc_query_impl[741bec1d205ed836]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[741bec1d205ed836]::query_impl::destructure_const::dynamic_query::{closure#2}::{closure#0}, rustc_middle[6c8ebc09c5dee75c]::query::erase::Erased<[u8; 24usize]>>
18: 0x7f77b2337e49 - <rustc_query_impl[741bec1d205ed836]::query_impl::destructure_const::dynamic_query::{closure#2} as core[9df9debe8b3ae22c]::ops::function::FnOnce<(rustc_middle[6c8ebc09c5dee75c]::ty::context::TyCtxt, rustc_middle[6c8ebc09c5dee75c]::ty::consts::Const)>>::call_once
19: 0x7f77b225c4ca - rustc_query_system[d1e761e268b8884b]::query::plumbing::try_execute_query::<rustc_query_impl[741bec1d205ed836]::DynamicConfig<rustc_query_system[d1e761e268b8884b]::query::caches::DefaultCache<rustc_middle[6c8ebc09c5dee75c]::ty::consts::Const, rustc_middle[6c8ebc09c5dee75c]::query::erase::Erased<[u8; 24usize]>>, false, false, false>, rustc_query_impl[741bec1d205ed836]::plumbing::QueryCtxt, false>
20: 0x7f77b22d11c9 - rustc_query_impl[741bec1d205ed836]::query_impl::destructure_const::get_query_non_incr::__rust_end_short_backtrace
21: 0x7f77b1ecded2 - <rustc_middle[6c8ebc09c5dee75c]::ty::print::pretty::FmtPrinter as rustc_middle[6c8ebc09c5dee75c]::ty::print::pretty::PrettyPrinter>::pretty_print_const_valtree
22: 0x7f77b2626c7f - <rustc_trait_selection[5e395e029186e477]::error_reporting::TypeErrCtxt>::report_selection_error
23: 0x7f77b1165dfa - <rustc_trait_selection[5e395e029186e477]::error_reporting::TypeErrCtxt>::report_fulfillment_errors
24: 0x7f77b3236362 - <rustc_hir_typeck[8cc08117c3dde91c]::fn_ctxt::FnCtxt>::check_expr_call
25: 0x7f77b320c9f1 - <rustc_hir_typeck[8cc08117c3dde91c]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
26: 0x7f77b3207b3b - <rustc_hir_typeck[8cc08117c3dde91c]::fn_ctxt::FnCtxt>::check_expr_block
27: 0x7f77b320c9cc - <rustc_hir_typeck[8cc08117c3dde91c]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
28: 0x7f77b31ed749 - rustc_hir_typeck[8cc08117c3dde91c]::check::check_fn
29: 0x7f77b39ce379 - rustc_hir_typeck[8cc08117c3dde91c]::typeck_with_inspect::{closure#0}
30: 0x7f77b39cccf4 - rustc_query_impl[741bec1d205ed836]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[741bec1d205ed836]::query_impl::typeck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[6c8ebc09c5dee75c]::query::erase::Erased<[u8; 8usize]>>
31: 0x7f77b33251f7 - rustc_query_system[d1e761e268b8884b]::query::plumbing::try_execute_query::<rustc_query_impl[741bec1d205ed836]::DynamicConfig<rustc_data_structures[ededeb3d82402ac5]::vec_cache::VecCache<rustc_span[f43d92d060b6ef6a]::def_id::LocalDefId, rustc_middle[6c8ebc09c5dee75c]::query::erase::Erased<[u8; 8usize]>, rustc_query_system[d1e761e268b8884b]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[741bec1d205ed836]::plumbing::QueryCtxt, false>
32: 0x7f77b3324ac9 - rustc_query_impl[741bec1d205ed836]::query_impl::typeck::get_query_non_incr::__rust_end_short_backtrace
33: 0x7f77b379b0f1 - <rustc_middle[6c8ebc09c5dee75c]::ty::context::TyCtxt>::par_hir_body_owners::<rustc_hir_analysis[6d86651e35dd2117]::check_crate::{closure#2}>::{closure#0}
34: 0x7f77b379ab03 - rustc_hir_analysis[6d86651e35dd2117]::check_crate
35: 0x7f77b3edee9b - rustc_interface[f52ab86d5a555b2e]::passes::analysis
36: 0x7f77b3edeaf5 - rustc_query_impl[741bec1d205ed836]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[741bec1d205ed836]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[6c8ebc09c5dee75c]::query::erase::Erased<[u8; 0usize]>>
37: 0x7f77b420e766 - rustc_query_system[d1e761e268b8884b]::query::plumbing::try_execute_query::<rustc_query_impl[741bec1d205ed836]::DynamicConfig<rustc_query_system[d1e761e268b8884b]::query::caches::SingleCache<rustc_middle[6c8ebc09c5dee75c]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[741bec1d205ed836]::plumbing::QueryCtxt, false>
38: 0x7f77b420e336 - rustc_query_impl[741bec1d205ed836]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
39: 0x7f77b4385011 - <rustc_interface[f52ab86d5a555b2e]::passes::create_and_enter_global_ctxt<core[9df9debe8b3ae22c]::option::Option<rustc_interface[f52ab86d5a555b2e]::queries::Linker>, rustc_driver_impl[84ab8a953ff30580]::run_compiler::{closure#0}::{closure#2}>::{closure#2} as core[9df9debe8b3ae22c]::ops::function::FnOnce<(&rustc_session[4724149daa9f2ace]::session::Session, rustc_middle[6c8ebc09c5dee75c]::ty::context::CurrentGcx, alloc[d3a84aa4019980d4]::sync::Arc<rustc_data_structures[ededeb3d82402ac5]::jobserver::Proxy>, &std[8a52549f710fb415]::sync::once_lock::OnceLock<rustc_middle[6c8ebc09c5dee75c]::ty::context::GlobalCtxt>, &rustc_data_structures[ededeb3d82402ac5]::sync::worker_local::WorkerLocal<rustc_middle[6c8ebc09c5dee75c]::arena::Arena>, &rustc_data_structures[ededeb3d82402ac5]::sync::worker_local::WorkerLocal<rustc_hir[d3cd5594ffcae9cc]::Arena>, rustc_driver_impl[84ab8a953ff30580]::run_compiler::{closure#0}::{closure#2})>>::call_once::{shim:vtable#0}
40: 0x7f77b41ce48a - rustc_interface[f52ab86d5a555b2e]::interface::run_compiler::<(), rustc_driver_impl[84ab8a953ff30580]::run_compiler::{closure#0}>::{closure#1}
41: 0x7f77b414c3ce - std[8a52549f710fb415]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[f52ab86d5a555b2e]::util::run_in_thread_with_globals<rustc_interface[f52ab86d5a555b2e]::util::run_in_thread_pool_with_globals<rustc_interface[f52ab86d5a555b2e]::interface::run_compiler<(), rustc_driver_impl[84ab8a953ff30580]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
42: 0x7f77b414c1a0 - <std[8a52549f710fb415]::thread::lifecycle::spawn_unchecked<rustc_interface[f52ab86d5a555b2e]::util::run_in_thread_with_globals<rustc_interface[f52ab86d5a555b2e]::util::run_in_thread_pool_with_globals<rustc_interface[f52ab86d5a555b2e]::interface::run_compiler<(), rustc_driver_impl[84ab8a953ff30580]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[9df9debe8b3ae22c]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
43: 0x7f77b414a578 - <std[8a52549f710fb415]::sys::thread::unix::Thread>::new::thread_start
44: 0x7f77ad89698b - <unknown>
45: 0x7f77ad91a9cc - <unknown>
46: 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.94.0-nightly (efa32de15 2025-12-24) running on x86_64-unknown-linux-gnu
note: compiler flags: -Z crate-attr=feature(generic_const_exprs) -Z dump-mir-dir=dir
query stack during panic:
#0 [destructure_const] destructuring type level constant
#1 [typeck] type-checking `bar`
#2 [analysis] running analysis passes on crate `mvce`
end of query stack
error: aborting due to 4 previous errors; 2 warnings emitted
Some errors have detailed explanations: E0308, E0601, E0741.
For more information about an error, try `rustc --explain E0308`.
@rustbot label +F-min_generic_const_args +F-adt_const_params +F-generic_const_exprs
Metadata
Metadata
Assignees
Labels
C-bugCategory: This is a bug.Category: This is a bug.F-adt_const_params`#![feature(adt_const_params)]``#![feature(adt_const_params)]`F-generic_const_exprs`#![feature(generic_const_exprs)]``#![feature(generic_const_exprs)]`F-min_generic_const_args`#![feature(min_generic_const_args)]``#![feature(min_generic_const_args)]`I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.