2024-04-11 09:14:15 -05:00
|
|
|
//! Test that coercing between function items of the same function,
|
2024-04-11 09:25:26 -05:00
|
|
|
//! but with different generic args works.
|
|
|
|
|
|
|
|
//@check-pass
|
2024-04-11 09:14:15 -05:00
|
|
|
|
|
|
|
#![feature(type_alias_impl_trait)]
|
|
|
|
|
|
|
|
fn foo<T>(t: T) -> T {
|
|
|
|
t
|
|
|
|
}
|
|
|
|
|
|
|
|
type F = impl Sized;
|
|
|
|
|
|
|
|
fn f(a: F) {
|
|
|
|
let mut x = foo::<F>;
|
|
|
|
x = foo::<()>;
|
|
|
|
x(a);
|
|
|
|
x(());
|
|
|
|
}
|
|
|
|
|
|
|
|
type G = impl Sized;
|
|
|
|
|
|
|
|
fn g(a: G) {
|
|
|
|
let x = foo::<()>;
|
|
|
|
let _: () = x(a);
|
|
|
|
}
|
|
|
|
|
|
|
|
type H = impl Sized;
|
|
|
|
|
|
|
|
fn h(a: H) {
|
|
|
|
let x = foo::<H>;
|
|
|
|
let _: H = x(());
|
|
|
|
}
|
|
|
|
|
|
|
|
type I = impl Sized;
|
|
|
|
|
|
|
|
fn i(a: I) {
|
|
|
|
let mut x = foo::<()>;
|
|
|
|
x = foo::<I>;
|
|
|
|
x(a);
|
|
|
|
x(());
|
|
|
|
}
|
|
|
|
|
|
|
|
type J = impl Sized;
|
|
|
|
|
|
|
|
fn j(a: J) {
|
|
|
|
let x = match true {
|
|
|
|
true => foo::<J>,
|
2024-04-11 09:25:26 -05:00
|
|
|
false => foo::<()>,
|
2024-04-11 09:14:15 -05:00
|
|
|
};
|
|
|
|
x(a);
|
|
|
|
x(());
|
|
|
|
}
|
|
|
|
|
|
|
|
fn k() -> impl Sized {
|
|
|
|
fn bind<T, F: FnOnce(T) -> T>(_: T, f: F) -> F {
|
|
|
|
f
|
|
|
|
}
|
|
|
|
let x = match true {
|
|
|
|
true => {
|
|
|
|
let f = foo;
|
|
|
|
bind(k(), f)
|
|
|
|
}
|
2024-04-11 09:25:26 -05:00
|
|
|
false => foo::<()>,
|
2024-04-11 09:14:15 -05:00
|
|
|
};
|
|
|
|
todo!()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {}
|