-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ICE: collection encountered polymorphic constant: UnevaluatedConst #106423
Comments
Hi @frankblubaugh, cool to see someone interested in sci-rs. sci-rs makes heavy use of const generic sized arrays (provided by heapless) to allow functionality for no_std. I hit several ICEs across several nightly versions, while putting together the current crate functionality. Do be warned to keep track of what nightly works for you if you plan to use the crate as it is now. The features required by sci-rs are I find that the internal compiler error hits in 2022-11-27 but not 2022-11-26. I tried both the aarch64-apple-ios and aarch64-apple-darwin targets on a library that uses sci-rs like your example. sci-rs has a lot of const generic usage. The call that crashed was way down inside of the butter_st call near poly_st and heapless. Here is an example of how the functions calls use computed const generic values to compute math on the stack for no_std compatibility in this call tree. pub fn poly_st<F, const N: usize>(z: &Vec<F, N>) -> Vec<F, { N + 1 }>
where
F: ComplexField,
[(); { N + 1 }]: Sized,
{
let mut a: Vec<F, { N + 1 }> = Vec::new();
a.push(F::one());
const KER: usize = 2;
for zi in z {
let mut b = Vec::new();
b.resize(a.len() + 1, F::zero());
let k = [F::one(), -zi.clone()];
for i in 0..a.len() + KER - 1 {
let u_i = if i > a.len() { i - KER } else { 0 };
let u_f = i.min(a.len() - 1);
if u_i == u_f {
b[i] += a[u_i].clone() * k[i - u_i].clone();
} else {
for u in u_i..(u_f + 1) {
if i - u < KER {
b[i] += a[u].clone() * k[i - u].clone();
}
}
}
}
a = b;
}
let mut roots = z.clone();
sort_cplx_st(&mut roots);
let mut root_conjs = z
.iter()
.map(|zi| zi.clone().conjugate())
.collect::<Vec<_, N>>();
sort_cplx_st(&mut root_conjs);
if roots.into_iter().zip(root_conjs).all(|(a, b)| a == b) {
a = a
.into_iter()
.map(|ai| ComplexField::from_real(ai.real()))
.collect();
}
a
} Additionally, here is a call site for poly_st pub fn zpk2tf_st<C, F, const N: usize>(
z: &Vec<C, N>,
p: &Vec<C, N>,
k: F,
) -> BaFormatFilter<F, { N + 1 }>
where
C: ComplexField<RealField = F>,
F: Float + RealField,
[(); { N + 1 }]: Sized,
{
let b = poly_st(z)
.into_iter()
.map(|bi| <C as ComplexField>::from_real(k) * bi)
.collect::<Vec<_, _>>();
let a = poly_st(p);
// lots of math not shown
todo!()
} |
searched nightlies: from nightly-2022-11-25 to nightly-2022-12-01 bisected with cargo-bisect-rustc v0.6.5Host triple: aarch64-apple-darwin cargo bisect-rustc --end=2022-12-01 |
WG-prioritization assigning priority (Zulip discussion). @rustbot label -I-prioritize +P-medium |
@trueb2 Is there a github repo for |
@JulianKnodt you can use https://docs.rs/crate/cargo-download/latest to see the whole source locally. |
Somewhat minimized: #![feature(generic_const_exprs, generic_arg_infer)]
#![allow(incomplete_features)]
#![allow(unused)]
use core::mem::MaybeUninit;
pub struct Arr<T, const N: usize> {
v: [MaybeUninit<T>; N],
}
impl<T, const N: usize> Arr<T, N> {
const ELEM: MaybeUninit<T> = MaybeUninit::uninit();
const INIT: [MaybeUninit<T>; N] = [Self::ELEM; N]; // important for optimization of `new`
fn new() -> Self {
Arr { v: Self::INIT }
}
}
pub struct BaFormatFilter<const N: usize> {}
pub enum DigitalFilter<const N: usize>
where
[(); N * 2 + 1]: Sized,
[(); N * 2]: Sized,
{
Ba(BaFormatFilter<{ N * 2 + 1 }>),
}
pub fn iirfilter_st_copy<const N: usize, const M: usize>(_: [f32; M]) -> DigitalFilter<N>
where
[(); N * 2 + 1]: Sized,
[(); N * 2]: Sized,
{
let zpk = zpk2tf_st(&Arr::<f32, { N * 2 }>::new(), &Arr::<f32, { N * 2 }>::new());
DigitalFilter::Ba(zpk)
}
pub fn zpk2tf_st<const N: usize>(
_z: &Arr<f32, N>,
_p: &Arr<f32, N>,
) -> BaFormatFilter<{ N + 1 }>
where
[(); N + 1]: Sized,
{
BaFormatFilter {}
}
fn main() {
iirfilter_st_copy::<4, 2>([10., 50.,]);
} |
- rust-lang/rust#99173 - rust-lang/rust#103708 - rust-lang/rust#104827 - rust-lang/rust#105209 - rust-lang/rust#106298 - rust-lang/rust#106423 Signed-off-by: Yuki Okushi <jtitor@2k36.org> rust-lang/rust#99173 Signed-off-by: Yuki Okushi <jtitor@2k36.org>
…piler-errors dont randomly use `_` to print out const generic arguments const generics seem to get printed out as `_` for no reason a lot of the time, as someone who spends a lot of time with const generics this has gotten ✨ very annoying ✨. Latest example would be rust-lang#106423 where the ICE messaged formatted a `ty::Const` containing no infer vars, as `_`. For some reason printing of the const argument on arrays was custom instead of using the existing logic for printing `ty::Const`. Additionally the existing logic for printing `ty::Const` would print out `_` for anon consts that are in a separate crate leading to weird diagnostics (see second commit). There ought to be less cases of consts randomly getting printed as `_` hiding valuable info now.
…piler-errors dont randomly use `_` to print out const generic arguments const generics seem to get printed out as `_` for no reason a lot of the time, as someone who spends a lot of time with const generics this has gotten ✨ very annoying ✨. Latest example would be rust-lang#106423 where the ICE messaged formatted a `ty::Const` containing no infer vars, as `_`. For some reason printing of the const argument on arrays was custom instead of using the existing logic for printing `ty::Const`. Additionally the existing logic for printing `ty::Const` would print out `_` for anon consts that are in a separate crate leading to weird diagnostics (see second commit). There ought to be less cases of consts randomly getting printed as `_` hiding valuable info now.
I checked the GitHub Actions CI logs that picked up the nightly changes. The error logs are nicer now:
|
Given this is tagged with requires-nightly, I don't think it qualifies as a beta regression. Removing that label. |
Triage: Fixed on the latest nightly, marking as E-needs-test |
…xxxx, r=fmease add a couple more ice tests Fixes rust-lang#104779 Fixes rust-lang#106423 Fixes rust-lang#106444 Fixes rust-lang#101852 Fixes rust-lang#106874 Fixes rust-lang#105047 Fixes rust-lang#107228 Fixes rust-lang#99945
…xxxx, r=fmease add a couple more ice tests Fixes rust-lang#104779 Fixes rust-lang#106423 Fixes rust-lang#106444 Fixes rust-lang#101852 Fixes rust-lang#106874 Fixes rust-lang#105047 Fixes rust-lang#107228 Fixes rust-lang#99945
…xxxx, r=fmease add a couple more ice tests Fixes rust-lang#104779 Fixes rust-lang#106423 Fixes rust-lang#106444 Fixes rust-lang#101852 Fixes rust-lang#106874 Fixes rust-lang#105047 Fixes rust-lang#107228 Fixes rust-lang#99945
…xxxx, r=fmease add a couple more ice tests Fixes rust-lang#104779 Fixes rust-lang#106423 Fixes rust-lang#106444 Fixes rust-lang#101852 Fixes rust-lang#106874 Fixes rust-lang#105047 Fixes rust-lang#107228 Fixes rust-lang#99945
Rollup merge of rust-lang#122943 - matthiaskrgr:ice-tests-9xxxx-to-12xxxx, r=fmease add a couple more ice tests Fixes rust-lang#104779 Fixes rust-lang#106423 Fixes rust-lang#106444 Fixes rust-lang#101852 Fixes rust-lang#106874 Fixes rust-lang#105047 Fixes rust-lang#107228 Fixes rust-lang#99945
…xxxx, r=fmease add a couple more ice tests Fixes rust-lang#104779 Fixes rust-lang#106423 Fixes rust-lang#106444 Fixes rust-lang#101852 Fixes rust-lang#106874 Fixes rust-lang#105047 Fixes rust-lang#107228 Fixes rust-lang#99945
Code
Meta
rustc --version --verbose
:Error output
Backtrace
The text was updated successfully, but these errors were encountered: