-
-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test crate to test async fn and impl Future (#622)
* Add test crate to test async fn and impl Future * Disable trait async fn for now, add TODO
- Loading branch information
Showing
4 changed files
with
72 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[package] | ||
publish = false | ||
name = "async_impl_future_equivalence" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[dependencies] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
//! async fn and return position impl Future are equivalent. | ||
//! Switching from one to the other should NOT generate any lints | ||
use std::future::Future; | ||
|
||
pub fn switches_to_return_impl() -> impl Future { | ||
async {} | ||
} | ||
|
||
pub async fn switches_to_async() {} | ||
|
||
pub struct S; | ||
|
||
impl S { | ||
pub fn switches_to_return_impl() -> impl Future { | ||
async {} | ||
} | ||
|
||
pub async fn switches_to_async() {} | ||
} | ||
|
||
// TODO: https://github.com/obi1kenobi/cargo-semver-checks/issues/624 | ||
// Uncomment once the project drops support for Rust < 1.75 | ||
// | ||
// #[allow(async_fn_in_trait)] | ||
// pub trait Trait { | ||
// fn switches_to_return_impl() -> impl Future; | ||
// async fn switches_to_async(); | ||
// } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[package] | ||
publish = false | ||
name = "async_impl_future_equivalence" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[dependencies] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
//! async fn and return position impl Future are equivalent. | ||
//! Switching from one to the other should NOT generate any lints | ||
use std::future::Future; | ||
|
||
pub async fn switches_to_return_impl() {} | ||
|
||
pub fn switches_to_async() -> impl Future { | ||
async {} | ||
} | ||
|
||
pub struct S; | ||
|
||
impl S { | ||
pub async fn switches_to_return_impl() {} | ||
|
||
pub fn switches_to_async() -> impl Future { | ||
async {} | ||
} | ||
} | ||
|
||
// TODO: https://github.com/obi1kenobi/cargo-semver-checks/issues/624 | ||
// Uncomment once the project drops support for Rust < 1.75 | ||
// | ||
// #[allow(async_fn_in_trait)] | ||
// pub trait Trait { | ||
// async fn switches_to_return_impl(); | ||
// fn switches_to_async() -> impl Future; | ||
// } |