-
Notifications
You must be signed in to change notification settings - Fork 202
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
io-async: fix warnings for latest nightly (1.75.0) #515
Conversation
The warning against using There's no way to express that with the In the embedded case, all existing runtimes and HALs don't require |
Ok, I finished with the remaining traits using the rewrite to the desugared version. I can change to use the I think leaving it with the desugared version also might be better for any future changes that want to add the |
adding Currently, This is an overview of the compatibility we get depending on the choice in the trait declaration:
(note that 🟢 = works trait Foo {
async fn foo(self); // future may or may not be Send.
}
struct MyFoo;
impl Foo for MyFoo {
async fn foo(self) {
// future that *does* implement Send.
}
}
async fn use<T: Foo>(foo: T) {
// works: nothing here requires `Send`, even if you do end up running this
// code in an executor that does require `Send`.
foo.foo().await;
}
fn spawn_concrete_type(foo: MyFoo) {
// works: the compiler can see `t.foo()` is Send even if the signature for `foo()`
// doesn't require `+ Send`, because it knows the concrete type.
tokio::spawn(t.foo())
}
fn spawn_generic<T: Foo>(t: T) {
// Doesn't work: the future for `t.foo()` may or may not be `Send` depending on `T`.
tokio::spawn(t.foo())
} So, first of all: there's no advantage in switching from About compat with executors that require Send, we can either:
I prefer doing
fn spawn_generic<T>(t: T)
where T: Foo + Send,
T::foo(): Send, // RTN! means "the future returned by foo() is Send"
{
tokio::spawn(t.foo()) // requires Send
}
|
After reading your write-up, I agree. I'm new to
That completely makes sense, I was not aware of RTN. I can make the changes to use the |
Adds `#[allow(async_fn_in_trait)]` to disable the lint in `async` trait functions recommending `Send` in the return type. Adding the type annotation is currently unstable, has little-to-no utility in current crates using `embedded-hal`, and will break those users. See <rust-embedded#515 (comment)> for details and discussion.
Looks like |
you can add a single clippy and rustdoc fail becuase you have to update nightly here |
Adds `#[allow(async_fn_in_trait)]` to disable the lint in `async` trait functions recommending `Send` in the return type. Adding the type annotation is currently unstable, has little-to-no utility in current crates using `embedded-hal`, and will break those users. See <rust-embedded#515 (comment)> for details and discussion.
Fixes
cargo check
warnings for the latest nightly version (1.75.0
).Recommended public API signatures for async trait functions has changed to recommending the desugared version for compatibility with different
async
runtimes.