-
Notifications
You must be signed in to change notification settings - Fork 13.4k
impl AsyncFn
inference error leaks confusing internal_implementation_detail::AsyncFnKindHelper
trait constraint requirement
#137905
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Labels
C-bug
Category: This is a bug.
Comments
jieyouxu
added a commit
to jieyouxu/rust
that referenced
this issue
Mar 5, 2025
…r, r=oli-obk Improve error message for `AsyncFn` trait failure for RPIT Use a `WellFormedDerived` obligation cause to make sure we can turn an `AsyncFnKindHelper` trait goal into its parent `AsyncFn*` goal, then fix the logic for reporting `AsyncFn*` kind mismatches. Best reviewed without whitespace. Fixes rust-lang#137905 r? oli-obk
jieyouxu
added a commit
to jieyouxu/rust
that referenced
this issue
Mar 5, 2025
…r, r=oli-obk Improve error message for `AsyncFn` trait failure for RPIT Use a `WellFormedDerived` obligation cause to make sure we can turn an `AsyncFnKindHelper` trait goal into its parent `AsyncFn*` goal, then fix the logic for reporting `AsyncFn*` kind mismatches. Best reviewed without whitespace. Fixes rust-lang#137905 r? oli-obk
compiler-errors
added a commit
to compiler-errors/rust
that referenced
this issue
Mar 6, 2025
…r, r=oli-obk Improve error message for `AsyncFn` trait failure for RPIT Use a `WellFormedDerived` obligation cause to make sure we can turn an `AsyncFnKindHelper` trait goal into its parent `AsyncFn*` goal, then fix the logic for reporting `AsyncFn*` kind mismatches. Best reviewed without whitespace. Fixes rust-lang#137905 r? oli-obk
Noratrieb
added a commit
to Noratrieb/rust
that referenced
this issue
Mar 6, 2025
…r, r=oli-obk Improve error message for `AsyncFn` trait failure for RPIT Use a `WellFormedDerived` obligation cause to make sure we can turn an `AsyncFnKindHelper` trait goal into its parent `AsyncFn*` goal, then fix the logic for reporting `AsyncFn*` kind mismatches. Best reviewed without whitespace. Fixes rust-lang#137905 r? oli-obk
compiler-errors
added a commit
to compiler-errors/rust
that referenced
this issue
Mar 6, 2025
…r, r=oli-obk Improve error message for `AsyncFn` trait failure for RPIT Use a `WellFormedDerived` obligation cause to make sure we can turn an `AsyncFnKindHelper` trait goal into its parent `AsyncFn*` goal, then fix the logic for reporting `AsyncFn*` kind mismatches. Best reviewed without whitespace. Fixes rust-lang#137905 r? oli-obk
rust-timer
added a commit
to rust-lang-ci/rust
that referenced
this issue
Mar 7, 2025
Rollup merge of rust-lang#137910 - compiler-errors:async-fn-goal-error, r=oli-obk Improve error message for `AsyncFn` trait failure for RPIT Use a `WellFormedDerived` obligation cause to make sure we can turn an `AsyncFnKindHelper` trait goal into its parent `AsyncFn*` goal, then fix the logic for reporting `AsyncFn*` kind mismatches. Best reviewed without whitespace. Fixes rust-lang#137905 r? oli-obk
I can still cause this (or something similar to it) on the current nightly: struct Test;
impl Test {
async fn an_async_fn(&mut self) {
todo!()
}
pub async fn uses_takes_asyncfn(&mut self) {
takes_asyncfn(Box::new(async || self.an_async_fn().await));
}
}
async fn takes_asyncfn(_: impl AsyncFn()) {
todo!()
} output:
Should I open a new issue? |
Yes, please open a new issue |
# for free
to join this conversation on GitHub.
Already have an account?
# to comment
Minimal repro:
Error message:
https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=1417c51240bb454a094b23c524191862
Changing the code to directly return the async closure instead of binding it to a variable produces a more reasonable (but still not ideal) error message:
This issue was originally reported on URLO: https://users.rust-lang.org/t/interesting-issue-with-new-async-closures-with-very-cryptic-error-message/126470
Meta
rustc --version --verbose
:The text was updated successfully, but these errors were encountered: