Skip to content

ICE: associated const projection is not supported yet #141562

Closed as duplicate of#134641
@moxian

Description

@moxian

Code

not minimal and extremely crude:
#![allow(incomplete_features)]
#![feature(associated_const_equality)]

#[allow(unused)]
pub(crate) use crate as real_time_fir_iir_filters;

use crate::conf::HighPass;
use crate::param::SecondOrderButterworthFilterConf;
use crate::param::SecondOrderButterworthFilterParam;

pub struct SecondOrderButterworthFilter<C = real_time_fir_iir_filters::conf::All, F = f64, P = OmegaSecondOrder<F>>
where
    F: real_time_fir_iir_filters::param::FilterFloat,
    C: SecondOrderButterworthFilterConf<Conf = C>,
    P: SecondOrderButterworthFilterParam<C, Conf = C> +
        real_time_fir_iir_filters::param::FilterParam<F = F>,
    [(); <C as ButterworthFilterConf<2>>::OUTPUTS]:  {}

impl< P,> real_time_fir_iir_filters::rtf::RtfBase for SecondOrderButterworthFilter<
    All,
    <P as real_time_fir_iir_filters::param::FilterParam>::F,  P,>
where
    All: SecondOrderButterworthFilterConf<Conf = All>,
    P:
        SecondOrderButterworthFilterParam<All, Conf = All> +
        real_time_fir_iir_filters::param::FilterParam {

}


impl< P,> real_time_fir_iir_filters::rtf::RtfBase for SecondOrderButterworthFilter<  HighPass,
  <P as real_time_fir_iir_filters::param::FilterParam>::F,  P,>
where
    HighPass: SecondOrderButterworthFilterConf<Conf = HighPass>,
    P:
        SecondOrderButterworthFilterParam<HighPass, Conf = HighPass> +
        real_time_fir_iir_filters::param::FilterParam 
{

}

pub mod param {
  use crate::conf::Conf;

  pub trait SecondOrderButterworthFilterConf = ButterworthFilterConf<2>;

  pub trait ButterworthFilterConf<const ORDER : usize>: Conf {
      type Conf: private::ButterworthFilterConfFinal<ORDER, Self>;
      const OUTPUTS: usize;
  }

  impl<C, const OUTPUTS : usize> ButterworthFilterConf<2> for C where
      C: SecondOrderFilterConf<OUTPUTS = const { OUTPUTS }> {}

  use crate::conf::Conf;
  use crate::conf::HighPass;

  pub trait SecondOrderFilterConf: Conf {
      type Conf: private::SecondOrderFilterConfFinal<Self>;
      const OUTPUTS: usize;
  }

  impl SecondOrderFilterConf for HighPass {
      const OUTPUTS: usize = 1;
  }




  pub trait SecondOrderButterworthFilterParam<C>: FilterParam +
      SecondOrderFilterParam<C> where C: Conf {
      type
          Conf: ButterworthFilterConf<2>;
      fn omega(&self)
      -> Omega<<Self as FilterParam>::F, 2>;
  }
  impl<P, C> SecondOrderButterworthFilterParam<C> for P where
      P: ButterworthFilterParam<C, Conf : ButterworthFilterConf<2>, ORDER =
      const 2, Omega = Omega<<Self as FilterParam>::F, 2>> +
      SecondOrderFilterParam<C>, C: Conf, [(); Self::ORDER]: {
      type Conf = <Self as ButterworthFilterParam<C>>::Conf;
      fn omega(&self) -> Omega<<Self as FilterParam>::F, 2> {
          ButterworthFilterParam::omega(self)
      }
  }

  pub trait FilterParam {
      const ORDER: usize = 0;
      type F: FilterFloat;
  }
} 

pub mod conf {
    use core::fmt::Debug;

    pub enum HighPass<const N: usize = 0> {}

    pub trait Conf: Sized + Copy + Debug + 'static {
        type Wildcard: Conf<CONF_TYPE = {
            ConfType::Wildcard
        }, Wildcard = <Self as Conf>::Wildcard>;
        const CONF_TYPE: ConfType;
    }
}

pub mod rtf {
    pub trait RtfBase: Sized {
        type Conf: conf::Conf;
        type F: FilterFloat;
        const OUTPUTS: usize;
        const IS_IIR: bool;
    }
}

This was discovered while trying to reduce #141489 , before I realized that the minimization is wrong since this ICEs on both recent nightly and stable with RUSTC_BOOTSTRAP, unlike the other issue, which only ICEs on latest.
So this perhaps has a different root cause...

Meta

rustc --version --verbose:

