-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Rollup of 8 pull requests #90434
Rollup of 8 pull requests #90434
Conversation
Co-authored-by: r00ster <[email protected]>
Co-authored-by: Jane Lusby <[email protected]>
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.
Closes rust-lang#81383. Signed-off-by: Miguel Ojeda <[email protected]>
…riplett Add paragraph to ControlFlow docs to menion it works with the ? operator (rust-lang#88715) fixes rust-lang#88715 r? ```@steveklabnik```
…=joshtriplett Stabilize `is_symlink()` for `Metadata` and `Path` I'm not fully sure about `since` version, correct me if I'm wrong Needs update after stabilization: [cargo-test-support](https://github.com/rust-lang/cargo/blob/8063672238a5b6c3a901c0fc17f3164692d0be85/crates/cargo-test-support/src/paths.rs#L202) Linked issue: rust-lang#85748
…joshtriplett Add #[must_use] to Rc::downgrade Missed this in previous PR rust-lang#89796 (comment) Parent issue: rust-lang#89692 r? ```@joshtriplett```
…ations, 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: rust-lang#89692 r? ```@joshtriplett```
…s, r=joshtriplett Add #[must_use] to mem/ptr functions There's a lot of low-level / unsafe stuff here. Are there legit use cases for ignoring any of these return values? * No regressions in `./x.py test --stage 1 library/std src/tools/clippy`. * One regression in `./x.py test --stage 1 src/test/ui`. Fixed. * I am unable to run `./x.py doc` on my machine so I'll need to wait for the CI to verify doctests pass. I eyeballed all the adjacent tests and they all look okay. Parent issue: rust-lang#89692 r? ```@joshtriplett```
…lett Add #[must_use] to remaining core functions I've run out of compelling reasons to group functions together across crates so I'm just going to go module-by-module. This is everything remaining from the `core` crate. Ignored by clippy for reasons unknown: ```rust core::alloc::Layout unsafe fn for_value_raw<T: ?Sized>(t: *const T) -> Self; core::any const fn type_name_of_val<T: ?Sized>(_val: &T) -> &'static str; ``` Ignored by clippy because of `mut`: ```rust str fn split_at_mut(&mut self, mid: usize) -> (&mut str, &mut str); ``` <del> Ignored by clippy presumably because a caller might want `f` called for side effects. That seems like a bad usage of `map` to me. ```rust core::cell::Ref<'b, T> fn map<U: ?Sized, F>(orig: Ref<'b, T>, f: F) -> Ref<'b, T>; core::cell::Ref<'b, T> fn map_split<U: ?Sized, V: ?Sized, F>(orig: Ref<'b, T>, f: F) -> (Ref<'b, U>, Ref<'b, V>); ``` </del> Parent issue: rust-lang#89692 r? ```@joshtriplett```
…olnay Stabilize `option_result_unwrap_unchecked` Closes rust-lang#81383. Stabilization report: rust-lang#81383 (comment). ```@rustbot``` label +A-option-result +T-libs-api
…shtriplett Add #[must_use] to alloc functions that would leak memory As [requested](rust-lang#89899 (comment)) by `@joshtriplett.` > Please do go ahead and add the ones whose only legitimate use for ignoring the return value is leaking memory. (In a separate PR please.) I think it's sufficiently error-prone to call something like alloc and ignore the result that it's legitimate to require `let _ =` for that. I added `realloc` myself. Clippy ignored it because of its `mut` argument. ```rust alloc/src/alloc.rs:123:1 alloc unsafe fn realloc(ptr: *mut u8, layout: Layout, new_size: usize) -> *mut u8; ``` Parent issue: rust-lang#89692 r? `@joshtriplett`
@bors r+ p=8 rollup=never |
📌 Commit ff6d8ec has been approved by |
☀️ Test successful - checks-actions |
Finished benchmarking commit (58899c4): comparison url. Summary: This benchmark run did not return any relevant changes. If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf. @rustbot label: -perf-regression |
Successful merges:
is_symlink()
forMetadata
andPath
#89677 (Stabilizeis_symlink()
forMetadata
andPath
)option_result_unwrap_unchecked
#89951 (Stabilizeoption_result_unwrap_unchecked
)Failed merges:
r? @ghost
@rustbot modify labels: rollup
Create a similar rollup