Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add #[must_use] to is_condition tests #89718

Merged
merged 1 commit into from
Oct 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions library/alloc/src/collections/btree/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,7 @@ impl<T> BTreeSet<T> {
/// b.insert(1);
/// assert_eq!(a.is_disjoint(&b), false);
/// ```
#[must_use]
#[stable(feature = "rust1", since = "1.0.0")]
pub fn is_disjoint(&self, other: &BTreeSet<T>) -> bool
where
Expand All @@ -559,6 +560,7 @@ impl<T> BTreeSet<T> {
/// set.insert(4);
/// assert_eq!(set.is_subset(&sup), false);
/// ```
#[must_use]
#[stable(feature = "rust1", since = "1.0.0")]
pub fn is_subset(&self, other: &BTreeSet<T>) -> bool
where
Expand Down Expand Up @@ -638,6 +640,7 @@ impl<T> BTreeSet<T> {
/// set.insert(2);
/// assert_eq!(set.is_superset(&sub), true);
/// ```
#[must_use]
#[stable(feature = "rust1", since = "1.0.0")]
pub fn is_superset(&self, other: &BTreeSet<T>) -> bool
where
Expand Down
19 changes: 19 additions & 0 deletions library/core/src/char/methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -692,6 +692,7 @@ impl char {
/// // love is many things, but it is not alphabetic
/// assert!(!c.is_alphabetic());
/// ```
#[must_use]
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn is_alphabetic(self) -> bool {
Expand Down Expand Up @@ -724,6 +725,7 @@ impl char {
/// assert!(!'中'.is_lowercase());
/// assert!(!' '.is_lowercase());
/// ```
#[must_use]
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn is_lowercase(self) -> bool {
Expand Down Expand Up @@ -756,6 +758,7 @@ impl char {
/// assert!(!'中'.is_uppercase());
/// assert!(!' '.is_uppercase());
/// ```
#[must_use]
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn is_uppercase(self) -> bool {
Expand Down Expand Up @@ -784,6 +787,7 @@ impl char {
///
/// assert!(!'越'.is_whitespace());
/// ```
#[must_use]
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn is_whitespace(self) -> bool {
Expand Down Expand Up @@ -812,6 +816,7 @@ impl char {
/// assert!('و'.is_alphanumeric());
/// assert!('藏'.is_alphanumeric());
/// ```
#[must_use]
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn is_alphanumeric(self) -> bool {
Expand All @@ -837,6 +842,7 @@ impl char {
/// assert!('œ'.is_control());
/// assert!(!'q'.is_control());
/// ```
#[must_use]
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn is_control(self) -> bool {
Expand All @@ -852,6 +858,7 @@ impl char {
/// [uax29]: https://www.unicode.org/reports/tr29/
/// [ucd]: https://www.unicode.org/reports/tr44/
/// [`DerivedCoreProperties.txt`]: https://www.unicode.org/Public/UCD/latest/ucd/DerivedCoreProperties.txt
#[must_use]
#[inline]
pub(crate) fn is_grapheme_extended(self) -> bool {
unicode::Grapheme_Extend(self)
Expand Down Expand Up @@ -881,6 +888,7 @@ impl char {
/// assert!(!'و'.is_numeric());
/// assert!(!'藏'.is_numeric());
/// ```
#[must_use]
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn is_numeric(self) -> bool {
Expand Down Expand Up @@ -1060,6 +1068,7 @@ impl char {
/// assert!(ascii.is_ascii());
/// assert!(!non_ascii.is_ascii());
/// ```
#[must_use]
#[stable(feature = "ascii_methods_on_intrinsics", since = "1.23.0")]
#[rustc_const_stable(feature = "const_ascii_methods_on_intrinsics", since = "1.32.0")]
#[inline]
Expand Down Expand Up @@ -1237,6 +1246,7 @@ impl char {
/// assert!(!lf.is_ascii_alphabetic());
/// assert!(!esc.is_ascii_alphabetic());
/// ```
#[must_use]
#[stable(feature = "ascii_ctype_on_intrinsics", since = "1.24.0")]
#[rustc_const_stable(feature = "const_ascii_ctype_on_intrinsics", since = "1.47.0")]
#[inline]
Expand Down Expand Up @@ -1270,6 +1280,7 @@ impl char {
/// assert!(!lf.is_ascii_uppercase());
/// assert!(!esc.is_ascii_uppercase());
/// ```
#[must_use]
#[stable(feature = "ascii_ctype_on_intrinsics", since = "1.24.0")]
#[rustc_const_stable(feature = "const_ascii_ctype_on_intrinsics", since = "1.47.0")]
#[inline]
Expand Down Expand Up @@ -1303,6 +1314,7 @@ impl char {
/// assert!(!lf.is_ascii_lowercase());
/// assert!(!esc.is_ascii_lowercase());
/// ```
#[must_use]
#[stable(feature = "ascii_ctype_on_intrinsics", since = "1.24.0")]
#[rustc_const_stable(feature = "const_ascii_ctype_on_intrinsics", since = "1.47.0")]
#[inline]
Expand Down Expand Up @@ -1339,6 +1351,7 @@ impl char {
/// assert!(!lf.is_ascii_alphanumeric());
/// assert!(!esc.is_ascii_alphanumeric());
/// ```
#[must_use]
#[stable(feature = "ascii_ctype_on_intrinsics", since = "1.24.0")]
#[rustc_const_stable(feature = "const_ascii_ctype_on_intrinsics", since = "1.47.0")]
#[inline]
Expand Down Expand Up @@ -1372,6 +1385,7 @@ impl char {
/// assert!(!lf.is_ascii_digit());
/// assert!(!esc.is_ascii_digit());
/// ```
#[must_use]
#[stable(feature = "ascii_ctype_on_intrinsics", since = "1.24.0")]
#[rustc_const_stable(feature = "const_ascii_ctype_on_intrinsics", since = "1.47.0")]
#[inline]
Expand Down Expand Up @@ -1408,6 +1422,7 @@ impl char {
/// assert!(!lf.is_ascii_hexdigit());
/// assert!(!esc.is_ascii_hexdigit());
/// ```
#[must_use]
#[stable(feature = "ascii_ctype_on_intrinsics", since = "1.24.0")]
#[rustc_const_stable(feature = "const_ascii_ctype_on_intrinsics", since = "1.47.0")]
#[inline]
Expand Down Expand Up @@ -1445,6 +1460,7 @@ impl char {
/// assert!(!lf.is_ascii_punctuation());
/// assert!(!esc.is_ascii_punctuation());
/// ```
#[must_use]
#[stable(feature = "ascii_ctype_on_intrinsics", since = "1.24.0")]
#[rustc_const_stable(feature = "const_ascii_ctype_on_intrinsics", since = "1.47.0")]
#[inline]
Expand Down Expand Up @@ -1478,6 +1494,7 @@ impl char {
/// assert!(!lf.is_ascii_graphic());
/// assert!(!esc.is_ascii_graphic());
/// ```
#[must_use]
#[stable(feature = "ascii_ctype_on_intrinsics", since = "1.24.0")]
#[rustc_const_stable(feature = "const_ascii_ctype_on_intrinsics", since = "1.47.0")]
#[inline]
Expand Down Expand Up @@ -1528,6 +1545,7 @@ impl char {
/// assert!(lf.is_ascii_whitespace());
/// assert!(!esc.is_ascii_whitespace());
/// ```
#[must_use]
#[stable(feature = "ascii_ctype_on_intrinsics", since = "1.24.0")]
#[rustc_const_stable(feature = "const_ascii_ctype_on_intrinsics", since = "1.47.0")]
#[inline]
Expand Down Expand Up @@ -1563,6 +1581,7 @@ impl char {
/// assert!(lf.is_ascii_control());
/// assert!(esc.is_ascii_control());
/// ```
#[must_use]
#[stable(feature = "ascii_ctype_on_intrinsics", since = "1.24.0")]
#[rustc_const_stable(feature = "const_ascii_ctype_on_intrinsics", since = "1.47.0")]
#[inline]
Expand Down
7 changes: 7 additions & 0 deletions library/core/src/num/f32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,7 @@ impl f32 {
/// assert!(nan.is_nan());
/// assert!(!f.is_nan());
/// ```
#[must_use]
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_float_classify", issue = "72505")]
#[inline]
Expand Down Expand Up @@ -467,6 +468,7 @@ impl f32 {
/// assert!(inf.is_infinite());
/// assert!(neg_inf.is_infinite());
/// ```
#[must_use]
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_float_classify", issue = "72505")]
#[inline]
Expand All @@ -488,6 +490,7 @@ impl f32 {
/// assert!(!inf.is_finite());
/// assert!(!neg_inf.is_finite());
/// ```
#[must_use]
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_float_classify", issue = "72505")]
#[inline]
Expand Down Expand Up @@ -515,6 +518,7 @@ impl f32 {
/// assert!(lower_than_min.is_subnormal());
/// ```
/// [subnormal]: https://en.wikipedia.org/wiki/Denormal_number
#[must_use]
#[stable(feature = "is_subnormal", since = "1.53.0")]
#[rustc_const_unstable(feature = "const_float_classify", issue = "72505")]
#[inline]
Expand All @@ -541,6 +545,7 @@ impl f32 {
/// assert!(!lower_than_min.is_normal());
/// ```
/// [subnormal]: https://en.wikipedia.org/wiki/Denormal_number
#[must_use]
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_float_classify", issue = "72505")]
#[inline]
Expand Down Expand Up @@ -587,6 +592,7 @@ impl f32 {
/// assert!(f.is_sign_positive());
/// assert!(!g.is_sign_positive());
/// ```
#[must_use]
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_float_classify", issue = "72505")]
#[inline]
Expand All @@ -604,6 +610,7 @@ impl f32 {
/// assert!(!f.is_sign_negative());
/// assert!(g.is_sign_negative());
/// ```
#[must_use]
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_float_classify", issue = "72505")]
#[inline]
Expand Down
9 changes: 9 additions & 0 deletions library/core/src/num/f64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,7 @@ impl f64 {
/// assert!(nan.is_nan());
/// assert!(!f.is_nan());
/// ```
#[must_use]
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_float_classify", issue = "72505")]
#[inline]
Expand Down Expand Up @@ -466,6 +467,7 @@ impl f64 {
/// assert!(inf.is_infinite());
/// assert!(neg_inf.is_infinite());
/// ```
#[must_use]
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_float_classify", issue = "72505")]
#[inline]
Expand All @@ -487,6 +489,7 @@ impl f64 {
/// assert!(!inf.is_finite());
/// assert!(!neg_inf.is_finite());
/// ```
#[must_use]
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_float_classify", issue = "72505")]
#[inline]
Expand Down Expand Up @@ -514,6 +517,7 @@ impl f64 {
/// assert!(lower_than_min.is_subnormal());
/// ```
/// [subnormal]: https://en.wikipedia.org/wiki/Denormal_number
#[must_use]
#[stable(feature = "is_subnormal", since = "1.53.0")]
#[rustc_const_unstable(feature = "const_float_classify", issue = "72505")]
#[inline]
Expand All @@ -540,6 +544,7 @@ impl f64 {
/// assert!(!lower_than_min.is_normal());
/// ```
/// [subnormal]: https://en.wikipedia.org/wiki/Denormal_number
#[must_use]
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_float_classify", issue = "72505")]
#[inline]
Expand Down Expand Up @@ -586,13 +591,15 @@ impl f64 {
/// assert!(f.is_sign_positive());
/// assert!(!g.is_sign_positive());
/// ```
#[must_use]
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_float_classify", issue = "72505")]
#[inline]
pub const fn is_sign_positive(self) -> bool {
!self.is_sign_negative()
}

#[must_use]
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_deprecated(since = "1.0.0", reason = "renamed to is_sign_positive")]
#[inline]
Expand All @@ -611,13 +618,15 @@ impl f64 {
/// assert!(!f.is_sign_negative());
/// assert!(g.is_sign_negative());
/// ```
#[must_use]
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_float_classify", issue = "72505")]
#[inline]
pub const fn is_sign_negative(self) -> bool {
self.to_bits() & 0x8000_0000_0000_0000 != 0
}

#[must_use]
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_deprecated(since = "1.0.0", reason = "renamed to is_sign_negative")]
#[inline]
Expand Down
2 changes: 2 additions & 0 deletions library/core/src/num/int_macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2502,6 +2502,7 @@ macro_rules! int_impl {
#[doc = concat!("assert!(10", stringify!($SelfT), ".is_positive());")]
#[doc = concat!("assert!(!(-10", stringify!($SelfT), ").is_positive());")]
/// ```
#[must_use]
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_stable(feature = "const_int_methods", since = "1.32.0")]
#[inline(always)]
Expand All @@ -2518,6 +2519,7 @@ macro_rules! int_impl {
#[doc = concat!("assert!((-10", stringify!($SelfT), ").is_negative());")]
#[doc = concat!("assert!(!10", stringify!($SelfT), ".is_negative());")]
/// ```
#[must_use]
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_stable(feature = "const_int_methods", since = "1.32.0")]
#[inline(always)]
Expand Down
Loading