Closed
Description
I was trying to figure out how to write things with traits and hit an ICE. It looked similar to #28344, but that was closed well before 1.8, so hopefully this is useful.
I tried this code:
use std::ops::{AddAssign, Mul};
struct Vec3<T:Default>(T,T,T);
trait DotProduct {
type Output;
fn dot(&self, &Self) -> Self::Output;
}
impl<T:Default> DotProduct for Vec3<T> where T : Mul, <T as Mul>::Output : AddAssign+Default {
type Output = <T as Mul>::Output;
fn dot(&self, rhs: &Self) -> Self::Output {
<T as Mul>::Output::default()
}
}
And this happened:
compiler_panic.rs:13:6: 13:33 error: internal compiler error: Type parameter `Self/SelfSpace.0` (Self/SelfSpace/0) out of range when substituting (root type=Some(Self)) substs=Substs[types=[[];[];[]], regions=[[];[];[]]]
compiler_panic.rs:13 <T as Mul>::Output::default()
^~~~~~~~~~~~~~~~~~~~~~~~~~~
note: the compiler unexpectedly panicked. this is a bug.
Meta
rustc --version --verbose
:
rustc 1.8.0 (db2939409 2016-04-11)
binary: rustc
commit-hash: db2939409db26ab4904372c82492cd3488e4c44e
commit-date: 2016-04-11
host: x86_64-pc-windows-gnu
release: 1.8.0
Backtrace:
stack backtrace:
0: 0x61cc34dc - strncmp
1: 0x61cc2b5c - strncmp
2: 0x61c84d6f - strncmp
3: 0x67e9b9fb - strncmp
4: 0x67e9b991 - strncmp
5: 0x67f16665 - strncmp
6: 0x9b96e0 - strncmp
7: 0xa7af85 - strncmp
8: 0xa793ca - strncmp
9: 0xa81c26 - strncmp
10: 0xa80e38 - strncmp
11: 0xa8756e - strncmp
12: 0xa1a9f5 - strncmp
13: 0x9d9440 - strncmp
14: 0xa0b816 - strncmp
15: 0x9dfad2 - strncmp
16: 0x9f7c3d - strncmp
17: 0x9acf31 - strncmp
18: 0x9a3d90 - strncmp
19: 0x9a053d - strncmp
20: 0x9b1a89 - strncmp
21: 0x99b343 - strncmp
22: 0x98eb58 - strncmp
23: 0x985947 - strncmp
24: 0x6b34a430 - strncmp
25: 0x6b3488ac - strncmp
26: 0x6b3455f7 - strncmp
27: 0x6b317f4d - strncmp
28: 0x6b306226 - strncmp
29: 0x6b30376b - strncmp
30: 0x61caf9ba - strncmp
31: 0x6b30400c - strncmp
32: 0x61cc1209 - strncmp
33: 0x77125a4c - strncmp