about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorYuki Okushi <huyuumi.dev@gmail.com>2020-01-15 08:34:33 +0900
committerYuki Okushi <huyuumi.dev@gmail.com>2020-01-15 23:41:37 +0900
commitce8fed65f5e6f75b91cff35aec21190714231091 (patch)
treedad5b0e2b70d523ed70f16fbf084cc648b2f7bee /src
parent406049df4948a2c93d50f2c72cfa0e2811695ef5 (diff)
downloadrust-ce8fed65f5e6f75b91cff35aec21190714231091.tar.gz
rust-ce8fed65f5e6f75b91cff35aec21190714231091.zip
Add test for issue-65918
Diffstat (limited to 'src')
-rw-r--r--src/test/ui/type-alias-impl-trait/issue-65918.rs49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/test/ui/type-alias-impl-trait/issue-65918.rs b/src/test/ui/type-alias-impl-trait/issue-65918.rs
new file mode 100644
index 00000000000..97efb85ef64
--- /dev/null
+++ b/src/test/ui/type-alias-impl-trait/issue-65918.rs
@@ -0,0 +1,49 @@
+// build-pass
+
+#![feature(type_alias_impl_trait)]
+
+use std::marker::PhantomData;
+
+/* copied Index and TryFrom for convinience (and simplicity) */
+trait MyIndex<T> {
+    type O;
+    fn my_index(self) -> Self::O;
+}
+trait MyFrom<T>: Sized {
+    type Error;
+    fn my_from(value: T) -> Result<Self, Self::Error>;
+}
+
+/* MCVE starts here */
+trait F {}
+impl F for () {}
+type DummyT<T> = impl F;
+fn _dummy_t<T>() -> DummyT<T> {}
+
+struct Phantom1<T>(PhantomData<T>);
+struct Phantom2<T>(PhantomData<T>);
+struct Scope<T>(Phantom2<DummyT<T>>);
+
+impl<T> Scope<T> {
+    fn new() -> Self {
+        unimplemented!()
+    }
+}
+
+impl<T> MyFrom<Phantom2<T>> for Phantom1<T> {
+    type Error = ();
+    fn my_from(_: Phantom2<T>) -> Result<Self, Self::Error> {
+        unimplemented!()
+    }
+}
+
+impl<T: MyFrom<Phantom2<DummyT<U>>>, U> MyIndex<Phantom1<T>> for Scope<U> {
+    type O = T;
+    fn my_index(self) -> Self::O {
+        MyFrom::my_from(self.0).ok().unwrap()
+    }
+}
+
+fn main() {
+    let _pos: Phantom1<DummyT<()>> = Scope::new().my_index();
+}