]> git.lizzy.rs Git - rust.git/commit - src/tools/rust-analyzer
Rollup merge of #89835 - jkugelman:must-use-expensive-computations, r=joshtriplett
authorMatthias Krüger <matthias.krueger@famsik.de>
Sun, 31 Oct 2021 08:20:24 +0000 (09:20 +0100)
committerGitHub <noreply@github.com>
Sun, 31 Oct 2021 08:20:24 +0000 (09:20 +0100)
commita26b1d2259ef96977c76d5e3a15a6dbf0371d91c
treec2d00361e0b9138c14309eaeb3564e6630e717e4
parent3cf3910c15a3c33dde3c380ac57501d37aa58e71
parent21f467774415b9f237bf1d0ece7236beb2e198a3
Rollup merge of #89835 - jkugelman:must-use-expensive-computations, r=joshtriplett

Add #[must_use] to expensive computations

The unifying theme for this commit is weak, admittedly. I put together a list of "expensive" functions when I originally proposed this whole effort, but nobody's cared about that criterion. Still, it's a decent way to bite off a not-too-big chunk of work.

Given the grab bag nature of this commit, the messages I used vary quite a bit. I'm open to wording changes.

For some reason clippy flagged four `BTreeSet` methods but didn't say boo about equivalent ones on `HashSet`. I stared at them for a while but I can't figure out the difference so I added the `HashSet` ones in.

```rust
// Flagged by clippy.
alloc::collections::btree_set::BTreeSet<T>   fn difference<'a>(&'a self, other: &'a BTreeSet<T>) -> Difference<'a, T>;
alloc::collections::btree_set::BTreeSet<T>   fn symmetric_difference<'a>(&'a self, other: &'a BTreeSet<T>) -> SymmetricDifference<'a, T>
alloc::collections::btree_set::BTreeSet<T>   fn intersection<'a>(&'a self, other: &'a BTreeSet<T>) -> Intersection<'a, T>;
alloc::collections::btree_set::BTreeSet<T>   fn union<'a>(&'a self, other: &'a BTreeSet<T>) -> Union<'a, T>;

// Ignored by clippy, but not by me.
std::collections::HashSet<T, S>              fn difference<'a>(&'a self, other: &'a HashSet<T, S>) -> Difference<'a, T, S>;
std::collections::HashSet<T, S>              fn symmetric_difference<'a>(&'a self, other: &'a HashSet<T, S>) -> SymmetricDifference<'a, T, S>
std::collections::HashSet<T, S>              fn intersection<'a>(&'a self, other: &'a HashSet<T, S>) -> Intersection<'a, T, S>;
std::collections::HashSet<T, S>              fn union<'a>(&'a self, other: &'a HashSet<T, S>) -> Union<'a, T, S>;
```

Parent issue: #89692

r? ```@joshtriplett```
library/alloc/src/collections/btree/set.rs
library/alloc/src/string.rs
library/core/src/str/mod.rs
library/std/src/collections/hash/set.rs
library/std/src/ffi/os_str.rs