]> git.lizzy.rs Git - rust.git/blob - src/test/ui/impl-trait/issues/issue-62742.rs
Merge commit '266e96785ab71834b917bf474f130a6d8fdecd4b' into sync_cg_clif-2022-10-23
[rust.git] / src / test / ui / impl-trait / issues / issue-62742.rs
1 use std::marker::PhantomData;
2
3 fn _alias_check() {
4     WrongImpl::foo(0i32);
5     //~^ ERROR the trait bound `RawImpl<_>: Raw<_>` is not satisfied
6     WrongImpl::<()>::foo(0i32);
7     //~^ ERROR the trait bound `RawImpl<()>: Raw<()>` is not satisfied
8     //~| ERROR trait bounds were not satisfied
9     CorrectImpl::foo(0i32);
10 }
11
12 pub trait Raw<T: ?Sized> {
13     type Value;
14 }
15
16 pub type WrongImpl<T> = SafeImpl<T, RawImpl<T>>;
17
18 pub type CorrectImpl<T> = SafeImpl<[T], RawImpl<T>>;
19
20 pub struct RawImpl<T>(PhantomData<T>);
21
22 impl<T> Raw<[T]> for RawImpl<T> {
23     type Value = T;
24 }
25
26 pub struct SafeImpl<T: ?Sized, A: Raw<T>>(PhantomData<(A, T)>);
27
28 impl<T: ?Sized, A: Raw<T>> SafeImpl<T, A> {
29     pub fn foo(value: A::Value) {}
30 }
31
32 fn main() {}