20
20
//! one function. Currently, the actual symbol is declared in the standard
21
21
//! library, but the location of this may change over time.
22
22
23
- // ignore-tidy-undocumented-unsafe
24
-
25
23
#![ allow( dead_code, missing_docs) ]
26
24
#![ unstable( feature = "core_panic" ,
27
25
reason = "internal details of the implementation of the `panic!` \
@@ -39,6 +37,7 @@ use crate::panic::{Location, PanicInfo};
39
37
#[ lang = "panic" ]
40
38
pub fn panic ( expr_file_line_col : & ( & ' static str , & ' static str , u32 , u32 ) ) -> ! {
41
39
if cfg ! ( feature = "panic_immediate_abort" ) {
40
+ // SAFETY: ends the program
42
41
unsafe { super :: intrinsics:: abort ( ) }
43
42
}
44
43
@@ -60,6 +59,7 @@ pub fn panic(expr_file_line_col: &(&'static str, &'static str, u32, u32)) -> ! {
60
59
#[ lang = "panic" ]
61
60
pub fn panic ( expr : & str , location : & Location < ' _ > ) -> ! {
62
61
if cfg ! ( feature = "panic_immediate_abort" ) {
62
+ // SAFETY: ends the program
63
63
unsafe { super :: intrinsics:: abort ( ) }
64
64
}
65
65
@@ -79,6 +79,7 @@ pub fn panic(expr: &str, location: &Location<'_>) -> ! {
79
79
fn panic_bounds_check ( file_line_col : & ( & ' static str , u32 , u32 ) ,
80
80
index : usize , len : usize ) -> ! {
81
81
if cfg ! ( feature = "panic_immediate_abort" ) {
82
+ // SAFETY: ends the program
82
83
unsafe { super :: intrinsics:: abort ( ) }
83
84
}
84
85
@@ -92,6 +93,7 @@ fn panic_bounds_check(file_line_col: &(&'static str, u32, u32),
92
93
#[ lang = "panic_bounds_check" ]
93
94
fn panic_bounds_check ( location : & Location < ' _ > , index : usize , len : usize ) -> ! {
94
95
if cfg ! ( feature = "panic_immediate_abort" ) {
96
+ // SAFETY: ends the program
95
97
unsafe { super :: intrinsics:: abort ( ) }
96
98
}
97
99
@@ -107,6 +109,7 @@ fn panic_bounds_check(location: &Location<'_>, index: usize, len: usize) -> ! {
107
109
#[ cfg_attr( feature="panic_immediate_abort" , inline) ]
108
110
pub fn panic_fmt ( fmt : fmt:: Arguments < ' _ > , file_line_col : & ( & ' static str , u32 , u32 ) ) -> ! {
109
111
if cfg ! ( feature = "panic_immediate_abort" ) {
112
+ // SAFETY: ends the program
110
113
unsafe { super :: intrinsics:: abort ( ) }
111
114
}
112
115
@@ -119,6 +122,7 @@ pub fn panic_fmt(fmt: fmt::Arguments<'_>, file_line_col: &(&'static str, u32, u3
119
122
let ( file, line, col) = * file_line_col;
120
123
let location = Location :: internal_constructor ( file, line, col) ;
121
124
let pi = PanicInfo :: internal_constructor ( Some ( & fmt) , & location) ;
125
+ // SAFETY: psuedo-FFI call to end the program
122
126
unsafe { panic_impl ( & pi) }
123
127
}
124
128
@@ -128,6 +132,7 @@ pub fn panic_fmt(fmt: fmt::Arguments<'_>, file_line_col: &(&'static str, u32, u3
128
132
#[ cfg_attr( feature="panic_immediate_abort" , inline) ]
129
133
pub fn panic_fmt ( fmt : fmt:: Arguments < ' _ > , location : & Location < ' _ > ) -> ! {
130
134
if cfg ! ( feature = "panic_immediate_abort" ) {
135
+ // SAFETY: ends the program
131
136
unsafe { super :: intrinsics:: abort ( ) }
132
137
}
133
138
@@ -138,5 +143,6 @@ pub fn panic_fmt(fmt: fmt::Arguments<'_>, location: &Location<'_>) -> ! {
138
143
}
139
144
140
145
let pi = PanicInfo :: internal_constructor ( Some ( & fmt) , location) ;
146
+ // SAFETY: psuedo-FFI call to end the program
141
147
unsafe { panic_impl ( & pi) }
142
148
}
0 commit comments