-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Uninferred types/regions ICE for array impl with const generics #60744
Labels
A-const-generics
Area: const generics (parameters and arguments)
I-ICE
Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Comments
varkor
added
A-const-generics
Area: const generics (parameters and arguments)
I-ICE
Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
labels
May 11, 2019
#![feature(const_generics)]
use std::fmt;
struct Array<T>(T);
impl<T: fmt::Debug, const N: usize> fmt::Debug for Array<[T; N]> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_list().entries((&self.0 as &[T]).iter()).finish()
}
}
fn main() {
println!("{:?}", Array([1, 2, 3]));
} produces the same error, but used to produce a different one from the other snippet, so it's also worth including as a test case. |
This isn't specific to arrays. Here's another example: struct Foo<const X: u8>(u32);
impl<const X: u8> Clone for Foo<{X}> {
fn clone(&self) -> Self {
Foo(self.0)
}
}
#[test]
fn test_foo() {
let foo: Foo<4> = Foo(1);
foo.clone();
} Compiler output:
I noticed that it works correctly if I replace impl<const X: u8> Clone for Foo<{X}>
// with
impl Clone for Foo<4> rustc 1.36.0-nightly (50a0def 2019-05-21) running on x86_64-unknown-linux-gnu |
I've added a few test cases in #60742, so this should be fixed after that's merged. |
Centril
added a commit
to Centril/rust
that referenced
this issue
May 28, 2019
…eddyb Allow const parameters in array sizes to be unified Fixes rust-lang#60632. Fixes rust-lang#60744. Fixes rust-lang#60923. (The last commit should probably be viewed in isolation, as it just renames things from `type` to `kind`.) r? @eddyb
Centril
added a commit
to Centril/rust
that referenced
this issue
May 28, 2019
…eddyb Allow const parameters in array sizes to be unified Fixes rust-lang#60632. Fixes rust-lang#60744. Fixes rust-lang#60923. (The last commit should probably be viewed in isolation, as it just renames things from `type` to `kind`.) r? @eddyb
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
A-const-generics
Area: const generics (parameters and arguments)
I-ICE
Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
After #60742 is merged, the following produces:
results in:
(Before #60742, this resulted in a different ICE.)
The text was updated successfully, but these errors were encountered: