forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsuggest-impl-async-fn-issue-148493.fixed
More file actions
64 lines (55 loc) · 2.04 KB
/
suggest-impl-async-fn-issue-148493.fixed
File metadata and controls
64 lines (55 loc) · 2.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#![allow(dead_code)]
//@ run-rustfix
//@ edition: 2021
// The suggestion should be `impl AsyncFn()` instead of something like `{async closure@...}`
fn test1() -> impl AsyncFn() {
//~^ ERROR the placeholder `_` is not allowed within types on item signatures for return types
//~| HELP replace with an appropriate return type
//~| SUGGESTION impl AsyncFn()
async || {}
}
fn test2() -> impl AsyncFn(i32) -> i32 {
//~^ ERROR the placeholder `_` is not allowed within types on item signatures for return types
//~| HELP replace with an appropriate return type
//~| SUGGESTION impl AsyncFn(i32) -> i32
async |x: i32| x + 1
}
fn test3() -> impl AsyncFn(i32, i32) -> i32 {
//~^ ERROR the placeholder `_` is not allowed within types on item signatures for return types
//~| HELP replace with an appropriate return type
//~| SUGGESTION impl AsyncFn(i32, i32) -> i32
async |x: i32, y: i32| x + y
}
fn test4() -> impl AsyncFn() {
//~^ ERROR the placeholder `_` is not allowed within types on item signatures for return types
//~| HELP replace with an appropriate return type
//~| SUGGESTION impl AsyncFn()
async || -> () { () }
}
fn test5() -> impl AsyncFn() -> i32 {
//~^ ERROR the placeholder `_` is not allowed within types on item signatures for return types
//~| HELP replace with an appropriate return type
//~| SUGGESTION impl AsyncFn() -> i32
let z = 42;
async move || z
}
fn test6() -> impl AsyncFnMut() -> i32 {
//~^ ERROR the placeholder `_` is not allowed within types on item signatures for return types
//~| HELP replace with an appropriate return type
//~| SUGGESTION impl AsyncFnMut() -> i32
let mut x = 0;
async move || {
x += 1;
x
}
}
fn test7() -> impl AsyncFnOnce() {
//~^ ERROR the placeholder `_` is not allowed within types on item signatures for return types
//~| HELP replace with an appropriate return type
//~| SUGGESTION impl AsyncFnOnce()
let s = String::from("hello");
async move || {
drop(s);
}
}
fn main() {}