@@ -341,6 +341,7 @@ impl<T> Option<T> {
341
341
/// x.expect("the world is ending"); // panics with `the world is ending`
342
342
/// ```
343
343
#[ inline]
344
+ #[ track_caller]
344
345
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
345
346
pub fn expect ( self , msg : & str ) -> T {
346
347
match self {
@@ -374,6 +375,7 @@ impl<T> Option<T> {
374
375
/// assert_eq!(x.unwrap(), "air"); // fails
375
376
/// ```
376
377
#[ inline]
378
+ #[ track_caller]
377
379
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
378
380
pub fn unwrap ( self ) -> T {
379
381
match self {
@@ -1015,6 +1017,7 @@ impl<T: fmt::Debug> Option<T> {
1015
1017
/// }
1016
1018
/// ```
1017
1019
#[ inline]
1020
+ #[ track_caller]
1018
1021
#[ unstable( feature = "option_expect_none" , reason = "newly added" , issue = "62633" ) ]
1019
1022
pub fn expect_none ( self , msg : & str ) {
1020
1023
if let Some ( val) = self {
@@ -1057,6 +1060,7 @@ impl<T: fmt::Debug> Option<T> {
1057
1060
/// }
1058
1061
/// ```
1059
1062
#[ inline]
1063
+ #[ track_caller]
1060
1064
#[ unstable( feature = "option_unwrap_none" , reason = "newly added" , issue = "62633" ) ]
1061
1065
pub fn unwrap_none ( self ) {
1062
1066
if let Some ( val) = self {
@@ -1184,13 +1188,15 @@ impl<T, E> Option<Result<T, E>> {
1184
1188
// This is a separate function to reduce the code size of .expect() itself.
1185
1189
#[ inline( never) ]
1186
1190
#[ cold]
1191
+ #[ track_caller]
1187
1192
fn expect_failed ( msg : & str ) -> ! {
1188
1193
panic ! ( "{}" , msg)
1189
1194
}
1190
1195
1191
1196
// This is a separate function to reduce the code size of .expect_none() itself.
1192
1197
#[ inline( never) ]
1193
1198
#[ cold]
1199
+ #[ track_caller]
1194
1200
fn expect_none_failed ( msg : & str , value : & dyn fmt:: Debug ) -> ! {
1195
1201
panic ! ( "{}: {:?}" , msg, value)
1196
1202
}
0 commit comments