-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of #99270 - rhysd:issue-99269, r=Mark-Simulacrum
Add `#[must_use]` to `Box::from_raw` Fixes #99269
- Loading branch information
Showing
3 changed files
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// #99269 | ||
|
||
// check-pass | ||
|
||
#![warn(unused_must_use)] | ||
|
||
unsafe fn free<T>(ptr: *mut T) { | ||
Box::from_raw(ptr); //~ WARNING unused return value | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
warning: unused return value of `Box::<T>::from_raw` that must be used | ||
--> $DIR/must-use-box-from-raw.rs:8:5 | ||
| | ||
LL | Box::from_raw(ptr); | ||
| ^^^^^^^^^^^^^^^^^^^ | ||
| | ||
note: the lint level is defined here | ||
--> $DIR/must-use-box-from-raw.rs:5:9 | ||
| | ||
LL | #![warn(unused_must_use)] | ||
| ^^^^^^^^^^^^^^^ | ||
= note: call `drop(from_raw(ptr))` if you intend to drop the `Box` | ||
|
||
warning: 1 warning emitted | ||
|