forked from rust-lang/glacier
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rust-lang/rust#92054 Kudos to @mwerschy for reducing.
- Loading branch information
Showing
2 changed files
with
20 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#![feature(allocator_api)] | ||
|
||
use std::alloc::{Allocator, Global, Layout}; | ||
|
||
fn main() { | ||
let layout: Layout = None.unwrap(); | ||
let ptr: *mut u8 = Global.allocate(layout).unwrap().as_ptr() as _; | ||
let box_ = unsafe { Box::from_raw_in(ptr, &Global) }; | ||
} |
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 @@ | ||
#![feature(allocator_api)] | ||
|
||
use std::alloc::{Allocator, Global, Layout}; | ||
|
||
fn main() { | ||
let layout: Layout = None.unwrap(); | ||
let ptr: *mut u8 = Global.allocate(layout).unwrap().as_ptr() as _; | ||
let slice: &mut [u8] = unsafe { std::slice::from_raw_parts_mut(ptr, 0) }; | ||
let box_ = unsafe { Box::from_raw_in(slice, &Global) }; | ||
box_.len(); | ||
} |