Skip to content

Commit 7d4d64d

Browse files
committed
Add test for issue-75053
1 parent 35b7374 commit 7d4d64d

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

src/test/ui/mir/issue-75053.rs

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// compile-flags: -Z mir-opt-level=2
2+
// build-pass
3+
4+
#![feature(type_alias_impl_trait)]
5+
6+
use std::marker::PhantomData;
7+
8+
trait MyIndex<T> {
9+
type O;
10+
fn my_index(self) -> Self::O;
11+
}
12+
trait MyFrom<T>: Sized {
13+
type Error;
14+
fn my_from(value: T) -> Result<Self, Self::Error>;
15+
}
16+
17+
trait F {}
18+
impl F for () {}
19+
type DummyT<T> = impl F;
20+
fn _dummy_t<T>() -> DummyT<T> {}
21+
22+
struct Phantom1<T>(PhantomData<T>);
23+
struct Phantom2<T>(PhantomData<T>);
24+
struct Scope<T>(Phantom2<DummyT<T>>);
25+
26+
impl<T> Scope<T> {
27+
fn new() -> Self {
28+
unimplemented!()
29+
}
30+
}
31+
32+
impl<T> MyFrom<Phantom2<T>> for Phantom1<T> {
33+
type Error = ();
34+
fn my_from(_: Phantom2<T>) -> Result<Self, Self::Error> {
35+
unimplemented!()
36+
}
37+
}
38+
39+
impl<T: MyFrom<Phantom2<DummyT<U>>>, U> MyIndex<Phantom1<T>> for Scope<U> {
40+
type O = T;
41+
fn my_index(self) -> Self::O {
42+
MyFrom::my_from(self.0).ok().unwrap()
43+
}
44+
}
45+
46+
fn main() {
47+
let _pos: Phantom1<DummyT<()>> = Scope::new().my_index();
48+
}

0 commit comments

Comments
 (0)