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

Lint pinned #[must_use] pointers (in particular, Box<T> where T is #[must_use]) in unused_must_use. #118054

Merged
merged 2 commits into from
Nov 19, 2023

Conversation

max-niederman
Copy link
Contributor

Fixes: #111458

This is motivated by a common async/await pattern:

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.

@rustbot
Copy link
Collaborator

rustbot commented Nov 19, 2023

r? @davidtwco

(rustbot has picked a reviewer for you, use r? to override)

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Nov 19, 2023
@max-niederman max-niederman marked this pull request as ready for review November 19, 2023 05:16
Copy link
Member

@Nilstrieb Nilstrieb left a comment

Choose a reason for hiding this comment

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

sounds good, thanks!
I don't think this needs signoff from any team as it's just some lint behavior, so I'm just going to approve it.

@Nilstrieb
Copy link
Member

@bors r

@bors
Copy link
Contributor

bors commented Nov 19, 2023

📌 Commit c5ed7b0 has been approved by Nilstrieb

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 19, 2023
@bors
Copy link
Contributor

bors commented Nov 19, 2023

⌛ Testing commit c5ed7b0 with merge 097261f...

@bors
Copy link
Contributor

bors commented Nov 19, 2023

☀️ Test successful - checks-actions
Approved by: Nilstrieb
Pushing 097261f to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Nov 19, 2023
@bors bors merged commit 097261f into rust-lang:master Nov 19, 2023
12 checks passed
@rustbot rustbot added this to the 1.76.0 milestone Nov 19, 2023
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (097261f): comparison URL.

Overall result: no relevant changes - no action needed

@rustbot label: -perf-regression

Instruction count

This benchmark run did not return any relevant results for this metric.

Max RSS (memory usage)

This benchmark run did not return any relevant results for this metric.

Cycles

This benchmark run did not return any relevant results for this metric.

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 676.234s -> 676.326s (0.01%)
Artifact size: 313.80 MiB -> 313.84 MiB (0.01%)

wip-sync pushed a commit to NetBSD/pkgsrc-wip that referenced this pull request Feb 18, 2024
Pkgsrc changes:
 * Adapt checksums and patches.

Upstream chnages:

Version 1.76.0 (2024-02-08)
==========================

