]> git.lizzy.rs Git - rust.git/commitdiff
Add test for issue-75053
authorYuki Okushi <huyuumi.dev@gmail.com>
Tue, 20 Oct 2020 08:07:27 +0000 (17:07 +0900)
committerYuki Okushi <huyuumi.dev@gmail.com>
Tue, 20 Oct 2020 08:07:27 +0000 (17:07 +0900)
src/test/ui/mir/issue-75053.rs [new file with mode: 0644]

diff --git a/src/test/ui/mir/issue-75053.rs b/src/test/ui/mir/issue-75053.rs
new file mode 100644 (file)
index 0000000..6e7211c
--- /dev/null
@@ -0,0 +1,48 @@
+// compile-flags: -Z mir-opt-level=2
+// build-pass
+
+#![feature(type_alias_impl_trait)]
+
+use std::marker::PhantomData;
+
+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>;
+}
+
+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();
+}