From 145385e7c3fbb242e3024ad0368f2cfd95f5666e Mon Sep 17 00:00:00 2001 From: Chris Gregory Date: Fri, 5 Jul 2019 20:57:25 -0700 Subject: [PATCH] Add messages to Option and Result must_use for is_* --- src/libcore/option.rs | 4 ++-- src/libcore/result.rs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libcore/option.rs b/src/libcore/option.rs index b27fd4098e16..9174ebae171d 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -178,7 +178,7 @@ impl Option { /// ``` /// /// [`Some`]: #variant.Some - #[must_use] + #[must_use = "if you intended to assert that this has a value, consider `.unwrap()` instead"] #[inline] #[stable(feature = "rust1", since = "1.0.0")] pub fn is_some(&self) -> bool { @@ -201,7 +201,7 @@ impl Option { /// ``` /// /// [`None`]: #variant.None - #[must_use] + #[must_use = "if you intended to assert that this doesn't have a value, consider `.and_then(|| panic!(\"`Option` had a value when expected `None`\"))` instead"] #[inline] #[stable(feature = "rust1", since = "1.0.0")] pub fn is_none(&self) -> bool { diff --git a/src/libcore/result.rs b/src/libcore/result.rs index 8a09877ce1f4..a31ac212dea2 100644 --- a/src/libcore/result.rs +++ b/src/libcore/result.rs @@ -277,7 +277,7 @@ impl Result { /// let x: Result = Err("Some error message"); /// assert_eq!(x.is_ok(), false); /// ``` - #[must_use] + #[must_use = "if you intended to assert that this is ok, consider `.unwrap()` instead"] #[inline] #[stable(feature = "rust1", since = "1.0.0")] pub fn is_ok(&self) -> bool { @@ -302,7 +302,7 @@ impl Result { /// let x: Result = Err("Some error message"); /// assert_eq!(x.is_err(), true); /// ``` - #[must_use] + #[must_use = "if you intended to assert that this is err, consider `.unwrap_err()` instead"] #[inline] #[stable(feature = "rust1", since = "1.0.0")] pub fn is_err(&self) -> bool {