Open
Description
auto-reduced (treereduce-rust):
#![feature(min_generic_const_args)]
enum Colour {
R,
G,
B,
W,
}
struct Led<const C: Colour> {}
impl Led<C> {
pub fn new() -> Led {
Led::<{ Colour::W }> {}
}
}
original:
#![feature(adt_const_params)]
#![feature(generic_const_exprs)]
#![feature(generic_arg_infer)]
#[derive(PartialEq, Eq)]
#[allow(dead_code)]
enum Colour {
R,
G,
B,
W,
}
struct Led<const C: Colour> {}
impl<const C: Colour> Led<C> {
pub fn new() -> Led<{ Colour::W }> {
Led::<{ Colour::W }> {}
}
}
fn main() {
let l = Led::<_>::new();
}
Version information
rustc 1.88.0-nightly (48f89e765 2025-04-09)
binary: rustc
commit-hash: 48f89e7659678f91a68c0c2d868180a0036ab32d
commit-date: 2025-04-09
host: x86_64-unknown-linux-gnu
release: 1.88.0-nightly
LLVM version: 20.1.2
Possibly related line of code:
rust/compiler/rustc_middle/src/ty/instance.rs
Lines 482 to 494 in 48f89e7
Command:
/home/matthias/.rustup/toolchains/master/bin/rustc -Zcrate-attr=feature(min_generic_const_args)
Program output
error[E0412]: cannot find type `C` in this scope
--> /tmp/icemaker_global_tempdir.z28WUAJGFSOZ/rustc_testrunner_tmpdir_reporting.d34pcMyh8VAF/mvce.rs:10:10
|
10 | impl Led<C> {
| ^ not found in this scope
|
help: you might be missing a type parameter
|
10 | impl<C> Led<C> {
| +++
warning: the feature `min_generic_const_args` is incomplete and may not be safe to use and/or cause compiler crashes
--> <crate attribute>:1:9
|
1 | feature(min_generic_const_args)
| ^^^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #132980 <https://github.com/rust-lang/rust/issues/132980> for more information
= note: `#[warn(incomplete_features)]` on by default
error[E0601]: `main` function not found in crate `mvce`
--> /tmp/icemaker_global_tempdir.z28WUAJGFSOZ/rustc_testrunner_tmpdir_reporting.d34pcMyh8VAF/mvce.rs:14:2
|
14 | }
| ^ consider adding a `main` function to `/tmp/icemaker_global_tempdir.z28WUAJGFSOZ/rustc_testrunner_tmpdir_reporting.d34pcMyh8VAF/mvce.rs`
error: `Colour` is forbidden as the type of a const generic parameter
--> /tmp/icemaker_global_tempdir.z28WUAJGFSOZ/rustc_testrunner_tmpdir_reporting.d34pcMyh8VAF/mvce.rs:8:21
|
8 | struct Led<const C: Colour> {}
| ^^^^^^
|
= 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
|
1 + #![feature(adt_const_params)]
|
error[E0747]: unresolved item provided when a constant was expected
--> /tmp/icemaker_global_tempdir.z28WUAJGFSOZ/rustc_testrunner_tmpdir_reporting.d34pcMyh8VAF/mvce.rs:10:10
|
10 | impl Led<C> {
| ^
|
help: if this generic argument was intended as a const parameter, surround it with braces
|
10 | impl Led<{ C }> {
| + +
error[E0107]: missing generics for struct `Led`
--> /tmp/icemaker_global_tempdir.z28WUAJGFSOZ/rustc_testrunner_tmpdir_reporting.d34pcMyh8VAF/mvce.rs:11:21
|
11 | pub fn new() -> Led {
| ^^^ expected 1 generic argument
|
note: struct defined here, with 1 generic parameter: `C`
--> /tmp/icemaker_global_tempdir.z28WUAJGFSOZ/rustc_testrunner_tmpdir_reporting.d34pcMyh8VAF/mvce.rs:8:8
|
8 | struct Led<const C: Colour> {}
| ^^^ ---------------
help: add missing generic argument
|
11 | pub fn new() -> Led<C> {
| +++
thread 'rustc' panicked at compiler/rustc_middle/src/ty/instance.rs:488:9:
assertion `left matches right` failed: `Instance::try_resolve` should only be used to resolve instances of functions, statics, and consts; to resolve associated types, use `try_normalize_erasing_regions`.
left: Ctor(Variant, Const)
right: DefKind::Fn | DefKind::AssocFn | DefKind::Const | DefKind::AssocConst |
DefKind::AnonConst | DefKind::InlineConst | DefKind::Static { .. } |
DefKind::Ctor(_, CtorKind::Fn) | DefKind::Closure |
DefKind::SyntheticCoroutineBody
stack backtrace:
0: 0x7ca5f569a5f3 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::hbda7938ad91daa71
1: 0x7ca5f5e06091 - core::fmt::write::hfcac35951f31bfd5
2: 0x7ca5f7221911 - std::io::Write::write_fmt::h69d457bf709d3faa
3: 0x7ca5f569a452 - std::sys::backtrace::BacktraceLock::print::h05237cc9fabaf381
4: 0x7ca5f569df3a - std::panicking::default_hook::{{closure}}::hc30470ec32c9e61a
5: 0x7ca5f569dabf - std::panicking::default_hook::h1a06328d8fcb4b65
6: 0x7ca5f46f3be3 - std[5a1f1ac0881987ae]::panicking::update_hook::<alloc[80a1e000ee70d0ff]::boxed::Box<rustc_driver_impl[3e4c5d0d05c5c229]::install_ice_hook::{closure#1}>>::{closure#0}
7: 0x7ca5f569e7b3 - std::panicking::rust_panic_with_hook::ha54ddc764a9f2927
8: 0x7ca5f569e4aa - std::panicking::begin_panic_handler::{{closure}}::h766080f7c8e9eb7a
9: 0x7ca5f569aac9 - std::sys::backtrace::__rust_end_short_backtrace::haf576155c2de2f94
10: 0x7ca5f569e16d - __rustc[10dcd0340a2c482b]::rust_begin_unwind
11: 0x7ca5f2082630 - core::panicking::panic_fmt::h005ce51f4b5ab7a3
12: 0x7ca5f40c5fba - core::panicking::assert_failed_inner::h4b65bb9eccf86241
13: 0x7ca5f4d00a84 - core[4dde9abed1c5489b]::panicking::assert_matches_failed::<rustc_hir[9c43573b07d67dbb]::def::DefKind>
14: 0x7ca5f62125ef - <rustc_middle[a8ce42bc99515a22]::ty::instance::Instance>::try_resolve
15: 0x7ca5f68e1695 - <rustc_middle[a8ce42bc99515a22]::ty::context::TyCtxt>::const_eval_resolve_for_typeck
16: 0x7ca5f68e11cc - rustc_trait_selection[9b8f5593c6c1191c]::traits::try_evaluate_const
17: 0x7ca5f68e0c83 - <rustc_trait_selection[9b8f5593c6c1191c]::traits::normalize::AssocTypeNormalizer as rustc_type_ir[f99837588d296a38]::fold::TypeFolder<rustc_middle[a8ce42bc99515a22]::ty::context::TyCtxt>>::fold_const
18: 0x7ca5f6250ef7 - <rustc_middle[a8ce42bc99515a22]::ty::Ty as rustc_type_ir[f99837588d296a38]::fold::TypeSuperFoldable<rustc_middle[a8ce42bc99515a22]::ty::context::TyCtxt>>::try_super_fold_with::<rustc_trait_selection[9b8f5593c6c1191c]::traits::normalize::AssocTypeNormalizer>
19: 0x7ca5f60a0a85 - <rustc_hir_typeck[7cddd7bac5f9e6c7]::fn_ctxt::FnCtxt>::normalize::<rustc_middle[a8ce42bc99515a22]::ty::Ty>
20: 0x7ca5f60dc6df - <rustc_hir_typeck[7cddd7bac5f9e6c7]::fn_ctxt::FnCtxt>::check_struct_path
21: 0x7ca5f697b00e - <rustc_hir_typeck[7cddd7bac5f9e6c7]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
22: 0x7ca5f69703f7 - <rustc_hir_typeck[7cddd7bac5f9e6c7]::fn_ctxt::FnCtxt>::check_expr_block
23: 0x7ca5f6977dfe - <rustc_hir_typeck[7cddd7bac5f9e6c7]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
24: 0x7ca5f60b5084 - rustc_hir_typeck[7cddd7bac5f9e6c7]::check::check_fn
25: 0x7ca5f60a259a - rustc_hir_typeck[7cddd7bac5f9e6c7]::typeck_with_inspect::{closure#0}
26: 0x7ca5f60a12b6 - rustc_query_impl[304b34704ffb34a2]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[304b34704ffb34a2]::query_impl::typeck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[a8ce42bc99515a22]::query::erase::Erased<[u8; 8usize]>>
27: 0x7ca5f607c66c - rustc_query_system[9941410aea4cdd96]::query::plumbing::try_execute_query::<rustc_query_impl[304b34704ffb34a2]::DynamicConfig<rustc_data_structures[7aca4433282a48ef]::vec_cache::VecCache<rustc_span[a10dda05a280b721]::def_id::LocalDefId, rustc_middle[a8ce42bc99515a22]::query::erase::Erased<[u8; 8usize]>, rustc_query_system[9941410aea4cdd96]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[304b34704ffb34a2]::plumbing::QueryCtxt, false>
28: 0x7ca5f607c0cb - rustc_query_impl[304b34704ffb34a2]::query_impl::typeck::get_query_non_incr::__rust_end_short_backtrace
29: 0x7ca5f607ac7e - rustc_hir_analysis[6987030d2b35bee6]::check_crate
30: 0x7ca5f68277e3 - rustc_interface[145e5df1fb885f40]::passes::run_required_analyses
31: 0x7ca5f6e2f09e - rustc_interface[145e5df1fb885f40]::passes::analysis
32: 0x7ca5f6e2f073 - rustc_query_impl[304b34704ffb34a2]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[304b34704ffb34a2]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[a8ce42bc99515a22]::query::erase::Erased<[u8; 0usize]>>
33: 0x7ca5f6dc42fd - rustc_query_system[9941410aea4cdd96]::query::plumbing::try_execute_query::<rustc_query_impl[304b34704ffb34a2]::DynamicConfig<rustc_query_system[9941410aea4cdd96]::query::caches::SingleCache<rustc_middle[a8ce42bc99515a22]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[304b34704ffb34a2]::plumbing::QueryCtxt, false>
34: 0x7ca5f6dc3ff8 - rustc_query_impl[304b34704ffb34a2]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
35: 0x7ca5f714f54b - rustc_interface[145e5df1fb885f40]::passes::create_and_enter_global_ctxt::<core[4dde9abed1c5489b]::option::Option<rustc_interface[145e5df1fb885f40]::queries::Linker>, rustc_driver_impl[3e4c5d0d05c5c229]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
36: 0x7ca5f6f49c39 - rustc_interface[145e5df1fb885f40]::interface::run_compiler::<(), rustc_driver_impl[3e4c5d0d05c5c229]::run_compiler::{closure#0}>::{closure#1}
37: 0x7ca5f6f1f945 - std[5a1f1ac0881987ae]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[145e5df1fb885f40]::util::run_in_thread_with_globals<rustc_interface[145e5df1fb885f40]::util::run_in_thread_pool_with_globals<rustc_interface[145e5df1fb885f40]::interface::run_compiler<(), rustc_driver_impl[3e4c5d0d05c5c229]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
38: 0x7ca5f6f2022b - <<std[5a1f1ac0881987ae]::thread::Builder>::spawn_unchecked_<rustc_interface[145e5df1fb885f40]::util::run_in_thread_with_globals<rustc_interface[145e5df1fb885f40]::util::run_in_thread_pool_with_globals<rustc_interface[145e5df1fb885f40]::interface::run_compiler<(), rustc_driver_impl[3e4c5d0d05c5c229]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[4dde9abed1c5489b]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
39: 0x7ca5f6f21637 - std::sys::pal::unix::thread::Thread::new::thread_start::hd9ac46f49686eea4
40: 0x7ca5f0c4e70a - <unknown>
41: 0x7ca5f0cd2aac - <unknown>
42: 0x0 - <unknown>
error: 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: please make sure that you have updated to the latest nightly
note: rustc 1.88.0-nightly (48f89e765 2025-04-09) running on x86_64-unknown-linux-gnu
note: compiler flags: -Z crate-attr=feature(min_generic_const_args) -Z dump-mir-dir=dir
query stack during panic:
#0 [typeck] type-checking `<impl at /tmp/icemaker_global_tempdir.z28WUAJGFSOZ/rustc_testrunner_tmpdir_reporting.d34pcMyh8VAF/mvce.rs:10:1: 10:12>::new`
#1 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 5 previous errors; 1 warning emitted
Some errors have detailed explanations: E0107, E0412, E0601, E0747.
For more information about an error, try `rustc --explain E0107`.
@rustbot label +F-min_generic_const_args