Skip to content

Instantly share code, notes, and snippets.

@bitshifter
Created April 14, 2018 01:20
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save bitshifter/afa4a3403802eebf9516ae7c3d174ba8 to your computer and use it in GitHub Desktop.
Minimal reproduction of rustc ICE issue #48638
use std::any::Any;
use std::fmt::Debug;
use std::marker::PhantomData;
// use std::ops::Mul;
pub trait Scalar: Copy + PartialEq + Debug + Any {}
impl Scalar for f64 {}
pub trait Dim: Any + Debug + Copy + PartialEq + Send {}
// pub trait DimName : Dim {
// type Value: NamedDim<Name = Self>;
// }
// pub trait NamedDim: Sized + Any/* + Unsigned*/ {
// type Name: DimName<Value = Self>;
// }
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub struct U1;
impl Dim for U1 {}
// impl DimName for U1 {}
pub unsafe trait ContiguousStorageMut<N: Scalar, R: Dim, C: Dim = U1> { }
pub trait Allocator<N: Scalar, R: Dim, C: Dim = U1>: Any + Sized {
type Buffer: ContiguousStorageMut<N, R, C> + Clone;
}
// #[repr(C)]
// pub struct MatrixArray<N, R, C>
// where
// R: DimName,
// C: DimName,
// R::Value: Mul<C::Value>,
// Prod<R::Value, C::Value>: ArrayLength<N>,
// {
// data: GenericArray<N, Prod<R::Value, C::Value>>,
// }
pub struct DefaultAllocator;
// impl<N, R, C> Allocator<N, R, C> for DefaultAllocator
// where
// N: Scalar,
// R: DimName,
// C: DimName,
// {
// type Buffer = MatrixArray<N, R, C>;
// }
pub type Owned<N, R, C = U1> = <DefaultAllocator as Allocator<N, R, C>>::Buffer;
#[repr(C)]
#[derive(Hash, Clone, Copy)]
pub struct Matrix<N: Scalar, R: Dim, C: Dim, S> {
pub data: S,
_phantoms: PhantomData<(N, R, C)>,
}
#[repr(packed)]
struct S {
x:Matrix<f64, U1, U1, Owned<f64, U1, U1>>,
}
fn main() {
}
@bitshifter
Copy link
Author

error: internal compiler error: librustc_typeck/check/wfcheck.rs:243: inference variables in Matrix<f64, U1, U1, _>
  --> src/main.rs:60:1
   |
60 | / struct S {
61 | |     x:Matrix<f64, U1, U1, Owned<f64, U1, U1>>,
62 | | }
   | |_^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment