File tree Expand file tree Collapse file tree 2 files changed +8
-1
lines changed Expand file tree Collapse file tree 2 files changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ macro_rules! panic {
10
10
$crate:: panicking:: panic( $msg)
11
11
) ;
12
12
( $msg: expr) => (
13
- $crate:: panic! ( "{}" , $crate :: convert :: identity :: < & str > ( $msg) )
13
+ $crate:: panicking :: panic_str ( $msg)
14
14
) ;
15
15
( $msg: expr, ) => (
16
16
$crate:: panic!( $msg)
Original file line number Diff line number Diff line change @@ -50,6 +50,13 @@ pub fn panic(expr: &'static str) -> ! {
50
50
panic_fmt ( fmt:: Arguments :: new_v1 ( & [ expr] , & [ ] ) ) ;
51
51
}
52
52
53
+ #[ inline]
54
+ #[ track_caller]
55
+ #[ cfg_attr( not( bootstrap) , lang = "panic_str" ) ] // needed for const-evaluated panics
56
+ pub fn panic_str ( expr : & str ) -> ! {
57
+ panic_fmt ( format_args ! ( "{}" , expr) ) ;
58
+ }
59
+
53
60
#[ cold]
54
61
#[ cfg_attr( not( feature = "panic_immediate_abort" ) , inline( never) ) ]
55
62
#[ track_caller]
You can’t perform that action at this time.
0 commit comments