Skip to content
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

Want way to detect recursive impls #247

Closed
ijackson opened this issue May 22, 2023 · 2 comments
Closed

Want way to detect recursive impls #247

ijackson opened this issue May 22, 2023 · 2 comments

Comments

@ijackson
Copy link

Hi. Coincidentally, we had an accidentally-always-recursive async fn impl in a trait, leading to stack overflow (https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/1197), and I just read about someone else who had the same problem (https://github.com/juspay/hyperswitch/wiki/Ask-not-what-the-compiler-can-do-for-you).

I think it might be possible to detect this situation, using the following technique: move the body of the trait method implementation into a separate inherent method (with a derived name, and returning impl Future or just being async, and then have the trait method call it.

But, this might make the error messages worse in other cases. I thought I would suggest it for your consideration. Thanks!

@dtolnay
Copy link
Owner

dtolnay commented May 22, 2023

Your suggestion used to be how async_trait was implemented prior to #143 and there were serious downsides with that.

@dtolnay dtolnay closed this as completed May 22, 2023
@ijackson
Copy link
Author

Your suggestion used to be how async_trait was implemented prior to #143 and there were serious downsides with that.

Oh dear. Thanks for the reply and sorry for the noise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants