Skip to content

Commit 35ee6bd

Browse files
committed
panicking comments
1 parent e41ced3 commit 35ee6bd

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/libcore/panicking.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
//!
88
//! ```
99
//! # use std::fmt;
10-
//! fn panic_impl(fmt: fmt::Arguments, file_line_col: &(&'static str, u32, u32)) -> !
10+
//! fn panic_impl(pi: &PanicInfo<'_>) -> !
1111
//! # { loop {} }
1212
//! ```
1313
//!
@@ -35,7 +35,7 @@ use crate::panic::{Location, PanicInfo};
3535
// never inline unless panic_immediate_abort to avoid code
3636
// bloat at the call sites as much as possible
3737
#[cfg_attr(not(feature="panic_immediate_abort"),inline(never))]
38-
#[lang = "panic"]
38+
#[lang = "panic"] // needed by codegen for panic on overflow and other `Assert` MIR terminators
3939
pub fn panic(expr: &str, location: &Location<'_>) -> ! {
4040
if cfg!(feature = "panic_immediate_abort") {
4141
unsafe { super::intrinsics::abort() }
@@ -52,7 +52,7 @@ pub fn panic(expr: &str, location: &Location<'_>) -> ! {
5252

5353
#[cold]
5454
#[cfg_attr(not(feature="panic_immediate_abort"),inline(never))]
55-
#[lang = "panic_bounds_check"]
55+
#[lang = "panic_bounds_check"] // needed by codegen for panic on OOB array/slice access
5656
fn panic_bounds_check(location: &Location<'_>, index: usize, len: usize) -> ! {
5757
if cfg!(feature = "panic_immediate_abort") {
5858
unsafe { super::intrinsics::abort() }

src/libstd/panicking.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ pub fn panicking() -> bool {
294294
update_panic_count(0) != 0
295295
}
296296

297-
/// Entry point of panic from the libcore crate.
297+
/// Entry point of panic from the libcore crate (`panic_impl` lang item).
298298
#[cfg(not(test))]
299299
#[panic_handler]
300300
#[unwind(allowed)]
@@ -380,7 +380,7 @@ fn continue_panic_fmt(info: &PanicInfo<'_>) -> ! {
380380
#[unstable(feature = "libstd_sys_internals",
381381
reason = "used by the panic! macro",
382382
issue = "0")]
383-
#[cfg_attr(not(test), lang = "begin_panic")]
383+
#[cfg_attr(not(test), lang = "begin_panic")] // lang item for CTFE panic support
384384
// never inline unless panic_immediate_abort to avoid code
385385
// bloat at the call sites as much as possible
386386
#[cfg_attr(not(feature="panic_immediate_abort"),inline(never))]

0 commit comments

Comments
 (0)