about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAaron Hill <aa1ronham@gmail.com>2021-05-01 17:55:19 -0400
committerAaron Hill <aa1ronham@gmail.com>2021-05-01 17:55:19 -0400
commit091b7ddcdd86189d7b01771bd0aff317f632b2f9 (patch)
treedc866eba091f8792574db3bb9227d02865a10757
parent91daf705b442c8200985eb7f2e99784898844263 (diff)
downloadrust-091b7ddcdd86189d7b01771bd0aff317f632b2f9.tar.gz
rust-091b7ddcdd86189d7b01771bd0aff317f632b2f9.zip
Add regression test
-rw-r--r--src/test/ui/traits/issue-84399-bad-fresh-caching.rs55
1 files changed, 55 insertions, 0 deletions
diff --git a/src/test/ui/traits/issue-84399-bad-fresh-caching.rs b/src/test/ui/traits/issue-84399-bad-fresh-caching.rs
new file mode 100644
index 00000000000..1494001564f
--- /dev/null
+++ b/src/test/ui/traits/issue-84399-bad-fresh-caching.rs
@@ -0,0 +1,55 @@
+// compile-flags: --crate-type lib
+// check-pass
+//
+// Regression test for issue #84399
+// Tests that we keep the full `ParamEnv` when
+// caching predicates with freshened types in the global cache
+
+use std::marker::PhantomData;
+pub trait Allocator<R> {
+    type Buffer;
+}
+pub struct DefaultAllocator;
+impl <R> Allocator<R> for DefaultAllocator {
+    type Buffer = ();
+}
+pub type Owned<R> = <DefaultAllocator as Allocator<R>>::Buffer;
+pub type MatrixMN<R> = Matrix<R, Owned<R>>;
+pub type Matrix4<N> = Matrix<N, ()>;
+pub struct Matrix<R, S> {
+    pub data: S,
+    _phantoms: PhantomData<R>,
+}
+pub fn set_object_transform(matrix: &Matrix4<()>) {
+    matrix.js_buffer_view();
+}
+pub trait Storable {
+    type Cell;
+    fn slice_to_items(_buffer: &()) -> &[Self::Cell] {
+        unimplemented!()
+    }
+}
+pub type Cell<T> = <T as Storable>::Cell;
+impl<R> Storable for MatrixMN<R>
+where
+    DefaultAllocator: Allocator<R>,
+{
+    type Cell = ();
+}
+pub trait JsBufferView {
+    fn js_buffer_view(&self) -> usize {
+        unimplemented!()
+    }
+}
+impl<R> JsBufferView for [MatrixMN<R>]
+where
+    DefaultAllocator: Allocator<R>,
+    MatrixMN<R>: Storable,
+    [Cell<MatrixMN<R>>]: JsBufferView,
+{
+    fn js_buffer_view(&self) -> usize {
+        <MatrixMN<R> as Storable>::slice_to_items(&()).js_buffer_view()
+    }
+}
+impl JsBufferView for [()] {}
+impl<R> JsBufferView for MatrixMN<R> where DefaultAllocator: Allocator<R> {}