-
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
Recursive type usage in function with Const Generics causes ICE #66205
Comments
Note: another example that also panics. I know, yes, expressions aren't yet supported as const parameters. But it has the same panic, which is WEIRD! When I wrote this one, I thought "okay maybe inside a #![feature(const_generics)]
#[allow(incomplete_features)]
struct Z<const N: usize>;
impl<const N: usize> Z<{N}> {
fn fact() -> i32 {
match N {
0 => 1,
_ => Z::<{
match N {
0 => 0,
_ => N - 1,
}
}>::fact()
}
}
} Error: error: internal compiler error: src/librustc/ty/subst.rs:651: const parameter `N/#0` (Const { ty: usize, val: Param(N/#0) }/0) out of range when substituting substs=[]
thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:890:9 |
Minified: #![feature(const_generics)]
fn fact<const N: usize>() {
fact::<{ N - 1 }>();
} I'm pretty sure that I saw this ICE before, but I can't find it ;/ |
This is just a result of having an expression ( |
No longer ICEs on the latest nightly |
Oh, the new output is interesting. It probably needs to be monomorphized so that the compiler detects the infinite recursion. And then we could also write one that doesn't have infinite recursion :3 In order to force an error, a test function should suffice right? |
What do you mean? |
I mean that I imagined it might detect that the function recurses infinitely onto itself. But I guess it reads it lazily, and lets monomorphization do the job of recursing the function? which would make a lot of sense to me. |
…-DPC Add regression tests for fixed ICEs Closes rust-lang#61747 (fixed from 1.41.0-nightly (4007d4e 2019-12-01)) Closes rust-lang#66205 (fixed from 1.41.0-nightly (4007d4e 2019-12-01)) Closes rust-lang#66270 (fixed by rust-lang#66246) Closes rust-lang#66868 (fixed by rust-lang#67071) Closes rust-lang#67424 (fixed by rust-lang#67160) Also picking a minor nit up from rust-lang#67071 with 101dd7b r? @Centril
…-DPC Add regression tests for fixed ICEs Closes rust-lang#61747 (fixed from 1.41.0-nightly (4007d4e 2019-12-01)) Closes rust-lang#66205 (fixed from 1.41.0-nightly (4007d4e 2019-12-01)) Closes rust-lang#66270 (fixed by rust-lang#66246) Closes rust-lang#66868 (fixed by rust-lang#67071) Closes rust-lang#67424 (fixed by rust-lang#67160) Also picking a minor nit up from rust-lang#67071 with 101dd7b r? @Centril
Add regression tests for fixed ICEs Closes rust-lang#61747 (fixed from 1.41.0-nightly (4007d4e 2019-12-01)) Closes rust-lang#66205 (fixed from 1.41.0-nightly (4007d4e 2019-12-01)) Closes rust-lang#66270 (fixed by rust-lang#66246) Closes rust-lang#67424 (fixed by rust-lang#67160) Also picking a minor nit up from rust-lang#67071 with 101dd7b r? @Centril
This is a toy example I made in order to later make tests which run for
T<const M: usize>
withM=0..N
.This is the error I get:
Error notes:
rustc 1.40.0-nightly (50f8aadd7 2019-11-07) running on x86_64-unknown-linux-gnu
compiler flags:
-C debuginfo=2 -C incremental --crate-type lib
Questions
I don't know if this kind of pattern is intended as part of the feature or in its future, but if not, I think it can be satisfied by using a procedural macro so that's probably alright.
The point of the pattern, as I mentioned at the beginning of the post, is to be able to test a particular generic type's implementation up to an arbitrary range of numeric constants. While implementing another project to help @varkor test the feature, I stumbled upon the problem of wanting to test hundreds of different constants, but having no way of doing so with say, a
for
loop over a range of constants. This is one way I thought of making it work.Am I making the right decisions here? How should I go about testing hundreds of constants? Thanks :)
The text was updated successfully, but these errors were encountered: