1 // compile-flags: -Z mir-opt-level=3
3 #![feature(type_alias_impl_trait, rustc_attrs)]
5 use std::marker::PhantomData;
9 fn my_index(self) -> Self::O;
11 trait MyFrom<T>: Sized {
13 fn my_from(value: T) -> Result<Self, Self::Error>;
18 type DummyT<T> = impl F;
19 fn _dummy_t<T>() -> DummyT<T> {}
21 struct Phantom1<T>(PhantomData<T>);
22 struct Phantom2<T>(PhantomData<T>);
23 struct Scope<T>(Phantom2<DummyT<T>>);
31 impl<T> MyFrom<Phantom2<T>> for Phantom1<T> {
33 fn my_from(_: Phantom2<T>) -> Result<Self, Self::Error> {
38 impl<T: MyFrom<Phantom2<DummyT<U>>>, U> MyIndex<Phantom1<T>> for Scope<U> {
40 fn my_index(self) -> Self::O {
41 MyFrom::my_from(self.0).ok().unwrap()
48 let _pos: Phantom1<DummyT<()>> = Scope::new().my_index();