Issue function modifiers in the right order in manual_async_fn lint

This commit is contained in:
Samuel Tardieu 2023-03-05 12:38:23 +01:00
parent 70e85d146f
commit afe27ba1a2
4 changed files with 75 additions and 4 deletions

View file

@ -107,4 +107,10 @@ mod issue_5765 {
}
}
pub async fn issue_10450() -> i32 { 42 }
pub(crate) async fn issue_10450_2() -> i32 { 42 }
pub(self) async fn issue_10450_3() -> i32 { 42 }
fn main() {}

View file

@ -127,4 +127,16 @@ mod issue_5765 {
}
}
pub fn issue_10450() -> impl Future<Output = i32> {
async { 42 }
}
pub(crate) fn issue_10450_2() -> impl Future<Output = i32> {
async { 42 }
}
pub(self) fn issue_10450_3() -> impl Future<Output = i32> {
async { 42 }
}
fn main() {}

View file

@ -161,5 +161,50 @@ help: move the body of the async block to the enclosing function
LL | fn explicit<'a, 'b>(_: &'a i32, _: &'b i32) -> impl Future<Output = i32> + 'a + 'b { 42 }
| ~~~~~~
error: aborting due to 10 previous errors
error: this function can be simplified using the `async fn` syntax
--> $DIR/manual_async_fn.rs:130:1
|
LL | pub fn issue_10450() -> impl Future<Output = i32> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
help: make the function `async` and return the output of the future directly
|
LL | pub async fn issue_10450() -> i32 {
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
help: move the body of the async block to the enclosing function
|
LL | pub fn issue_10450() -> impl Future<Output = i32> { 42 }
| ~~~~~~
error: this function can be simplified using the `async fn` syntax
--> $DIR/manual_async_fn.rs:134:1
|
LL | pub(crate) fn issue_10450_2() -> impl Future<Output = i32> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
help: make the function `async` and return the output of the future directly
|
LL | pub(crate) async fn issue_10450_2() -> i32 {
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
help: move the body of the async block to the enclosing function
|
LL | pub(crate) fn issue_10450_2() -> impl Future<Output = i32> { 42 }
| ~~~~~~
error: this function can be simplified using the `async fn` syntax
--> $DIR/manual_async_fn.rs:138:1
|
LL | pub(self) fn issue_10450_3() -> impl Future<Output = i32> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
help: make the function `async` and return the output of the future directly
|
LL | pub(self) async fn issue_10450_3() -> i32 {
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
help: move the body of the async block to the enclosing function
|
LL | pub(self) fn issue_10450_3() -> impl Future<Output = i32> { 42 }
| ~~~~~~
error: aborting due to 13 previous errors