diff --git a/src/libcore/option.rs b/src/libcore/option.rs index b27fd4098e167..2c148ec485767 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,8 @@ 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 8a09877ce1f4b..a31ac212dea24 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 {