rust/library/alloc
Matthias Krüger 1f700139f8
Rollup merge of #127586 - zachs18:more-must-use, r=cuviper
Add `#[must_use]` to some `into_raw*` functions.

cc #121287

r? ``@cuviper``

Adds `#[must_use = "losing the pointer will leak memory"]`[^1] to `Box::into_raw(_with_allocator)`, `Vec::into_raw_parts(_with_alloc)`, `String::into_raw_parts`[^2], and `rc::{Rc, Weak}::into_raw_with_allocator` (Rc's normal `into_raw` and all of `Arc`'s `into_raw*`s are already `must_use`).

Adds `#[must_use = "losing the raw <resource name may leak resources"]` to `IntoRawFd::into_raw_fd`, `IntoRawSocket::into_raw_socket`, and `IntoRawHandle::into_raw_handle`.

[^1]: "*will* leak memory" may be too-strong wording (since `Box`/`Vec`/`String`/`rc::Weak` might not have a backing allocation), but I left it as-is for simplicity and consistency.

[^2]: `String::into_raw_parts`'s `must_use` message is changed from the previous (possibly misleading) "`self` will be dropped if the result is not used".
2024-08-03 11:17:42 +02:00
..
benches Reformat use declarations. 2024-07-29 08:26:52 +10:00
src Rollup merge of #127586 - zachs18:more-must-use, r=cuviper 2024-08-03 11:17:42 +02:00
tests Reformat use declarations. 2024-07-29 08:26:52 +10:00
Cargo.toml Auto merge of #125016 - nicholasbishop:bishop-cb-112, r=tgross35 2024-07-29 07:41:33 +00:00