diff options
| author | Patrick Walton <pcwalton@mimiga.net> | 2014-05-19 23:19:56 -0700 |
|---|---|---|
| committer | Patrick Walton <pcwalton@mimiga.net> | 2014-05-22 14:42:02 -0700 |
| commit | e878721d70349e2055f0ef854085de92e9498fde (patch) | |
| tree | 35940d52f145bca81dcf73e5e7da7f3847ceb413 /src/liballoc | |
| parent | 5633d4641f7d63805e3c12c899f8401410bd825f (diff) | |
| download | rust-e878721d70349e2055f0ef854085de92e9498fde.tar.gz rust-e878721d70349e2055f0ef854085de92e9498fde.zip | |
libcore: Remove all uses of `~str` from `libcore`.
[breaking-change]
Diffstat (limited to 'src/liballoc')
| -rw-r--r-- | src/liballoc/heap.rs | 12 | ||||
| -rw-r--r-- | src/liballoc/util.rs | 17 |
2 files changed, 23 insertions, 6 deletions
diff --git a/src/liballoc/heap.rs b/src/liballoc/heap.rs index 631b72cb897..8376fc578db 100644 --- a/src/liballoc/heap.rs +++ b/src/liballoc/heap.rs @@ -116,18 +116,18 @@ pub fn stats_print() { } } +// The compiler never calls `exchange_free` on ~ZeroSizeType, so zero-size +// allocations can point to this `static`. It would be incorrect to use a null +// pointer, due to enums assuming types like unique pointers are never null. +pub static mut EMPTY: uint = 12345; + /// The allocator for unique pointers. #[cfg(not(test))] #[lang="exchange_malloc"] #[inline] unsafe fn exchange_malloc(size: uint, align: uint) -> *mut u8 { - // The compiler never calls `exchange_free` on ~ZeroSizeType, so zero-size - // allocations can point to this `static`. It would be incorrect to use a null - // pointer, due to enums assuming types like unique pointers are never null. - static EMPTY: () = (); - if size == 0 { - &EMPTY as *() as *mut u8 + &EMPTY as *uint as *mut u8 } else { allocate(size, align) } diff --git a/src/liballoc/util.rs b/src/liballoc/util.rs index 7e35af79eab..64d62035890 100644 --- a/src/liballoc/util.rs +++ b/src/liballoc/util.rs @@ -28,3 +28,20 @@ fn align_to(size: uint, align: uint) -> uint { assert!(align != 0); (size + align - 1) & !(align - 1) } + +// FIXME(#14344): When linking liballoc with libstd, this library will be linked +// as an rlib (it only exists as an rlib). It turns out that an +// optimized standard library doesn't actually use *any* symbols +// from this library. Everything is inlined and optimized away. +// This means that linkers will actually omit the object for this +// file, even though it may be needed in the future. +// +// To get around this for now, we define a dummy symbol which +// will never get inlined so the stdlib can call it. The stdlib's +// reference to this symbol will cause this library's object file +// to get linked in to libstd successfully (the linker won't +// optimize it out). +#[deprecated] +#[doc(hidden)] +pub fn make_stdlib_link_work() {} + |