rustc 1.89.0-nightly (16d2276fa 2025-05-16)
binary: rustc
commit-hash: 16d2276fa6fccb0cc239a542d4c3f0eb46f660ec
commit-date: 2025-05-16
host: x86_64-pc-windows-msvc
release: 1.89.0-nightly
LLVM version: 20.1.4
Bisection points to nightly-2024-10-16. PRs in range:
 - #131690 (Rollup of 8 pull requests) by matthiaskrgr
   - #129424 (Stabilize `Pin::as_deref_mut()`)
   - #131332 (Fix clobber_abi and disallow SVE-related registers in Arm64EC inline assembly)
   - #131384 (Update precondition tests (especially for zero-size access to null))
   - #131430 (Special treatment empty tuple when suggest adding a string literal in format macro.)
   - #131550 (Make some tweaks to extern block diagnostics)
   - #131667 (Fix AArch64InlineAsmReg::emit)
   - #131679 (compiletest: Document various parts of compiletest's `lib.rs`)
   - #131682 (Tag PRs affecting compiletest with `A-compiletest`)
 - #129458 (Autodiff Upstreaming - enzyme frontend) by EnzymeAD
 - #131724 (Rollup of 7 pull requests) by matthiaskrgr
   - #130608 (Implemented `FromStr` for `CString` and `TryFrom<CString>` for `String`)
   - #130635 (Add `&pin (mut|const) T` type position sugar)
   - #130747 (improve error messages for `C-cmse-nonsecure-entry` functions)
   - #131137 (Add 1.82 release notes)
   - #131328 (Remove unnecessary sorts in `rustc_hir_analysis`)
   - #131496 (Stabilise `const_make_ascii`.)
   - #131706 (Fix two const-hacks)
 - #131727 (Miri subtree update) by RalfJung
   - #3972 (Avoid some needless monomorphizations) by rust-lang
   - #3968 (Added a variadic argument helper) by YohDeadfall
   - #3973 (ensure that a macOS os_unfair_lock that is moved while being held is not implicitly unlocked) by RalfJung
   - #3974 (use new check_min_arg_count helper in more places) by RalfJung-  
 - #131723 (Rollup of 9 pull requests) by matthiaskrgr
   - #122670 (Fix bug where `option_env!` would return `None` when env var is present but not valid Unicode)
   - #131095 (Use environment variables instead of command line arguments for merged doctests)
   - #131339 (Expand set_ptr_value / with_metadata_of docs)
   - #131652 (Move polarity into `PolyTraitRef` rather than storing it on the side)
   - #131675 (Update lint message for ABI not supported)
   - #131681 (Fix up-to-date checking for run-make tests)
   - #131702 (Suppress import errors for traits that couldve applied for method lookup error)
   - #131703 (Resolved python deprecation warning in publish_toolstate.py)
   - #131710 (Remove `'apostrophes'` from `rustc_parse_format`)
 - #130654 (stabilize `-Znext-solver=coherence` again) by lcnr
 - #131747 (Rollup of 7 pull requests) by compiler-errors
   - #129794 (uefi: Implement getcwd and chdir)
   - #130568 (Make some float methods unstable `const fn`)
   - #131521 (rename RcBox to RcInner for consistency)
   - #131701 (Don't report `on_unimplemented` message for negative traits)
   - #131705 (Fix most ui tests on emscripten target)
   - #131733 (Fix uninlined_format_args in stable_mir)
   - #131734 (Update `arm64e-apple-tvos` maintainer)

Error output

Backtrace

