Skip to content

fix(server): Enforce serve_connection result usage #178

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

Merged

Conversation

Sol-Ell
Copy link
Contributor

@Sol-Ell Sol-Ell commented Apr 2, 2025

  • Mark serve_connection and serve_connection_with_upgrades as must_use to prevent ignored results.
  • Mark serve_connection_with_upgrades as must_use for consistency.
  • Helps avoid silent issues when forgetting to .await the connection.

Not a major issue, but spent 15 minutes debugging due to a missing .await.

Copy link
Member

@seanmonstar seanmonstar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, thanks for PR! Yea, we generally try to provide warnings for people like this. I assumed that must_use on std::future::Future would make it so we didn't need to do add it manually anymore, but it seems that's only for impl Future and Box<dyn Future>.

One request: can they be added to the types themselves, not to the functions, with a note? That's how we've done it for other futures: https://github.com/hyperium/hyper/blob/c449528a33d266a8ca1210baca11e5d649ca6c27/src/server/conn/http1.rs#L38

@Sol-Ell
Copy link
Contributor Author

Sol-Ell commented Apr 2, 2025

Thanks for pointing this out. I'll update everything accordingly.

Copy link
Member

@seanmonstar seanmonstar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lovely, thank you!

@seanmonstar seanmonstar merged commit e7b3966 into hyperium:master Apr 2, 2025
16 checks passed
@Sol-Ell Sol-Ell deleted the must-use-serve-connection-result branch April 3, 2025 04:26
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

Successfully merging this pull request may close these issues.

None yet

2 participants