mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-26 13:01:27 +03:00
46 lines
1.2 KiB
Rust
46 lines
1.2 KiB
Rust
//@ run-pass
|
|
|
|
#![feature(fn_delegation)]
|
|
|
|
trait Trait<'a, A, const B: bool> {
|
|
fn foo<'b, const B2: bool, T, U>(&self, f: impl FnOnce() -> usize) -> usize {
|
|
f() + 1
|
|
}
|
|
}
|
|
|
|
struct X;
|
|
impl<'a, A, const B: bool> Trait<'a, A, B> for X {}
|
|
|
|
reuse Trait::foo;
|
|
reuse Trait::<'static, (), true>::foo::<true, (), ()> as bar;
|
|
|
|
reuse foo as foo2;
|
|
reuse bar as bar2;
|
|
|
|
trait Trait2 {
|
|
reuse foo2 as foo3;
|
|
reuse bar2 as bar3;
|
|
}
|
|
|
|
impl Trait2 for () {}
|
|
|
|
reuse <() as Trait2>::foo3 as foo4;
|
|
reuse <() as Trait2>::bar3 as bar4;
|
|
|
|
fn main() {
|
|
assert_eq!(foo::<'static, X, (), true, false, (), ()>(&X, || 123), 124);
|
|
assert_eq!(foo2::<'static, X, (), true, false, (), ()>(&X, || 123), 124);
|
|
assert_eq!(<()>::foo3::<'static, X, (), true, false, (), ()>(&X, || 123), 124);
|
|
assert_eq!(foo4::<'static, X, (), true, false, (), ()>(&X, || 123), 124);
|
|
|
|
assert_eq!(bar::<X>(&X, || 123), 124);
|
|
assert_eq!(bar2::<X>(&X, || 123), 124);
|
|
assert_eq!(<()>::bar3::<X>(&X, || 123), 124);
|
|
assert_eq!(bar4::<X>(&X, || 123), 124);
|
|
|
|
assert_eq!(bar(&X, || 123), 124);
|
|
assert_eq!(bar2(&X, || 123), 124);
|
|
assert_eq!(<()>::bar3(&X, || 123), 124);
|
|
assert_eq!(bar4::<X>(&X, || 123), 124);
|
|
}
|