]> git.proxmox.com Git - rustc.git/blame - src/test/ui/type-alias-impl-trait/issue-65918.rs
New upstream version 1.56.0~beta.4+dfsg1
[rustc.git] / src / test / ui / type-alias-impl-trait / issue-65918.rs
CommitLineData
74b04a01
XL
1// ignore-test: This now ICEs again.
2
dfeec247
XL
3// build-pass
4
94222f64 5#![feature(type_alias_impl_trait)]
dfeec247
XL
6
7use std::marker::PhantomData;
8
74b04a01 9/* copied Index and TryFrom for convenience (and simplicity) */
dfeec247
XL
10trait MyIndex<T> {
11 type O;
12 fn my_index(self) -> Self::O;
13}
14trait MyFrom<T>: Sized {
15 type Error;
16 fn my_from(value: T) -> Result<Self, Self::Error>;
17}
18
19/* MCVE starts here */
20trait F {}
21impl F for () {}
22type DummyT<T> = impl F;
23fn _dummy_t<T>() -> DummyT<T> {}
24
25struct Phantom1<T>(PhantomData<T>);
26struct Phantom2<T>(PhantomData<T>);
27struct Scope<T>(Phantom2<DummyT<T>>);
28
29impl<T> Scope<T> {
30 fn new() -> Self {
31 unimplemented!()
32 }
33}
34
35impl<T> MyFrom<Phantom2<T>> for Phantom1<T> {
36 type Error = ();
37 fn my_from(_: Phantom2<T>) -> Result<Self, Self::Error> {
38 unimplemented!()
39 }
40}
41
42impl<T: MyFrom<Phantom2<DummyT<U>>>, U> MyIndex<Phantom1<T>> for Scope<U> {
43 type O = T;
44 fn my_index(self) -> Self::O {
45 MyFrom::my_from(self.0).ok().unwrap()
46 }
47}
48
49fn main() {
50 let _pos: Phantom1<DummyT<()>> = Scope::new().my_index();
51}