Open
Description
Code
#![feature(generic_const_exprs)]
#[derive(Default)]
pub struct GenId<const IDX: usize>;
pub trait IndexTrait: Default {
const IDX: usize;
}
pub trait ToplogyIndex {
type Idx: IndexTrait;
}
#[derive(Default)]
pub struct Expression<T: ToplogyIndex> {
pub data: T,
}
fn i<T: ToplogyIndex, const IDX0: usize, const IDX1: usize>(s: Expression<T>) -> Expression<GenId<{ IDX0 | IDX1 }>>
where
GenId<{ IDX0 | IDX1 }>: ToplogyIndex,
{
Expression::default()
}
pub fn sum<In: ToplogyIndex>(s: Expression<In>) -> Expression<In>
where
[(); In::Idx::IDX]:,
{
s
}
fn param_position<In: ToplogyIndex>(s: Expression<In>)
where
GenId<{ 1 | 2 }>: ToplogyIndex,
{
sum(i::<_, 1, 2>(s));
}
fn main() {}
Meta
rustc --version --verbose
:
rustc 1.87.0-nightly (b74da9613 2025-03-06)
binary: rustc
commit-hash: b74da9613a8cb5ba67a985f71325be0b7b16c0dd
commit-date: 2025-03-06
host: x86_64-unknown-linux-gnu
release: 1.87.0-nightly
LLVM version: 20.1.0
Error output
error: internal compiler error: compiler/rustc_middle/src/ty/normalize_erasing_regions.rs:169:13: Failed to normalize Alias(Projection, AliasTy { args: [GenId<(BitOr: (1_usize: usize), (2_usize: usize))>], def_id: DefId(0:6 ~ elements[46b7]::ToplogyIndex::Idx), .. }) in typing_env=TypingEnv { typing_mode: PostAnalysis, param_env: ParamEnv { caller_bounds: [Binder { value: ConstEvaluatable(UnevaluatedConst { def: DefId(0:18 ~ elements[46b7]::param_position::{constant#0}), args: [In/#0] }), bound_vars: [] }, Binder { value: TraitPredicate(<GenId<{ 1 | 2 }> as ToplogyIndex>, polarity:Positive), bound_vars: [] }, Binder { value: TraitPredicate(<In as ToplogyIndex>, polarity:Positive), bound_vars: [] }, Binder { value: TraitPredicate(<In as std::marker::Sized>, polarity:Positive), bound_vars: [] }] } }, maybe try to call `try_normalize_erasing_regions` instead
Backtrace
thread 'rustc' panicked at compiler/rustc_middle/src/ty/normalize_erasing_regions.rs:169:13:
Box<dyn Any>
stack backtrace:
0: std::panicking::begin_panic::<rustc_errors::ExplicitBug>
1: <rustc_errors::diagnostic::BugAbort as rustc_errors::diagnostic::EmissionGuarantee>::emit_producing_guarantee
2: rustc_middle::util::bug::opt_span_bug_fmt::<rustc_span::span_encoding::Span>::{closure#0}
3: rustc_middle::ty::context::tls::with_opt::<rustc_middle::util::bug::opt_span_bug_fmt<rustc_span::span_encoding::Span>::{closure#0}, !>::{closure#0}
4: rustc_middle::ty::context::tls::with_context_opt::<rustc_middle::ty::context::tls::with_opt<rustc_middle::util::bug::opt_span_bug_fmt<rustc_span::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
5: rustc_middle::util::bug::bug_fmt
6: <rustc_middle::ty::normalize_erasing_regions::NormalizeAfterErasingRegionsFolder as rustc_type_ir::fold::TypeFolder<rustc_middle::ty::context::TyCtxt>>::fold_ty
7: rustc_ty_utils::instance::resolve_instance_raw
[... omitted 1 frame ...]
8: <rustc_middle::ty::instance::Instance>::try_resolve
9: <rustc_middle::ty::context::TyCtxt>::const_eval_resolve_for_typeck
10: rustc_trait_selection::traits::try_evaluate_const
11: <rustc_trait_selection::traits::fulfill::FulfillProcessor as rustc_data_structures::obligation_forest::ObligationProcessor>::process_obligation
12: <rustc_data_structures::obligation_forest::ObligationForest<rustc_trait_selection::traits::fulfill::PendingPredicateObligation>>::process_obligations::<rustc_trait_selection::traits::fulfill::FulfillProcessor>
13: <rustc_trait_selection::traits::fulfill::FulfillmentContext<rustc_infer::traits::engine::ScrubbedTraitError> as rustc_infer::traits::engine::TraitEngine<rustc_infer::traits::engine::ScrubbedTraitError>>::select_all_or_error
14: <rustc_trait_selection::traits::const_evaluatable::satisfied_from_param_env::Visitor as rustc_type_ir::visit::TypeVisitor<rustc_middle::ty::context::TyCtxt>>::visit_const
15: rustc_trait_selection::traits::const_evaluatable::satisfied_from_param_env
16: rustc_trait_selection::traits::const_evaluatable::is_const_evaluatable.cold
17: <rustc_trait_selection::traits::fulfill::FulfillProcessor as rustc_data_structures::obligation_forest::ObligationProcessor>::process_obligation
18: <rustc_data_structures::obligation_forest::ObligationForest<rustc_trait_selection::traits::fulfill::PendingPredicateObligation>>::process_obligations::<rustc_trait_selection::traits::fulfill::FulfillProcessor>
19: <rustc_hir_typeck::fn_ctxt::FnCtxt>::confirm_builtin_call
20: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
21: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_block
22: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
23: rustc_hir_typeck::check::check_fn
24: rustc_hir_typeck::typeck_with_inspect::{closure#0}
[... omitted 1 frame ...]
25: <rustc_middle::ty::context::TyCtxt>::par_hir_body_owners::<rustc_hir_analysis::check_crate::{closure#3}>::{closure#0}
26: rustc_hir_analysis::check_crate
27: rustc_interface::passes::run_required_analyses
28: rustc_interface::passes::analysis
[... omitted 1 frame ...]
29: rustc_interface::passes::create_and_enter_global_ctxt::<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
30: 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.
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 `/home/jakob/SBB/sbb_content/rustc-ice-2025-03-07T10_20_03-133509.txt` to your bug report
note: compiler flags: --crate-type bin -C embed-bitcode=no -C debuginfo=2 -C incremental=[REDACTED]
note: some of the compiler flags provided by cargo are hidden
query stack during panic:
#0 [resolve_instance_raw] resolving instance `<<GenId<1 | 2> as ToplogyIndex>::Idx as IndexTrait>::IDX`
#1 [typeck] type-checking `param_position`
#2 [analysis] running analysis passes on this crate
end of query stack
[rustc-ice-2025-03-07T10_20_03-133509.txt](https://github.com/user-attachments/files/19124764/rustc-ice-2025-03-07T10_20_03-133509.txt)