|
| 1 | +// compile-flags: --crate-type lib |
| 2 | +// check-pass |
| 3 | +// |
| 4 | +// Regression test for issue #84399 |
| 5 | +// Tests that we keep the full `ParamEnv` when |
| 6 | +// caching predicates with freshened types in the global cache |
| 7 | + |
| 8 | +use std::marker::PhantomData; |
| 9 | +pub trait Allocator<R> { |
| 10 | + type Buffer; |
| 11 | +} |
| 12 | +pub struct DefaultAllocator; |
| 13 | +impl <R> Allocator<R> for DefaultAllocator { |
| 14 | + type Buffer = (); |
| 15 | +} |
| 16 | +pub type Owned<R> = <DefaultAllocator as Allocator<R>>::Buffer; |
| 17 | +pub type MatrixMN<R> = Matrix<R, Owned<R>>; |
| 18 | +pub type Matrix4<N> = Matrix<N, ()>; |
| 19 | +pub struct Matrix<R, S> { |
| 20 | + pub data: S, |
| 21 | + _phantoms: PhantomData<R>, |
| 22 | +} |
| 23 | +pub fn set_object_transform(matrix: &Matrix4<()>) { |
| 24 | + matrix.js_buffer_view(); |
| 25 | +} |
| 26 | +pub trait Storable { |
| 27 | + type Cell; |
| 28 | + fn slice_to_items(_buffer: &()) -> &[Self::Cell] { |
| 29 | + unimplemented!() |
| 30 | + } |
| 31 | +} |
| 32 | +pub type Cell<T> = <T as Storable>::Cell; |
| 33 | +impl<R> Storable for MatrixMN<R> |
| 34 | +where |
| 35 | + DefaultAllocator: Allocator<R>, |
| 36 | +{ |
| 37 | + type Cell = (); |
| 38 | +} |
| 39 | +pub trait JsBufferView { |
| 40 | + fn js_buffer_view(&self) -> usize { |
| 41 | + unimplemented!() |
| 42 | + } |
| 43 | +} |
| 44 | +impl<R> JsBufferView for [MatrixMN<R>] |
| 45 | +where |
| 46 | + DefaultAllocator: Allocator<R>, |
| 47 | + MatrixMN<R>: Storable, |
| 48 | + [Cell<MatrixMN<R>>]: JsBufferView, |
| 49 | +{ |
| 50 | + fn js_buffer_view(&self) -> usize { |
| 51 | + <MatrixMN<R> as Storable>::slice_to_items(&()).js_buffer_view() |
| 52 | + } |
| 53 | +} |
| 54 | +impl JsBufferView for [()] {} |
| 55 | +impl<R> JsBufferView for MatrixMN<R> where DefaultAllocator: Allocator<R> {} |
0 commit comments