diff options
| author | bors <bors@rust-lang.org> | 2023-11-19 12:23:59 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-11-19 12:23:59 +0000 |
| commit | 097261f241d0295a84a1fc754639e58202ea7e8e (patch) | |
| tree | ada2eaff0c5485ef44c05df190933c94a37625b6 /compiler/rustc_const_eval/src/const_eval/machine.rs | |
| parent | 10a98e8bff0b1335e7f0f1ea0453ee0765ae96fe (diff) | |
| parent | c5ed7b0ead27a9b666c2c4fc14160fba972df793 (diff) | |
| download | rust-097261f241d0295a84a1fc754639e58202ea7e8e.tar.gz rust-097261f241d0295a84a1fc754639e58202ea7e8e.zip | |
Auto merge of #118054 - max-niederman:pinned-must-use, r=Nilstrieb
Lint pinned `#[must_use]` pointers (in particular, `Box<T>` where `T` is `#[must_use]`) in `unused_must_use`.
Fixes: #111458
This is motivated by a common async/await pattern:
```rs
fn foo() -> Pin<Box<dyn Future<Output = i32>>> {
Box::pin(async { 42 })
}
// call `foo`, but forget to await the result
foo();
```
Unlike with `async fn` or return position `impl Future`, this does not currently warn the user that the `Future` is unused.
To fix this, I've extended the `unused_must_use` lint to catch `Pin<P>`, where `P` must be used. In particular, this applies to `Pin<Box<T>>`, where `T` must be used. I'm not sure if there are other pointers where this applies, but I can't think of any situation the user wouldn't want to be warned.
Diffstat (limited to 'compiler/rustc_const_eval/src/const_eval/machine.rs')
0 files changed, 0 insertions, 0 deletions
