1 // Regression test for #66768.
4 //-^ "dead code" is needed to reproduce the issue.
6 use std::marker::PhantomData;
7 use std::ops::{Add, Mul};
9 fn problematic_function<Space>(material_surface_element: Edge2dElement)
11 DefaultAllocator: FiniteElementAllocator<DimU1, Space>,
13 let _: Point2<f64> = material_surface_element.map_reference_coords().into();
16 impl<T> ArrayLength<T> for UTerm {
19 impl<T, N: ArrayLength<T>> ArrayLength<T> for UInt<N, B0> {
20 type ArrayType = GenericArrayImplEven<T, N>;
22 impl<T, N: ArrayLength<T>> ArrayLength<T> for UInt<N, B1> {
23 type ArrayType = GenericArrayImplOdd<T, N>;
25 impl<U> Add<U> for UTerm {
27 fn add(self, _: U) -> Self::Output {
31 impl<Ul, Ur> Add<UInt<Ur, B1>> for UInt<Ul, B0>
35 type Output = UInt<Sum<Ul, Ur>, B1>;
36 fn add(self, _: UInt<Ur, B1>) -> Self::Output {
40 impl<U> Mul<U> for UTerm {
42 fn mul(self, _: U) -> Self {
46 impl<Ul, B, Ur> Mul<UInt<Ur, B>> for UInt<Ul, B0>
50 type Output = UInt<Prod<Ul, UInt<Ur, B>>, B0>;
51 fn mul(self, _: UInt<Ur, B>) -> Self::Output {
55 impl<Ul, B, Ur> Mul<UInt<Ur, B>> for UInt<Ul, B1>
58 UInt<Prod<Ul, UInt<Ur, B>>, B0>: Add<UInt<Ur, B>>,
60 type Output = Sum<UInt<Prod<Ul, UInt<Ur, B>>, B0>, UInt<Ur, B>>;
61 fn mul(self, _: UInt<Ur, B>) -> Self::Output {
65 impl<N, R, C> Allocator<N, R, C> for DefaultAllocator
69 R::Value: Mul<C::Value>,
70 Prod<R::Value, C::Value>: ArrayLength<N>,
72 type Buffer = ArrayStorage<N, R, C>;
73 fn allocate_uninitialized(_: R, _: C) -> Self::Buffer {
76 fn allocate_from_iterator<I>(_: R, _: C, _: I) -> Self::Buffer {
80 impl<N, C> Allocator<N, Dynamic, C> for DefaultAllocator {
81 type Buffer = VecStorage<N, Dynamic, C>;
82 fn allocate_uninitialized(_: Dynamic, _: C) -> Self::Buffer {
85 fn allocate_from_iterator<I>(_: Dynamic, _: C, _: I) -> Self::Buffer {
89 impl DimName for DimU1 {
95 impl DimName for DimU2 {
101 impl<N, D> From<VectorN<N, D>> for Point<N, D>
103 DefaultAllocator: Allocator<N, D>,
105 fn from(_: VectorN<N, D>) -> Self {
109 impl<GeometryDim, NodalDim> FiniteElementAllocator<GeometryDim, NodalDim> for DefaultAllocator where
110 DefaultAllocator: Allocator<f64, GeometryDim> + Allocator<f64, NodalDim>
113 impl ReferenceFiniteElement for Edge2dElement {
114 type NodalDim = DimU1;
116 impl FiniteElement<DimU2> for Edge2dElement {
117 fn map_reference_coords(&self) -> Vector2<f64> {
122 type Owned<N, R, C> = <DefaultAllocator as Allocator<N, R, C>>::Buffer;
123 type MatrixMN<N, R, C> = Matrix<N, R, C, Owned<N, R, C>>;
124 type VectorN<N, D> = MatrixMN<N, D, DimU1>;
125 type Vector2<N> = VectorN<N, DimU2>;
126 type Point2<N> = Point<N, DimU2>;
127 type U1 = UInt<UTerm, B1>;
128 type U2 = UInt<UInt<UTerm, B1>, B0>;
129 type Sum<A, B> = <A as Add<B>>::Output;
130 type Prod<A, B> = <A as Mul<B>>::Output;
132 struct GenericArray<T, U: ArrayLength<T>> {
135 struct GenericArrayImplEven<T, U> {
139 struct GenericArrayImplOdd<T, U> {
147 _marker: PhantomData<(U, B)>,
149 struct DefaultAllocator;
153 struct Matrix<N, R, C, S> {
155 _phantoms: PhantomData<(N, R, C)>,
157 struct ArrayStorage<N, R, C>
161 R::Value: Mul<C::Value>,
162 Prod<R::Value, C::Value>: ArrayLength<N>,
164 _data: GenericArray<N, Prod<R::Value, C::Value>>,
166 struct VecStorage<N, R, C> {
173 DefaultAllocator: Allocator<N, D>,
175 _coords: VectorN<N, D>,
177 struct Edge2dElement;
179 trait ArrayLength<T> {
182 trait Allocator<Scalar, R, C = DimU1> {
184 fn allocate_uninitialized(nrows: R, ncols: C) -> Self::Buffer;
185 fn allocate_from_iterator<I>(nrows: R, ncols: C, iter: I) -> Self::Buffer;
191 trait FiniteElementAllocator<GeometryDim, NodalDim>:
192 Allocator<f64, GeometryDim> + Allocator<f64, NodalDim>
195 trait ReferenceFiniteElement {
198 trait FiniteElement<GeometryDim>: ReferenceFiniteElement
200 DefaultAllocator: FiniteElementAllocator<GeometryDim, Self::NodalDim>,
202 fn map_reference_coords(&self) -> VectorN<f64, GeometryDim>;