diff options
| author | est31 <MTest31@outlook.com> | 2017-06-28 01:15:29 +0200 |
|---|---|---|
| committer | est31 <MTest31@outlook.com> | 2017-07-02 13:53:29 +0200 |
| commit | eb5fb21bd5871a0dd3bb7bc135bc1a083ad32292 (patch) | |
| tree | 53d595f50db5a07a4deeb7f080e5f056c6d9f176 /src/libcore/panicking.rs | |
| parent | da887074fc70a9f8d2afec8dbe6e2eeea6fc1406 (diff) | |
| download | rust-eb5fb21bd5871a0dd3bb7bc135bc1a083ad32292.tar.gz rust-eb5fb21bd5871a0dd3bb7bc135bc1a083ad32292.zip | |
Fix the test failure, add comment, and refactor a little bit
Diffstat (limited to 'src/libcore/panicking.rs')
| -rw-r--r-- | src/libcore/panicking.rs | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/src/libcore/panicking.rs b/src/libcore/panicking.rs index d4df0f69b90..eae33cf0422 100644 --- a/src/libcore/panicking.rs +++ b/src/libcore/panicking.rs @@ -38,13 +38,8 @@ use fmt; -#[cold] #[inline(never)] -pub fn panic_new(expr_file_line_col: &(&'static str, &'static str, u32, u32)) -> ! { - panic(&expr_file_line_col) -} - #[cold] #[inline(never)] // this is the slow path, always -#[lang = "panic"] +#[cfg_attr(not(stage0), lang = "panic")] pub fn panic(expr_file_line_col: &(&'static str, &'static str, u32, u32)) -> ! { // Use Arguments::new_v1 instead of format_args!("{}", expr) to potentially // reduce size overhead. The format_args! macro uses str's Display trait to @@ -56,17 +51,33 @@ pub fn panic(expr_file_line_col: &(&'static str, &'static str, u32, u32)) -> ! { panic_fmt(fmt::Arguments::new_v1(&[expr], &[]), &(file, line, col)) } +// FIXME: remove when SNAP #[cold] #[inline(never)] -#[lang = "panic_bounds_check"] +#[cfg(stage0)] +#[lang = "panic"] +pub fn panic_old(expr_file_line: &(&'static str, &'static str, u32)) -> ! { + let (expr, file, line) = *expr_file_line; + let expr_file_line_col = (expr, file, line, 0); + panic(&expr_file_line_col) +} + +#[cold] #[inline(never)] +#[cfg_attr(not(stage0), lang = "panic_bounds_check")] fn panic_bounds_check(file_line_col: &(&'static str, u32, u32), index: usize, len: usize) -> ! { panic_fmt(format_args!("index out of bounds: the len is {} but the index is {}", len, index), file_line_col) } +// FIXME: remove when SNAP #[cold] #[inline(never)] -pub fn panic_fmt_new(fmt: fmt::Arguments, file_line_col: &(&'static str, u32, u32)) -> ! { - panic_fmt(fmt, &file_line_col) +#[cfg(stage0)] +#[lang = "panic_bounds_check"] +fn panic_bounds_check_old(file_line: &(&'static str, u32), + index: usize, len: usize) -> ! { + let (file, line) = *file_line; + panic_fmt(format_args!("index out of bounds: the len is {} but the index is {}", + len, index), &(file, line, 0)) } #[cold] #[inline(never)] |
