]> git.lizzy.rs Git - rust.git/blob - src/test/ui/type-alias-impl-trait/issue-65918.rs
Loop over all opaque types instead of looking at just the first one with the same...
[rust.git] / src / test / ui / type-alias-impl-trait / issue-65918.rs
1 // ignore-test: This now ICEs again.
2
3 // build-pass
4
5 // revisions: min_tait full_tait
6 #![feature(min_type_alias_impl_trait)]
7 #![cfg_attr(full_tait, feature(type_alias_impl_trait))]
8 //[full_tait]~^ WARN incomplete
9
10 use std::marker::PhantomData;
11
12 /* copied Index and TryFrom for convenience (and simplicity) */
13 trait MyIndex<T> {
14     type O;
15     fn my_index(self) -> Self::O;
16 }
17 trait MyFrom<T>: Sized {
18     type Error;
19     fn my_from(value: T) -> Result<Self, Self::Error>;
20 }
21
22 /* MCVE starts here */
23 trait F {}
24 impl F for () {}
25 type DummyT<T> = impl F;
26 fn _dummy_t<T>() -> DummyT<T> {}
27
28 struct Phantom1<T>(PhantomData<T>);
29 struct Phantom2<T>(PhantomData<T>);
30 struct Scope<T>(Phantom2<DummyT<T>>);
31
32 impl<T> Scope<T> {
33     fn new() -> Self {
34         unimplemented!()
35     }
36 }
37
38 impl<T> MyFrom<Phantom2<T>> for Phantom1<T> {
39     type Error = ();
40     fn my_from(_: Phantom2<T>) -> Result<Self, Self::Error> {
41         unimplemented!()
42     }
43 }
44
45 impl<T: MyFrom<Phantom2<DummyT<U>>>, U> MyIndex<Phantom1<T>> for Scope<U> {
46     type O = T;
47     fn my_index(self) -> Self::O {
48         MyFrom::my_from(self.0).ok().unwrap()
49     }
50 }
51
52 fn main() {
53     let _pos: Phantom1<DummyT<()>> = Scope::new().my_index();
54 }