Skip to content

Commit 96b299e

Browse files
committed
std: Remove unstable::lang
Put the lonely lang items here closer to the code they are calling.
1 parent 3e57808 commit 96b299e

File tree

4 files changed

+36
-55
lines changed

4 files changed

+36
-55
lines changed

src/libstd/rt/local_heap.rs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,14 @@ impl Drop for MemoryRegion {
276276
}
277277
}
278278

279+
280+
#[cfg(not(test))]
281+
#[lang="malloc"]
282+
#[inline]
283+
pub unsafe fn local_malloc_(drop_glue: fn(*mut u8), size: uint, align: uint) -> *u8 {
284+
local_malloc(drop_glue, size, align)
285+
}
286+
279287
#[inline]
280288
pub unsafe fn local_malloc(drop_glue: fn(*mut u8), size: uint, align: uint) -> *u8 {
281289
// FIXME: Unsafe borrow for speed. Lame.
@@ -288,7 +296,16 @@ pub unsafe fn local_malloc(drop_glue: fn(*mut u8), size: uint, align: uint) -> *
288296
}
289297
}
290298

291-
// A little compatibility function
299+
#[cfg(not(test))]
300+
#[lang="free"]
301+
#[inline]
302+
pub unsafe fn local_free_(ptr: *u8) {
303+
local_free(ptr)
304+
}
305+
306+
// NB: Calls to free CANNOT be allowed to fail, as throwing an exception from
307+
// inside a landing pad may corrupt the state of the exception handler. If a
308+
// problem occurs, call exit instead.
292309
#[inline]
293310
pub unsafe fn local_free(ptr: *u8) {
294311
// FIXME: Unsafe borrow for speed. Lame.

src/libstd/rt/unwind.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,24 @@ pub mod eabi {
376376
}
377377
}
378378

379+
#[cold]
380+
#[lang="fail_"]
381+
#[cfg(not(test))]
382+
pub fn fail_(expr: *u8, file: *u8, line: uint) -> ! {
383+
begin_unwind_raw(expr, file, line);
384+
}
385+
386+
#[cold]
387+
#[lang="fail_bounds_check"]
388+
#[cfg(not(test))]
389+
pub fn fail_bounds_check(file: *u8, line: uint, index: uint, len: uint) -> ! {
390+
use c_str::ToCStr;
391+
392+
let msg = format!("index out of bounds: the len is {} but the index is {}",
393+
len as uint, index as uint);
394+
msg.with_c_str(|buf| fail_(buf as *u8, file, line))
395+
}
396+
379397
/// This is the entry point of unwinding for things like lang items and such.
380398
/// The arguments are normally generated by the compiler, and need to
381399
/// have static lifetimes.

src/libstd/unstable/lang.rs

Lines changed: 0 additions & 52 deletions
This file was deleted.

src/libstd/unstable/mod.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ pub mod dynamic_lib;
1717

1818
pub mod finally;
1919
pub mod simd;
20-
#[cfg(not(test))]
21-
pub mod lang;
2220
pub mod sync;
2321
pub mod mutex;
2422
pub mod stack;

0 commit comments

Comments
 (0)