thread 'rustc' panicked at /rustc/16d2276fa6fccb0cc239a542d4c3f0eb46f660ec\compiler\rustc_next_trait_solver\src\solve\normalizes_to\mod.rs:373:25:
associated const projection is not supported yet
stack backtrace:
   0: std::panicking::begin_panic_handler
             at /rustc/16d2276fa6fccb0cc239a542d4c3f0eb46f660ec/library\std\src\panicking.rs:697
   1: core::panicking::panic_fmt
             at /rustc/16d2276fa6fccb0cc239a542d4c3f0eb46f660ec/library\core\src\panicking.rs:75
   2: <alloc::raw_vec::RawVec<rustc_trait_selection::solve::inspect::analyse::InspectCandidate>>::grow_one
   3: rustc_codegen_ssa::debuginfo::type_names::compute_debuginfo_vtable_name
   4: rustc_codegen_ssa::debuginfo::type_names::compute_debuginfo_vtable_name
   5: rustc_codegen_ssa::debuginfo::type_names::compute_debuginfo_vtable_name
   6: <alloc::raw_vec::RawVec<rustc_trait_selection::solve::inspect::analyse::InspectCandidate>>::grow_one
   7: <alloc::raw_vec::RawVec<rustc_trait_selection::solve::inspect::analyse::InspectCandidate>>::grow_one
   8: rustc_codegen_ssa::debuginfo::type_names::compute_debuginfo_vtable_name
   9: rustc_codegen_ssa::debuginfo::type_names::compute_debuginfo_vtable_name
  10: <alloc::raw_vec::RawVec<rustc_trait_selection::solve::inspect::analyse::InspectCandidate>>::grow_one
  11: <alloc::raw_vec::RawVec<rustc_trait_selection::solve::inspect::analyse::InspectCandidate>>::grow_one
  12: <alloc::raw_vec::RawVec<rustc_trait_selection::solve::inspect::analyse::InspectCandidate>>::grow_one
  13: rustc_codegen_ssa::debuginfo::type_names::compute_debuginfo_vtable_name
  14: rustc_codegen_ssa::debuginfo::type_names::compute_debuginfo_vtable_name
  15: rustc_codegen_ssa::debuginfo::type_names::compute_debuginfo_vtable_name
  16: <alloc::raw_vec::RawVec<rustc_trait_selection::solve::inspect::analyse::InspectCandidate>>::grow_one
  17: <alloc::raw_vec::RawVec<rustc_trait_selection::solve::inspect::analyse::InspectCandidate>>::grow_one
  18: <alloc::raw_vec::RawVec<rustc_trait_selection::solve::inspect::analyse::InspectCandidate>>::grow_one
  19: rustc_codegen_ssa::debuginfo::type_names::compute_debuginfo_vtable_name
  20: <alloc::raw_vec::RawVec<rustc_trait_selection::solve::inspect::analyse::InspectCandidate>>::grow_one
  21: rustc_codegen_ssa::mir::find_cold_blocks
  22: rustc_codegen_ssa::debuginfo::type_names::compute_debuginfo_vtable_name
  23: rustc_codegen_ssa::debuginfo::type_names::compute_debuginfo_vtable_name
  24: <alloc::raw_vec::RawVec<rustc_trait_selection::solve::inspect::analyse::InspectCandidate>>::grow_one
  25: <alloc::raw_vec::RawVec<rustc_trait_selection::solve::inspect::analyse::InspectCandidate>>::grow_one
  26: rustc_codegen_ssa::debuginfo::type_names::compute_debuginfo_vtable_name
  27: rustc_codegen_ssa::debuginfo::type_names::compute_debuginfo_vtable_name
  28: <alloc::raw_vec::RawVec<rustc_trait_selection::solve::inspect::analyse::InspectCandidate>>::grow_one
  29: <alloc::raw_vec::RawVec<rustc_trait_selection::solve::inspect::analyse::InspectCandidate>>::grow_one
  30: <alloc::raw_vec::RawVec<rustc_trait_selection::solve::inspect::analyse::InspectCandidate>>::grow_one
  31: rustc_codegen_ssa::debuginfo::type_names::compute_debuginfo_vtable_name
  32: rustc_codegen_ssa::debuginfo::type_names::compute_debuginfo_vtable_name
  33: rustc_codegen_ssa::debuginfo::type_names::compute_debuginfo_vtable_name
  34: <alloc::raw_vec::RawVec<rustc_trait_selection::solve::inspect::analyse::InspectCandidate>>::grow_one
  35: <alloc::raw_vec::RawVec<rustc_trait_selection::solve::inspect::analyse::InspectCandidate>>::grow_one
  36: rustc_trait_selection::traits::coherence::overlapping_impls
  37: <rustc_middle::traits::specialization_graph::Children as rustc_trait_selection::traits::specialize::specialization_graph::ChildrenExt>::insert
  38: <rustc_middle::traits::specialization_graph::Graph as rustc_trait_selection::traits::specialize::specialization_graph::GraphExt>::insert
  39: rustc_trait_selection::traits::specialize::specialization_graph_provider
  40: RINvNtNtCsceq9HnlmPNX_18rustc_query_system5query8plumbing17try_execute_queryINtCsgtgSloM9rKF_16rustc_query_impl13DynamicConfigINtNtCskJc15ZtcHlN_21rustc_data_structures9vec_cache8VecCacheNtNtCs58xKICPkfbi_10rustc_span6def_id8CrateNumINtNtNtCs6RMfinxcFgq_12
  41: RINvNtNtCsceq9HnlmPNX_18rustc_query_system5query8plumbing17try_execute_queryINtCsgtgSloM9rKF_16rustc_query_impl13DynamicConfigINtNtB4_6caches10DefIdCacheINtNtNtCs6RMfinxcFgq_12rustc_middle5query5erase6ErasedAhj8_EEKb0_KB3r_KB3r_ENtNtB1f_8plumbing9QueryCtxt
  42: rustc_query_impl::query_system
  43: <rustc_hir_analysis::autoderef::Autoderef>::into_obligations
  44: RINvNtNtCsceq9HnlmPNX_18rustc_query_system5query8plumbing17try_execute_queryINtCsgtgSloM9rKF_16rustc_query_impl13DynamicConfigINtNtCskJc15ZtcHlN_21rustc_data_structures9vec_cache8VecCacheNtNtCs58xKICPkfbi_10rustc_span6def_id8CrateNumINtNtNtCs6RMfinxcFgq_12
  45: RINvNtNtCsceq9HnlmPNX_18rustc_query_system5query8plumbing17try_execute_queryINtCsgtgSloM9rKF_16rustc_query_impl13DynamicConfigINtNtB4_6caches10DefIdCacheINtNtNtCs6RMfinxcFgq_12rustc_middle5query5erase6ErasedAhj1_EEKb0_KB3r_KB3r_ENtNtB1f_8plumbing9QueryCtxt
  46: rustc_query_impl::query_system
  47: rustc_hir_analysis::check::region::region_scope_tree
  48: rustc_hir_analysis::check::wfcheck::check_well_formed
  49: rustc_query_impl::plumbing::query_key_hash_verify_all
  50: RINvNtNtCsceq9HnlmPNX_18rustc_query_system5query8plumbing17try_execute_queryINtCsgtgSloM9rKF_16rustc_query_impl13DynamicConfigINtNtCskJc15ZtcHlN_21rustc_data_structures9vec_cache8VecCacheNtNtCs58xKICPkfbi_10rustc_span6def_id10LocalDefIdINtNtNtCs6RMfinxcFgq
  51: rustc_query_impl::plumbing::query_key_hash_verify_all
  52: rustc_hir_analysis::check::wfcheck::check_mod_type_wf
  53: RINvNtNtCsceq9HnlmPNX_18rustc_query_system5query8plumbing17try_execute_queryINtCsgtgSloM9rKF_16rustc_query_impl13DynamicConfigINtNtCskJc15ZtcHlN_21rustc_data_structures9vec_cache8VecCacheNtNtCs58xKICPkfbi_10rustc_span6def_id8CrateNumINtNtNtCs6RMfinxcFgq_12
  54: RINvNtNtCsceq9HnlmPNX_18rustc_query_system5query8plumbing17try_execute_queryINtCsgtgSloM9rKF_16rustc_query_impl13DynamicConfigINtNtB4_6caches12DefaultCacheNtNtCs58xKICPkfbi_10rustc_span6def_id13LocalModDefIdINtNtNtCs6RMfinxcFgq_12rustc_middle5query5erase6E
  55: rustc_query_impl::query_system
  56: rustc_hir_analysis::check_crate
  57: <rustc_interface::passes::LintStoreExpandImpl as rustc_expand::base::LintStoreExpand>::pre_expansion_lint
  58: rustc_interface::passes::analysis
  59: RINvNtNtCsceq9HnlmPNX_18rustc_query_system5query8plumbing17try_execute_queryINtCsgtgSloM9rKF_16rustc_query_impl13DynamicConfigINtNtCskJc15ZtcHlN_21rustc_data_structures9vec_cache8VecCacheNtNtCs58xKICPkfbi_10rustc_span6def_id8CrateNumINtNtNtCs6RMfinxcFgq_12
  60: RINvNtNtCsceq9HnlmPNX_18rustc_query_system5query8plumbing17try_execute_queryINtCsgtgSloM9rKF_16rustc_query_impl13DynamicConfigINtNtB4_6caches11SingleCacheINtNtNtCs6RMfinxcFgq_12rustc_middle5query5erase6ErasedAhj0_EEKb0_KB3s_KB3s_ENtNtB1f_8plumbing9QueryCtx
  61: rustc_query_impl::query_system
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 `H:\work\my\trash\rust-mini\thing\rustc-ice-2025-05-25T22_17_08-14304.txt` to your bug report

note: compiler flags: --crate-type lib -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 [specialization_graph_of] building specialization graph of trait `rtf::RtfBase`
#1 [coherent_trait] coherence checking all impls of trait `rtf::RtfBase`
#2 [check_well_formed] checking that `rtf::RtfBase::OUTPUTS` is well-formed
#3 [check_mod_type_wf] checking that types are well-formed in module `rtf`
#4 [analysis] running analysis passes on this crate
end of query stack

@rustbot label: +E-needs-mcve +F-associated_const_equality

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.F-associated_const_equality`#![feature(associated_const_equality)]`I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️S-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issueT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions