File tree Expand file tree Collapse file tree 4 files changed +16
-2
lines changed Expand file tree Collapse file tree 4 files changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -337,7 +337,7 @@ impl<'a> Arguments<'a> {
337
337
#[ doc( hidden) ]
338
338
#[ inline]
339
339
#[ unstable( feature = "fmt_internals" , reason = "internal to format_args!" , issue = "none" ) ]
340
- pub fn new_v1 ( pieces : & ' a [ & ' static str ] , args : & ' a [ ArgumentV1 < ' a > ] ) -> Arguments < ' a > {
340
+ pub const fn new_v1 ( pieces : & ' a [ & ' static str ] , args : & ' a [ ArgumentV1 < ' a > ] ) -> Arguments < ' a > {
341
341
Arguments { pieces, fmt : None , args }
342
342
}
343
343
@@ -350,7 +350,7 @@ impl<'a> Arguments<'a> {
350
350
#[ doc( hidden) ]
351
351
#[ inline]
352
352
#[ unstable( feature = "fmt_internals" , reason = "internal to format_args!" , issue = "none" ) ]
353
- pub fn new_v1_formatted (
353
+ pub const fn new_v1_formatted (
354
354
pieces : & ' a [ & ' static str ] ,
355
355
args : & ' a [ ArgumentV1 < ' a > ] ,
356
356
fmt : & ' a [ rt:: v1:: Argument ] ,
Original file line number Diff line number Diff line change 73
73
#![ feature( cfg_target_has_atomic) ]
74
74
#![ feature( const_heap) ]
75
75
#![ feature( const_alloc_layout) ]
76
+ #![ feature( const_arguments_as_str) ]
76
77
#![ feature( const_assert_type) ]
77
78
#![ feature( const_discriminant) ]
78
79
#![ feature( const_cell_into_inner) ]
Original file line number Diff line number Diff line change @@ -74,6 +74,7 @@ fn panic_bounds_check(index: usize, len: usize) -> ! {
74
74
#[ cfg_attr( not( feature = "panic_immediate_abort" ) , inline( never) ) ]
75
75
#[ cfg_attr( feature = "panic_immediate_abort" , inline) ]
76
76
#[ track_caller]
77
+ #[ cfg_attr( not( bootstrap) , lang = "panic_fmt" ) ] // needed for const-evaluated panics
77
78
pub fn panic_fmt ( fmt : fmt:: Arguments < ' _ > ) -> ! {
78
79
if cfg ! ( feature = "panic_immediate_abort" ) {
79
80
super :: intrinsics:: abort ( )
@@ -92,6 +93,17 @@ pub fn panic_fmt(fmt: fmt::Arguments<'_>) -> ! {
92
93
unsafe { panic_impl ( & pi) }
93
94
}
94
95
96
+ /// This function is used instead of panic_fmt in const eval.
97
+ #[ cfg( not( bootstrap) ) ]
98
+ #[ lang = "const_panic_fmt" ]
99
+ pub const fn const_panic_fmt ( fmt : fmt:: Arguments < ' _ > ) -> ! {
100
+ if let Some ( msg) = fmt. as_str ( ) {
101
+ panic_str ( msg) ;
102
+ } else {
103
+ panic_str ( "???" ) ;
104
+ }
105
+ }
106
+
95
107
#[ derive( Debug ) ]
96
108
#[ doc( hidden) ]
97
109
pub enum AssertKind {
Original file line number Diff line number Diff line change @@ -448,6 +448,7 @@ pub fn panicking() -> bool {
448
448
#[ cfg_attr( not( feature = "panic_immediate_abort" ) , track_caller) ]
449
449
#[ cfg_attr( not( feature = "panic_immediate_abort" ) , inline( never) ) ]
450
450
#[ cfg_attr( feature = "panic_immediate_abort" , inline) ]
451
+ #[ cfg_attr( all( not( bootstrap) , not( test) ) , lang = "begin_panic_fmt" ) ]
451
452
pub fn begin_panic_fmt ( msg : & fmt:: Arguments < ' _ > ) -> ! {
452
453
if cfg ! ( feature = "panic_immediate_abort" ) {
453
454
intrinsics:: abort ( )
You can’t perform that action at this time.
0 commit comments