@@ -341,6 +341,7 @@ impl<T> Option<T> {
341341 /// x.expect("the world is ending"); // panics with `the world is ending`
342342 /// ```
343343 #[ inline]
344+ #[ track_caller]
344345 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
345346 pub fn expect ( self , msg : & str ) -> T {
346347 match self {
@@ -374,6 +375,7 @@ impl<T> Option<T> {
374375 /// assert_eq!(x.unwrap(), "air"); // fails
375376 /// ```
376377 #[ inline]
378+ #[ track_caller]
377379 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
378380 pub fn unwrap ( self ) -> T {
379381 match self {
@@ -1015,6 +1017,7 @@ impl<T: fmt::Debug> Option<T> {
10151017 /// }
10161018 /// ```
10171019 #[ inline]
1020+ #[ track_caller]
10181021 #[ unstable( feature = "option_expect_none" , reason = "newly added" , issue = "62633" ) ]
10191022 pub fn expect_none ( self , msg : & str ) {
10201023 if let Some ( val) = self {
@@ -1057,6 +1060,7 @@ impl<T: fmt::Debug> Option<T> {
10571060 /// }
10581061 /// ```
10591062 #[ inline]
1063+ #[ track_caller]
10601064 #[ unstable( feature = "option_unwrap_none" , reason = "newly added" , issue = "62633" ) ]
10611065 pub fn unwrap_none ( self ) {
10621066 if let Some ( val) = self {
@@ -1184,13 +1188,15 @@ impl<T, E> Option<Result<T, E>> {
11841188// This is a separate function to reduce the code size of .expect() itself.
11851189#[ inline( never) ]
11861190#[ cold]
1191+ #[ track_caller]
11871192fn expect_failed ( msg : & str ) -> ! {
11881193 panic ! ( "{}" , msg)
11891194}
11901195
11911196// This is a separate function to reduce the code size of .expect_none() itself.
11921197#[ inline( never) ]
11931198#[ cold]
1199+ #[ track_caller]
11941200fn expect_none_failed ( msg : & str , value : & dyn fmt:: Debug ) -> ! {
11951201 panic ! ( "{}: {:?}" , msg, value)
11961202}
0 commit comments