Closed
Description
I was writing some generic code over vectors using the under-construction feature of const generics, and had a circular chain of super-traits that required me to cast the Self type to the trait as can be seen in the Div
supertrait requirement. I believe that is causing the MIR error.
I think this may be related to #66906 but it is subtly different so I'm putting the issue up regardless.
Code
#![feature(const_generics)]
use std::ops::Div;
use num::Float;
/// Abstract vector over some finite field
pub trait Vector<const N: usize>: Div<<Self as Vector<N>>::Field, Output = Self> + Copy {
type Field: Float;
fn cons(vs: [Self::Field; N]) -> Self { todo!() }
}
Meta
rustc --version --verbose
:
I updated my rust version on nightly right before I ran this so hopefully it is up to date:
rustc 1.44.0-nightly (f509b26a7 2020-03-18)
binary: rustc
commit-hash: f509b26a7730d721ef87423a72b3fdf8724b4afa
commit-date: 2020-03-18
host: x86_64-apple-darwin
release: 1.44.0-nightly
LLVM version: 9.0
Error output
... Warnings Elided for convenience...
warning: Error finalizing incremental compilation session directory `/Users/julianknodt/Desktop/programming/projects/rustjects/gfx/target/debug/incremental/ray_weekend-1jydezk8mz1tf/s-flpmnsfnok-1ritjvd-working`: No such file or directory (os error 2)
error: internal compiler error: mir_const_qualif: MIR had errors
--> src/vec.rs:8:55
|
8 | pub trait Vector<const N: usize>: Div<<Self as Vector<N>>::Field, Output = Self> + Copy {
| ^
error: internal compiler error: PromoteTemps: MIR had errors
--> src/vec.rs:8:55
|
8 | pub trait Vector<const N: usize>: Div<<Self as Vector<N>>::Field, Output = Self> + Copy {
| ^
error: internal compiler error: broken MIR in DefId(0:2682 ~ ray_weekend[6635]::vec[0]::Vector[0]::{{constant}}[0]) ("return type"): bad type [type error]
--> src/vec.rs:8:55
|
8 | pub trait Vector<const N: usize>: Div<<Self as Vector<N>>::Field, Output = Self> + Copy {
| ^
error: internal compiler error: broken MIR in DefId(0:2682 ~ ray_weekend[6635]::vec[0]::Vector[0]::{{constant}}[0]) (LocalDecl { mutability: Mut, local_info: Other, internal: false, is_block_tail: None, ty: [type error], user_ty: UserTypeProjections { contents: [] }, source_info: SourceInfo { span: src/vec.rs:8:55: 8:56, scope: scope[0] } }): bad type [type error]
--> src/vec.rs:8:55
|
8 | pub trait Vector<const N: usize>: Div<<Self as Vector<N>>::Field, Output = Self> + Copy {
| ^
thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', src/librustc_errors/lib.rs:360:17
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
error: internal compiler error: unexpected panic
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports
note: rustc 1.44.0-nightly (f509b26a7 2020-03-18) running on x86_64-apple-darwin
note: compiler flags: -C debuginfo=2 -C incremental --crate-type lib
note: some of the compiler flags provided by cargo are hidden
error: could not compile `ray_weekend`.
To learn more, run the command again with --verbose.
Backtrace
...Warnings elided for clarity...
warning: Error finalizing incremental compilation session directory `/Users/julianknodt/Desktop/programming/projects/rustjects/gfx/target/debug/incremental/ray_weekend-1jydezk8mz1tf/s-flpmrtevdl-1q49gen-working`: No such file or directory (os error 2)
error: internal compiler error: mir_const_qualif: MIR had errors
--> src/vec.rs:8:55
|
8 | pub trait Vector<const N: usize>: Div<<Self as Vector<N>>::Field, Output = Self> + Copy {
| ^
error: internal compiler error: PromoteTemps: MIR had errors
--> src/vec.rs:8:55
|
8 | pub trait Vector<const N: usize>: Div<<Self as Vector<N>>::Field, Output = Self> + Copy {
| ^
error: internal compiler error: broken MIR in DefId(0:2682 ~ ray_weekend[6635]::vec[0]::Vector[0]::{{constant}}[0]) ("return type"): bad type [type error]
--> src/vec.rs:8:55
|
8 | pub trait Vector<const N: usize>: Div<<Self as Vector<N>>::Field, Output = Self> + Copy {
| ^
error: internal compiler error: broken MIR in DefId(0:2682 ~ ray_weekend[6635]::vec[0]::Vector[0]::{{constant}}[0]) (LocalDecl { mutability: Mut, local_info: Other, internal: false, is_block_tail: None, ty: [type error], user_ty: UserTypeProjections { contents: [] }, source_info: SourceInfo { span: src/vec.rs:8:55: 8:56, scope: scope[0] } }): bad type [type error]
--> src/vec.rs:8:55
|
8 | pub trait Vector<const N: usize>: Div<<Self as Vector<N>>::Field, Output = Self> + Copy {
| ^
thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', src/librustc_errors/lib.rs:360:17
stack backtrace:
0: <unknown>
1: <unknown>
2: <unknown>
3: <unknown>
4: <unknown>
5: <unknown>
6: <unknown>
7: <unknown>
8: <unknown>
9: <unknown>
10: <unknown>
11: <unknown>
12: <unknown>
13: <unknown>
14: <unknown>
15: <unknown>
16: <unknown>
17: <unknown>
18: <unknown>
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
error: internal compiler error: unexpected panic
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports
note: rustc 1.44.0-nightly (f509b26a7 2020-03-18) running on x86_64-apple-darwin
note: compiler flags: -C debuginfo=2 -C incremental --crate-type lib
note: some of the compiler flags provided by cargo are hidden
query stack during panic:
end of query stack
error: could not compile `ray_weekend`.
To learn more, run the command again with --verbose.
This issue has been assigned to @lcnr via this comment.