]>
Commit | Line | Data |
---|---|---|
416331ca | 1 | // build-pass (FIXME(62277): could be check-pass?) |
dc9dc135 XL |
2 | // edition:2018 |
3 | // compile-flags: --crate-type lib | |
4 | ||
dc9dc135 XL |
5 | use std::future::Future; |
6 | ||
7 | pub async fn simple_generic<T>() {} | |
8 | ||
9 | pub trait Foo { | |
10 | fn foo(&self) {} | |
11 | } | |
12 | ||
13 | struct FooType; | |
14 | impl Foo for FooType {} | |
15 | ||
16 | pub async fn call_generic_bound<F: Foo>(f: F) { | |
17 | f.foo() | |
18 | } | |
19 | ||
20 | pub async fn call_where_clause<F>(f: F) | |
21 | where | |
22 | F: Foo, | |
23 | { | |
24 | f.foo() | |
25 | } | |
26 | ||
27 | pub async fn call_impl_trait(f: impl Foo) { | |
28 | f.foo() | |
29 | } | |
30 | ||
31 | pub async fn call_with_ref(f: &impl Foo) { | |
32 | f.foo() | |
33 | } | |
34 | ||
35 | pub fn async_fn_with_same_generic_params_unifies() { | |
36 | let mut a = call_generic_bound(FooType); | |
37 | a = call_generic_bound(FooType); | |
38 | ||
39 | let mut b = call_where_clause(FooType); | |
40 | b = call_where_clause(FooType); | |
41 | ||
42 | let mut c = call_impl_trait(FooType); | |
43 | c = call_impl_trait(FooType); | |
44 | ||
45 | let f_one = FooType; | |
46 | let f_two = FooType; | |
47 | let mut d = call_with_ref(&f_one); | |
48 | d = call_with_ref(&f_two); | |
49 | } | |
50 | ||
51 | pub fn simple_generic_block<T>() -> impl Future<Output = ()> { | |
52 | async move {} | |
53 | } | |
54 | ||
55 | pub fn call_generic_bound_block<F: Foo>(f: F) -> impl Future<Output = ()> { | |
56 | async move { f.foo() } | |
57 | } | |
58 | ||
59 | pub fn call_where_clause_block<F>(f: F) -> impl Future<Output = ()> | |
60 | where | |
61 | F: Foo, | |
62 | { | |
63 | async move { f.foo() } | |
64 | } | |
65 | ||
66 | pub fn call_impl_trait_block(f: impl Foo) -> impl Future<Output = ()> { | |
67 | async move { f.foo() } | |
68 | } | |
69 | ||
70 | pub fn call_with_ref_block<'a>(f: &'a (impl Foo + 'a)) -> impl Future<Output = ()> + 'a { | |
71 | async move { f.foo() } | |
72 | } | |
73 | ||
74 | pub fn async_block_with_same_generic_params_unifies() { | |
75 | let mut a = call_generic_bound_block(FooType); | |
76 | a = call_generic_bound_block(FooType); | |
77 | ||
78 | let mut b = call_where_clause_block(FooType); | |
79 | b = call_where_clause_block(FooType); | |
80 | ||
81 | let mut c = call_impl_trait_block(FooType); | |
82 | c = call_impl_trait_block(FooType); | |
83 | ||
84 | let f_one = FooType; | |
85 | let f_two = FooType; | |
86 | let mut d = call_with_ref_block(&f_one); | |
87 | d = call_with_ref_block(&f_two); | |
88 | } |