about summary refs log tree commit diff
path: root/src/libcore
diff options
context:
space:
mode:
authorAdam Perry <adam.n.perry@gmail.com>2020-01-04 19:42:21 -0800
committerAdam Perry <adam.n.perry@gmail.com>2020-01-04 19:52:37 -0800
commit7a6af7eb0ef685c2dfd907f7e76a876174c9f665 (patch)
tree5c8cebce3845f2959155f37c86c19f3ac0f47cb6 /src/libcore
parent2e9d573d3f6bc9808e01cef914084fac15f42cc2 (diff)
downloadrust-7a6af7eb0ef685c2dfd907f7e76a876174c9f665.tar.gz
rust-7a6af7eb0ef685c2dfd907f7e76a876174c9f665.zip
Result's panics have `#[track_caller]`.
Diffstat (limited to 'src/libcore')
-rw-r--r--src/libcore/result.rs5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/libcore/result.rs b/src/libcore/result.rs
index 5cfc81097dd..b39abf91785 100644
--- a/src/libcore/result.rs
+++ b/src/libcore/result.rs
@@ -957,6 +957,7 @@ impl<T, E: fmt::Debug> Result<T, E> {
     /// x.unwrap(); // panics with `emergency failure`
     /// ```
     #[inline]
+    #[track_caller]
     #[stable(feature = "rust1", since = "1.0.0")]
     pub fn unwrap(self) -> T {
         match self {
@@ -984,6 +985,7 @@ impl<T, E: fmt::Debug> Result<T, E> {
     /// x.expect("Testing expect"); // panics with `Testing expect: emergency failure`
     /// ```
     #[inline]
+    #[track_caller]
     #[stable(feature = "result_expect", since = "1.4.0")]
     pub fn expect(self, msg: &str) -> T {
         match self {
@@ -1017,6 +1019,7 @@ impl<T: fmt::Debug, E> Result<T, E> {
     /// assert_eq!(x.unwrap_err(), "emergency failure");
     /// ```
     #[inline]
+    #[track_caller]
     #[stable(feature = "rust1", since = "1.0.0")]
     pub fn unwrap_err(self) -> E {
         match self {
@@ -1044,6 +1047,7 @@ impl<T: fmt::Debug, E> Result<T, E> {
     /// x.expect_err("Testing expect_err"); // panics with `Testing expect_err: 10`
     /// ```
     #[inline]
+    #[track_caller]
     #[stable(feature = "result_expect_err", since = "1.17.0")]
     pub fn expect_err(self, msg: &str) -> E {
         match self {
@@ -1188,6 +1192,7 @@ impl<T, E> Result<Option<T>, E> {
 // This is a separate function to reduce the code size of the methods
 #[inline(never)]
 #[cold]
+#[track_caller]
 fn unwrap_failed(msg: &str, error: &dyn fmt::Debug) -> ! {
     panic!("{}: {:?}", msg, error)
 }