From 35ee6bd59b20954bfee4e8c02ea16fedb6faca04 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sun, 24 Nov 2019 11:26:07 +0100 Subject: [PATCH 1/3] panicking comments --- src/libcore/panicking.rs | 6 +++--- src/libstd/panicking.rs | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/libcore/panicking.rs b/src/libcore/panicking.rs index 8a6ab99c65a..9940303ff32 100644 --- a/src/libcore/panicking.rs +++ b/src/libcore/panicking.rs @@ -7,7 +7,7 @@ //! //! ``` //! # use std::fmt; -//! fn panic_impl(fmt: fmt::Arguments, file_line_col: &(&'static str, u32, u32)) -> ! +//! fn panic_impl(pi: &PanicInfo<'_>) -> ! //! # { loop {} } //! ``` //! @@ -35,7 +35,7 @@ use crate::panic::{Location, PanicInfo}; // never inline unless panic_immediate_abort to avoid code // bloat at the call sites as much as possible #[cfg_attr(not(feature="panic_immediate_abort"),inline(never))] -#[lang = "panic"] +#[lang = "panic"] // needed by codegen for panic on overflow and other `Assert` MIR terminators pub fn panic(expr: &str, location: &Location<'_>) -> ! { if cfg!(feature = "panic_immediate_abort") { unsafe { super::intrinsics::abort() } @@ -52,7 +52,7 @@ pub fn panic(expr: &str, location: &Location<'_>) -> ! { #[cold] #[cfg_attr(not(feature="panic_immediate_abort"),inline(never))] -#[lang = "panic_bounds_check"] +#[lang = "panic_bounds_check"] // needed by codegen for panic on OOB array/slice access fn panic_bounds_check(location: &Location<'_>, index: usize, len: usize) -> ! { if cfg!(feature = "panic_immediate_abort") { unsafe { super::intrinsics::abort() } diff --git a/src/libstd/panicking.rs b/src/libstd/panicking.rs index f76969146fd..62cd190cf7a 100644 --- a/src/libstd/panicking.rs +++ b/src/libstd/panicking.rs @@ -294,7 +294,7 @@ pub fn panicking() -> bool { update_panic_count(0) != 0 } -/// Entry point of panic from the libcore crate. +/// Entry point of panic from the libcore crate (`panic_impl` lang item). #[cfg(not(test))] #[panic_handler] #[unwind(allowed)] @@ -380,7 +380,7 @@ fn continue_panic_fmt(info: &PanicInfo<'_>) -> ! { #[unstable(feature = "libstd_sys_internals", reason = "used by the panic! macro", issue = "0")] -#[cfg_attr(not(test), lang = "begin_panic")] +#[cfg_attr(not(test), lang = "begin_panic")] // lang item for CTFE panic support // never inline unless panic_immediate_abort to avoid code // bloat at the call sites as much as possible #[cfg_attr(not(feature="panic_immediate_abort"),inline(never))] From 80f5213cee9f98bf37b5e7244f2c71e94b5ed4dc Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sun, 24 Nov 2019 13:13:33 +0100 Subject: [PATCH 2/3] expand type info on __rust_start_panic --- src/libstd/panicking.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/libstd/panicking.rs b/src/libstd/panicking.rs index 62cd190cf7a..6819a4a04d7 100644 --- a/src/libstd/panicking.rs +++ b/src/libstd/panicking.rs @@ -44,6 +44,8 @@ extern { data: *mut u8, data_ptr: *mut usize, vtable_ptr: *mut usize) -> u32; + + /// `payload` is actually a `*mut &mut dyn BoxMeUp` but that would cause FFI warnings. #[unwind(allowed)] fn __rust_start_panic(payload: usize) -> u32; } From 6440b9425384d2f8f11c4fe281fe99f79b92afb6 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sun, 24 Nov 2019 13:15:22 +0100 Subject: [PATCH 3/3] make comment compile --- src/libcore/panicking.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/libcore/panicking.rs b/src/libcore/panicking.rs index 9940303ff32..4833194be37 100644 --- a/src/libcore/panicking.rs +++ b/src/libcore/panicking.rs @@ -6,8 +6,7 @@ //! interface for panicking is: //! //! ``` -//! # use std::fmt; -//! fn panic_impl(pi: &PanicInfo<'_>) -> ! +//! fn panic_impl(pi: &core::panic::PanicInfo<'_>) -> ! //! # { loop {} } //! ``` //!