Closed
Description
I tried this code:
#![allow(dead_code)]
unsafe fn free<T>(ptr: *mut T) {
Box::from_raw(ptr);
}
fn main() {}
I expected to see this happen: explanation
The same as CString::from_raw
, I expected the following warning:
warning: unused return value of `Box::<T>::from_raw` that must be used
--> foo.rs:4:5
|
4 | Box::from_raw(ptr);
| ^^^^^^^^^^^^^^^^^^^
|
= note: `#[warn(unused_must_use)]` on by default
= note: call `drop(from_raw(ptr))` if you intend to drop the `Box`
Instead, this happened: explanation
No warning is reported.
Meta
rustc --version --verbose
:
rustc 1.62.0 (a8314ef7d 2022-06-27)
binary: rustc
commit-hash: a8314ef7d0ec7b75c336af2c9857bfaf43002bfc
commit-date: 2022-06-27
host: x86_64-apple-darwin
release: 1.62.0
LLVM version: 14.0.5
Note that #[must_use]
was added to CString::from_raw
at #89753 following the activity tracked at #89692.
I'm creating this issue after discussion at rust-lang/regex#882.