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

new lint: missing_must_use_on_future_types #14066

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

rmehri01
Copy link

Adds a lint that checks if Future is implemented for a type (struct or enum) and will warn if there is no #[must_use] attribute since futures must be awaited to do work, similar to how async fn works.

Example output:

error: this struct implements `Future` but is missing a `#[must_use]` attribute
  --> tests/ui/missing_must_use_on_future_types.rs:11:1
   |
LL | struct BasicStruct;
   | ^^^^^^^^^^^^^^^^^^
   |
   = note: `-D clippy::missing-must-use-on-future-types` implied by `-D warnings`
   = help: to override `-D warnings` add `#[allow(clippy::missing_must_use_on_future_types)]`
help: add the attribute
   |
LL + #[must_use]
LL | struct BasicStruct;
   |

Closes #13886

changelog: [missing_must_use_on_future_types]: new lint

@rustbot
Copy link
Collaborator

rustbot commented Jan 23, 2025

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @Centri3 (or someone else) some time within the next two weeks.

Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (S-waiting-on-review and S-waiting-on-author) stays updated, invoking these commands when appropriate:

  • @rustbot author: the review is finished, PR author should check the comments and take action accordingly
  • @rustbot review: the author is ready for a review, this PR will be queued again in the reviewer's queue

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Jan 23, 2025
@rmehri01 rmehri01 force-pushed the missing-must-use-on-future-types branch from acf6e40 to dc0d159 Compare January 23, 2025 05:30
@rmehri01 rmehri01 changed the title Missing must use on future types new lint: missing_must_use_on_future_types Jan 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Missing must_use on type implementing Future
3 participants