Skip to content

Commit

Permalink
Add test crate to test async fn and impl Future (#622)
Browse files Browse the repository at this point in the history
* Add test crate to test async fn and impl Future

* Disable trait async fn for now, add TODO
  • Loading branch information
jw013 authored Jan 6, 2024
1 parent fb22c5e commit 87eca01
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 0 deletions.
7 changes: 7 additions & 0 deletions test_crates/async_impl_future_equivalence/new/Cargo.toml
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]
29 changes: 29 additions & 0 deletions test_crates/async_impl_future_equivalence/new/src/lib.rs
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();
// }
7 changes: 7 additions & 0 deletions test_crates/async_impl_future_equivalence/old/Cargo.toml
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]
29 changes: 29 additions & 0 deletions test_crates/async_impl_future_equivalence/old/src/lib.rs
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;
// }

0 comments on commit 87eca01

Please sign in to comment.