Language
--------
- [Document Rust ABI compatibility between various types]
  (rust-lang/rust#115476)
- [Also: guarantee that char and u32 are ABI-compatible]
  (rust-lang/rust#118032)
- [Warn against ambiguous wide pointer comparisons]
  (rust-lang/rust#117758)

Compiler
--------
- [Lint pinned `#[must_use]` pointers (in particular, `Box<T>`
  where `T` is `#[must_use]`) in `unused_must_use`.]
  (rust-lang/rust#118054)
- [Soundness fix: fix computing the offset of an unsized field in
  a packed struct]
  (rust-lang/rust#118540)
- [Soundness fix: fix dynamic size/align computation logic for
  packed types with dyn Trait tail]
  (rust-lang/rust#118538)
- [Add `$message_type` field to distinguish json diagnostic outputs]
  (rust-lang/rust#115691)
- [Enable Rust to use the EHCont security feature of Windows]
  (rust-lang/rust#118013)
- [Add tier 3 {x86_64,i686}-win7-windows-msvc targets]
  (rust-lang/rust#118150)
- [Add tier 3 aarch64-apple-watchos target]
  (rust-lang/rust#119074)
- [Add tier 3 arm64e-apple-ios & arm64e-apple-darwin targets]
  (rust-lang/rust#115526)

Refer to Rust's [platform support page][platform-support-doc]
for more information on Rust's tiered platform support.

Libraries
---------
- [Add a column number to `dbg!()`]
  (rust-lang/rust#114962)
- [Add `std::hash::{DefaultHasher, RandomState}` exports]
  (rust-lang/rust#115694)
- [Fix rounding issue with exponents in fmt]
  (rust-lang/rust#116301)
- [Add T: ?Sized to `RwLockReadGuard` and `RwLockWriteGuard`'s Debug impls.]
  (rust-lang/rust#117138)
- [Windows: Allow `File::create` to work on hidden files]
  (rust-lang/rust#116438)

Stabilized APIs
---------------
- [`Arc::unwrap_or_clone`]
  (https://doc.rust-lang.org/stable/std/sync/struct.Arc.html#method.unwrap_or_clone)
- [`Rc::unwrap_or_clone`]
  (https://doc.rust-lang.org/stable/std/rc/struct.Rc.html#method.unwrap_or_clone)
- [`Result::inspect`]
  (https://doc.rust-lang.org/stable/std/result/enum.Result.html#method.inspect)
- [`Result::inspect_err`]
  (https://doc.rust-lang.org/stable/std/result/enum.Result.html#method.inspect_err)
- [`Option::inspect`]
  (https://doc.rust-lang.org/stable/std/option/enum.Option.html#method.inspect)
- [`type_name_of_val`]
  (https://doc.rust-lang.org/stable/std/any/fn.type_name_of_val.html)
- [`std::hash::{DefaultHasher, RandomState}`]
  (https://doc.rust-lang.org/stable/std/hash/index.html#structs)
  These were previously available only through `std::collections::hash_map`.
- [`ptr::{from_ref, from_mut}`]
  (https://doc.rust-lang.org/stable/std/ptr/fn.from_ref.html)
- [`ptr::addr_eq`](https://doc.rust-lang.org/stable/std/ptr/fn.addr_eq.html)

Cargo
-----

See [Cargo release notes]
(https://github.com/rust-lang/cargo/blob/master/CHANGELOG.md#cargo-176-2024-02-08).

Rustdoc
-------
- [Don't merge cfg and doc(cfg) attributes for re-exports]
  (rust-lang/rust#113091)
- [rustdoc: allow resizing the sidebar / hiding the top bar]
  (rust-lang/rust#115660)
- [rustdoc-search: add support for traits and associated types]
  (rust-lang/rust#116085)
- [rustdoc: Add highlighting for comments in items declaration]
  (rust-lang/rust#117869)

Compatibility Notes
-------------------
- [Add allow-by-default lint for unit bindings]
  (rust-lang/rust#112380)
  This is expected to be upgraded to a warning by default in a future Rust
  release. Some macros emit bindings with type `()` with user-provided spans,
  which means that this lint will warn for user code.
- [Remove x86_64-sun-solaris target.]
  (rust-lang/rust#118091)
- [Remove asmjs-unknown-emscripten target]
  (rust-lang/rust#117338)
- [Report errors in jobserver inherited through environment variables]
  (rust-lang/rust#113730)
  This [may warn](rust-lang/rust#120515)
  on benign problems too.
- [Update the minimum external LLVM to 16.]
  (rust-lang/rust#117947)
- [Improve `print_tts`](rust-lang/rust#114571)
  This change can break some naive manual parsing of token trees
  in proc macro code which expect a particular structure after
  `.to_string()`, rather than just arbitrary Rust code.
- [Make `IMPLIED_BOUNDS_ENTAILMENT` into a hard error from a lint]
  (rust-lang/rust#117984)
- [Vec's allocation behavior was changed when collecting some iterators]
  (rust-lang/rust#110353)
  Allocation behavior is currently not specified, nevertheless
  changes can be surprising.
  See [`impl FromIterator for Vec`]
  (https://doc.rust-lang.org/nightly/std/vec/struct.Vec.html#impl-FromIterator-for-Vec)
  for more details.
- [Properly reject `default` on free const items]
  (rust-lang/rust#117818)
facebook-github-bot pushed a commit to facebook/sapling that referenced this pull request Feb 20, 2024
Summary:
`1.76.0` release with fixes addressing the following:
* Release notes ([link](https://releases.rs/docs/1.76.0/))
  * Most notable is [#118054](rust-lang/rust#118054) manifesting as:
```
error: unused implementer of `futures::Future` that must be used
   --> fbcode/mlx/metalearner/housekeeper/housekeeper.rs:213:13
    |
213 |             self.ping_oncall(&oncall, usecases);
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: futures do nothing unless you `.await` or poll them
    = note: requested on the command line with `-D unused-must-use`
```
* Changes in `search_index.js` spec for `rustdoc` ([link](https://github.com/rust-lang/rust/pull/118910/files#diff-3ac57789ddcd2856a3b4f0c444f2813315179bdbe55bb945fe64fcb27b53fee5L491))
* Split of `#![feature(exposed_provenance)]` ([link](rust-lang/rust#118487)) from [#95228](rust-lang/rust#95228)
* `buck2` OSS toolchain bump to `nightly-2023-12-11` just before [#11878](rust-lang/rust-clippy#11878) and a bunch of other clippy lint renames.

Reviewed By: dtolnay

Differential Revision: D53776867

fbshipit-source-id: 78db83d8cdd6b0abae2b94ed1075e67b501fcd73
facebook-github-bot pushed a commit to facebook/buck2 that referenced this pull request Feb 20, 2024
Summary:
`1.76.0` release with fixes addressing the following:
* Release notes ([link](https://releases.rs/docs/1.76.0/))
  * Most notable is [#118054](rust-lang/rust#118054) manifesting as:
```
error: unused implementer of `futures::Future` that must be used
   --> fbcode/mlx/metalearner/housekeeper/housekeeper.rs:213:13
    |
213 |             self.ping_oncall(&oncall, usecases);
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: futures do nothing unless you `.await` or poll them
    = note: requested on the command line with `-D unused-must-use`
```
* Changes in `search_index.js` spec for `rustdoc` ([link](https://github.com/rust-lang/rust/pull/118910/files#diff-3ac57789ddcd2856a3b4f0c444f2813315179bdbe55bb945fe64fcb27b53fee5L491))
* Split of `#![feature(exposed_provenance)]` ([link](rust-lang/rust#118487)) from [#95228](rust-lang/rust#95228)
* `buck2` OSS toolchain bump to `nightly-2023-12-11` just before [#11878](rust-lang/rust-clippy#11878) and a bunch of other clippy lint renames.

Reviewed By: dtolnay

Differential Revision: D53776867

fbshipit-source-id: 78db83d8cdd6b0abae2b94ed1075e67b501fcd73
facebook-github-bot pushed a commit to facebookincubator/reindeer that referenced this pull request Feb 20, 2024
Summary:
`1.76.0` release with fixes addressing the following:
* Release notes ([link](https://releases.rs/docs/1.76.0/))
  * Most notable is [#118054](rust-lang/rust#118054) manifesting as:
```
error: unused implementer of `futures::Future` that must be used
   --> fbcode/mlx/metalearner/housekeeper/housekeeper.rs:213:13
    |
213 |             self.ping_oncall(&oncall, usecases);
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: futures do nothing unless you `.await` or poll them
    = note: requested on the command line with `-D unused-must-use`
```
* Changes in `search_index.js` spec for `rustdoc` ([link](https://github.com/rust-lang/rust/pull/118910/files#diff-3ac57789ddcd2856a3b4f0c444f2813315179bdbe55bb945fe64fcb27b53fee5L491))
* Split of `#![feature(exposed_provenance)]` ([link](rust-lang/rust#118487)) from [#95228](rust-lang/rust#95228)
* `buck2` OSS toolchain bump to `nightly-2023-12-11` just before [#11878](rust-lang/rust-clippy#11878) and a bunch of other clippy lint renames.

Reviewed By: dtolnay

Differential Revision: D53776867

fbshipit-source-id: 78db83d8cdd6b0abae2b94ed1075e67b501fcd73
facebook-github-bot pushed a commit to facebookexperimental/reverie that referenced this pull request Feb 20, 2024
Summary:
`1.76.0` release with fixes addressing the following:
* Release notes ([link](https://releases.rs/docs/1.76.0/))
  * Most notable is [#118054](rust-lang/rust#118054) manifesting as:
```
error: unused implementer of `futures::Future` that must be used
   --> fbcode/mlx/metalearner/housekeeper/housekeeper.rs:213:13
    |
213 |             self.ping_oncall(&oncall, usecases);
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: futures do nothing unless you `.await` or poll them
    = note: requested on the command line with `-D unused-must-use`
```
* Changes in `search_index.js` spec for `rustdoc` ([link](https://github.com/rust-lang/rust/pull/118910/files#diff-3ac57789ddcd2856a3b4f0c444f2813315179bdbe55bb945fe64fcb27b53fee5L491))
* Split of `#![feature(exposed_provenance)]` ([link](rust-lang/rust#118487)) from [#95228](rust-lang/rust#95228)
* `buck2` OSS toolchain bump to `nightly-2023-12-11` just before [#11878](rust-lang/rust-clippy#11878) and a bunch of other clippy lint renames.

Reviewed By: dtolnay

Differential Revision: D53776867

fbshipit-source-id: 78db83d8cdd6b0abae2b94ed1075e67b501fcd73
facebook-github-bot pushed a commit to facebook/starlark-rust that referenced this pull request Feb 20, 2024
Summary:
`1.76.0` release with fixes addressing the following:
* Release notes ([link](https://releases.rs/docs/1.76.0/))
  * Most notable is [#118054](rust-lang/rust#118054) manifesting as:
```
error: unused implementer of `futures::Future` that must be used
   --> fbcode/mlx/metalearner/housekeeper/housekeeper.rs:213:13
    |
213 |             self.ping_oncall(&oncall, usecases);
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: futures do nothing unless you `.await` or poll them
    = note: requested on the command line with `-D unused-must-use`
```
* Changes in `search_index.js` spec for `rustdoc` ([link](https://github.com/rust-lang/rust/pull/118910/files#diff-3ac57789ddcd2856a3b4f0c444f2813315179bdbe55bb945fe64fcb27b53fee5L491))
* Split of `#![feature(exposed_provenance)]` ([link](rust-lang/rust#118487)) from [#95228](rust-lang/rust#95228)
* `buck2` OSS toolchain bump to `nightly-2023-12-11` just before [#11878](rust-lang/rust-clippy#11878) and a bunch of other clippy lint renames.

Reviewed By: dtolnay

Differential Revision: D53776867

fbshipit-source-id: 78db83d8cdd6b0abae2b94ed1075e67b501fcd73
facebook-github-bot pushed a commit to facebookexperimental/rust-shed that referenced this pull request Feb 20, 2024
Summary:
`1.76.0` release with fixes addressing the following:
* Release notes ([link](https://releases.rs/docs/1.76.0/))
  * Most notable is [#118054](rust-lang/rust#118054) manifesting as:
```
error: unused implementer of `futures::Future` that must be used
   --> fbcode/mlx/metalearner/housekeeper/housekeeper.rs:213:13
    |
213 |             self.ping_oncall(&oncall, usecases);
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: futures do nothing unless you `.await` or poll them
    = note: requested on the command line with `-D unused-must-use`
```
* Changes in `search_index.js` spec for `rustdoc` ([link](https://github.com/rust-lang/rust/pull/118910/files#diff-3ac57789ddcd2856a3b4f0c444f2813315179bdbe55bb945fe64fcb27b53fee5L491))
* Split of `#![feature(exposed_provenance)]` ([link](rust-lang/rust#118487)) from [#95228](rust-lang/rust#95228)
* `buck2` OSS toolchain bump to `nightly-2023-12-11` just before [#11878](rust-lang/rust-clippy#11878) and a bunch of other clippy lint renames.

Reviewed By: dtolnay

Differential Revision: D53776867

fbshipit-source-id: 78db83d8cdd6b0abae2b94ed1075e67b501fcd73
facebook-github-bot pushed a commit to facebook/errpy that referenced this pull request Feb 20, 2024
Summary:
`1.76.0` release with fixes addressing the following:
* Release notes ([link](https://releases.rs/docs/1.76.0/))
  * Most notable is [#118054](rust-lang/rust#118054) manifesting as:
```
error: unused implementer of `futures::Future` that must be used
   --> fbcode/mlx/metalearner/housekeeper/housekeeper.rs:213:13
    |
213 |             self.ping_oncall(&oncall, usecases);
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: futures do nothing unless you `.await` or poll them
    = note: requested on the command line with `-D unused-must-use`
```
* Changes in `search_index.js` spec for `rustdoc` ([link](https://github.com/rust-lang/rust/pull/118910/files#diff-3ac57789ddcd2856a3b4f0c444f2813315179bdbe55bb945fe64fcb27b53fee5L491))
* Split of `#![feature(exposed_provenance)]` ([link](rust-lang/rust#118487)) from [#95228](rust-lang/rust#95228)
* `buck2` OSS toolchain bump to `nightly-2023-12-11` just before [#11878](rust-lang/rust-clippy#11878) and a bunch of other clippy lint renames.

Reviewed By: dtolnay

Differential Revision: D53776867

fbshipit-source-id: 78db83d8cdd6b0abae2b94ed1075e67b501fcd73
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

New #[must_use] behaviour for async methods does not apply to Pin<Box<dyn Future<Output = ()>>>
6 participants