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

clippy::double-must-use emitted for #[must_use] on async fn #10486

Closed
garryod opened this issue Mar 11, 2023 · 1 comment · Fixed by #10589
Closed

clippy::double-must-use emitted for #[must_use] on async fn #10486

garryod opened this issue Mar 11, 2023 · 1 comment · Fixed by #10589
Assignees
Labels
C-bug Category: Clippy is not doing the correct thing I-false-positive Issue: The lint was triggered on code it shouldn't have

Comments

@garryod
Copy link

garryod commented Mar 11, 2023

Summary

As of 1.67 (Pull Request), the #[must_use] hint is applied to the Output of a Future when use on an async fn. With this change clippy now reports a false positive double-must-use in the context of async fns.

Lint Name

double-must-use

Reproducer

I tried this code:

#[must_use]
pub async fn new_reliable(room_url: impl Into<String>) -> (Self, MessageLoopFuture) {
    ...
}

I saw this happen:

error: this function has an empty `#[must_use]` attribute, but returns a type already marked as `#[must_use]`
Error:    --> matchbox_socket/src/webrtc_socket/socket.rs:139:5
    |
139 |     pub async fn new_unreliable(room_url: impl Into<String>) -> (Self, MessageLoopFuture) {
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = help: either add some descriptive text or remove the attribute
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#double_must_use
    = note: `-D clippy::double-must-use` implied by `-D warnings`

I expected to see this happen:

No warning

Version

rustc 1.68.0 (2c8cc3432 2023-03-06)
binary: rustc
commit-hash: 2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74
commit-date: 2023-03-06
host: x86_64-unknown-linux-gnu
release: 1.68.0
LLVM version: 15.0.6

Additional Labels

No response

@garryod garryod added C-bug Category: Clippy is not doing the correct thing I-false-positive Issue: The lint was triggered on code it shouldn't have labels Mar 11, 2023
@blyxyas
Copy link
Member

blyxyas commented Apr 2, 2023

@rustbot claim

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
C-bug Category: Clippy is not doing the correct thing I-false-positive Issue: The lint was triggered on code it shouldn't have
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants