Open
Description
Code
#![feature(min_generic_const_args)]
#![allow(incomplete_features)]
trait Trait1 {
#[type_const]
const ASSOC: usize;
}
trait Q {
const ASSOC: usize;
}
impl<const N: usize> Q for [u8; N] {
const ASSOC: usize = 1;
}
pub fn test<Z: Trait1>() -> [u8; <[u8; Z::ASSOC] as Q>::ASSOC] {}
fn main() {}
A mutant from tests/ui/const-generics/bad-subst-const-kind.rs
Meta
rustc --version --verbose
:
rustc 1.89.0-nightly (1bbd62e54 2025-05-29)
binary: rustc
commit-hash: 1bbd62e547ba5cc08ccb44c27def3d33195d2dd5
commit-date: 2025-05-29
host: aarch64-apple-darwin
release: 1.89.0-nightly
LLVM version: 20.1.5
Error output
thread 'rustc' panicked at /rustc/1bbd62e547ba5cc08ccb44c27def3d33195d2dd5/compiler/rustc_type_ir/src/binder.rs:740:9:
expected type for `Z/#0` (Z/#0/0) but found Const(?0c) when instantiating, args=[?0c]
Backtrace
thread 'rustc' panicked at /rustc/1bbd62e547ba5cc08ccb44c27def3d33195d2dd5/compiler/rustc_type_ir/src/binder.rs:740:9:
expected type for `Z/#0` (Z/#0/0) but found Const(?0c) when instantiating, args=[?0c]
stack backtrace:
0: __rustc::rust_begin_unwind
1: core::panicking::panic_fmt
2: <rustc_type_ir::binder::ArgFolder<rustc_middle::ty::context::TyCtxt>>::type_param_expected
3: <rustc_type_ir::binder::ArgFolder<rustc_middle::ty::context::TyCtxt> as rustc_type_ir::fold::TypeFolder<rustc_middle::ty::context::TyCtxt>>::fold_ty
4: <&rustc_middle::ty::list::RawList<(), rustc_middle::ty::generic_args::GenericArg> as rustc_type_ir::fold::TypeFoldable<rustc_middle::ty::context::TyCtxt>>::fold_with::<rustc_type_ir::binder::ArgFolder<rustc_middle::ty::context::TyCtxt>>
5: <rustc_middle::ty::consts::Const as rustc_type_ir::fold::TypeSuperFoldable<rustc_middle::ty::context::TyCtxt>>::super_fold_with::<rustc_type_ir::binder::ArgFolder<rustc_middle::ty::context::TyCtxt>>
6: <rustc_middle::ty::Ty as rustc_type_ir::fold::TypeSuperFoldable<rustc_middle::ty::context::TyCtxt>>::super_fold_with::<rustc_type_ir::binder::ArgFolder<rustc_middle::ty::context::TyCtxt>>
7: <&rustc_middle::ty::list::RawList<(), rustc_middle::ty::generic_args::GenericArg> as rustc_type_ir::fold::TypeFoldable<rustc_middle::ty::context::TyCtxt>>::fold_with::<rustc_type_ir::binder::ArgFolder<rustc_middle::ty::context::TyCtxt>>
8: <rustc_middle::ty::consts::Const as rustc_type_ir::fold::TypeSuperFoldable<rustc_middle::ty::context::TyCtxt>>::super_fold_with::<rustc_type_ir::binder::ArgFolder<rustc_middle::ty::context::TyCtxt>>
9: rustc_trait_selection::traits::project::opt_normalize_projection_term
10: rustc_trait_selection::traits::project::normalize_projection_term
11: <rustc_trait_selection::traits::normalize::AssocTypeNormalizer>::normalize_trait_projection::{closure#0}
12: <rustc_trait_selection::traits::normalize::AssocTypeNormalizer as rustc_type_ir::fold::TypeFolder<rustc_middle::ty::context::TyCtxt>>::fold_const
13: <rustc_middle::ty::Ty as rustc_type_ir::fold::TypeSuperFoldable<rustc_middle::ty::context::TyCtxt>>::super_fold_with::<rustc_trait_selection::traits::normalize::AssocTypeNormalizer>
14: <rustc_infer::infer::at::At as rustc_trait_selection::traits::normalize::NormalizeExt>::normalize::<rustc_middle::ty::Ty>
15: <rustc_hir_analysis::check::wfcheck::WfCheckingCtxt>::normalize::<rustc_middle::ty::Ty>
16: rustc_hir_analysis::check::wfcheck::check_fn_or_method
17: rustc_hir_analysis::check::wfcheck::check_item_fn
18: rustc_hir_analysis::check::wfcheck::check_item
19: rustc_hir_analysis::check::wfcheck::check_well_formed
[... omitted 1 frame ...]
20: <rustc_middle::hir::ModuleItems>::par_opaques::<rustc_hir_analysis::check::wfcheck::check_mod_type_wf::{closure#4}>::{closure#0}
21: rustc_hir_analysis::check::wfcheck::check_mod_type_wf
[... omitted 1 frame ...]
22: rustc_hir_analysis::check_crate
23: rustc_interface::passes::run_required_analyses
24: rustc_interface::passes::analysis
[... omitted 1 frame ...]
25: rustc_interface::passes::create_and_enter_global_ctxt::<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2}>
26: rustc_interface::interface::run_compiler::<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
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: please attach the file at `/Users/jisukbyun/workspace/250203 scratch/rustc-ice-2025-05-30T16_11_31-96654.txt` to your bug report
query stack during panic:
#0 [check_well_formed] checking that `test` is well-formed
#1 [check_mod_type_wf] checking that types are well-formed in top-level module
#2 [analysis] running analysis passes on this crate
end of query stack
Bisects to
searched nightlies: from nightly-2025-01-01 to nightly-2025-05-30
regressed nightly: nightly-2025-05-24
searched commit range: 2eef478...3e674b0
regressed commit: 52bf0cf
bisected with cargo-bisect-rustc v0.6.9
Host triple: x86_64-unknown-linux-gnu
Reproduce with:
cargo bisect-rustc --end=2025-05-30 --regress ice --preserve --script rustc -- mgca_2.rs
Notes
- ICE location:
compiler/rustc_type_ir/src/binder.rs Line-740
rust/compiler/rustc_type_ir/src/binder.rs
Lines 739 to 748 in 1bbd62e
@rustbot label +F-min_generic_const_args