1515 issue = "44489" ) ]
1616
1717use any:: Any ;
18+ use fmt;
1819
1920/// A struct providing information about a panic.
2021///
@@ -38,6 +39,7 @@ use any::Any;
3839#[ derive( Debug ) ]
3940pub struct PanicInfo < ' a > {
4041 payload : & ' a ( Any + Send ) ,
42+ message : Option < & ' a fmt:: Arguments < ' a > > ,
4143 location : Location < ' a > ,
4244}
4345
@@ -47,8 +49,11 @@ impl<'a> PanicInfo<'a> {
4749 and related macros",
4850 issue = "0" ) ]
4951 #[ doc( hidden) ]
50- pub fn internal_constructor ( payload : & ' a ( Any + Send ) , location : Location < ' a > , ) -> Self {
51- PanicInfo { payload, location }
52+ pub fn internal_constructor ( payload : & ' a ( Any + Send ) ,
53+ message : Option < & ' a fmt:: Arguments < ' a > > ,
54+ location : Location < ' a > )
55+ -> Self {
56+ PanicInfo { payload, location, message }
5257 }
5358
5459 /// Returns the payload associated with the panic.
@@ -73,6 +78,16 @@ impl<'a> PanicInfo<'a> {
7378 self . payload
7479 }
7580
81+ /// If the `panic!` macro from the `core` crate (not from `std`)
82+ /// was used with a formatting string and some additional arguments,
83+ /// returns that message ready to be used for example with [`fmt::write`]
84+ ///
85+ /// [`fmt::write`]: ../fmt/fn.write.html
86+ #[ unstable( feature = "panic_info_message" , issue = "44489" ) ]
87+ pub fn message ( & self ) -> Option < & fmt:: Arguments > {
88+ self . message
89+ }
90+
7691 /// Returns information about the location from which the panic originated,
7792 /// if available.
7893 ///
0 commit comments