From 0eaeb6c57b99d4f274024ee7d7fc80467ccfeed8 Mon Sep 17 00:00:00 2001 From: Jane Losare-Lusby Date: Thu, 5 Jun 2025 10:29:21 -0700 Subject: [PATCH] add track_caller attribute to map_err and ok_or/_else --- library/core/src/option.rs | 2 ++ library/core/src/result.rs | 1 + 2 files changed, 3 insertions(+) diff --git a/library/core/src/option.rs b/library/core/src/option.rs index 675556b07a838..58a254450f965 100644 --- a/library/core/src/option.rs +++ b/library/core/src/option.rs @@ -1305,6 +1305,7 @@ impl Option { /// assert_eq!(x.ok_or(0), Err(0)); /// ``` #[inline] + #[track_caller] #[stable(feature = "rust1", since = "1.0.0")] pub fn ok_or(self, err: E) -> Result { match self { @@ -1330,6 +1331,7 @@ impl Option { /// assert_eq!(x.ok_or_else(|| 0), Err(0)); /// ``` #[inline] + #[track_caller] #[stable(feature = "rust1", since = "1.0.0")] pub fn ok_or_else(self, err: F) -> Result where diff --git a/library/core/src/result.rs b/library/core/src/result.rs index 23e32c2e0f01d..520922b4579a3 100644 --- a/library/core/src/result.rs +++ b/library/core/src/result.rs @@ -907,6 +907,7 @@ impl Result { /// assert_eq!(x.map_err(stringify), Err("error code: 13".to_string())); /// ``` #[inline] + #[track_caller] #[stable(feature = "rust1", since = "1.0.0")] pub fn map_err F>(self, op: O) -> Result { match self {