diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2021-10-11 14:11:45 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-10-11 14:11:45 +0200 |
| commit | 96ffc74fe3f7dfc85d165d08b040634ce9400e33 (patch) | |
| tree | dff03f4122cf0b6f2fd61862b5e04adf542a2919 /library/core/src/alloc | |
| parent | 9183942e8383b4a2c40f8eeb872c71ab3d8c60fe (diff) | |
| parent | cf2bcd10ed28b169b8df74383c2a35a4ffbdcf40 (diff) | |
| download | rust-96ffc74fe3f7dfc85d165d08b040634ce9400e33.tar.gz rust-96ffc74fe3f7dfc85d165d08b040634ce9400e33.zip | |
Rollup merge of #89753 - jkugelman:must-use-from_value-conversions, r=joshtriplett
Add #[must_use] to from_value conversions
I added two methods to the list myself. Clippy did not flag them because they take `mut` args, but neither modifies their argument.
```rust
core::str const unsafe fn from_utf8_unchecked_mut(v: &mut [u8]) -> &mut str;
std::ffi::CString unsafe fn from_raw(ptr: *mut c_char) -> CString;
```
I put a custom note on `from_raw`:
```rust
#[must_use = "call `drop(from_raw(ptr))` if you intend to drop the `CString`"]
pub unsafe fn from_raw(ptr: *mut c_char) -> CString {
```
Parent issue: #89692
r? ``@joshtriplett``
Diffstat (limited to 'library/core/src/alloc')
| -rw-r--r-- | library/core/src/alloc/layout.rs | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/library/core/src/alloc/layout.rs b/library/core/src/alloc/layout.rs index c98aa38e3df..d4c8ea33501 100644 --- a/library/core/src/alloc/layout.rs +++ b/library/core/src/alloc/layout.rs @@ -94,6 +94,7 @@ impl Layout { /// [`Layout::from_size_align`]. #[stable(feature = "alloc_layout", since = "1.28.0")] #[rustc_const_stable(feature = "alloc_layout", since = "1.36.0")] + #[must_use] #[inline] pub const unsafe fn from_size_align_unchecked(size: usize, align: usize) -> Self { // SAFETY: the caller must ensure that `align` is greater than zero. |
