Skip to content

Rollup of 7 pull requests #89724

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

Closed
wants to merge 14 commits into from
Closed
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 compiler/rustc_feature/src/active.rs
Original file line number Diff line number Diff line change
@@ -678,6 +678,9 @@ declare_features! (
/// Allows `#[doc(cfg_hide(...))]`.
(active, doc_cfg_hide, "1.57.0", Some(43781), None),

/// Allows using the `non_exhaustive_omitted_patterns` lint.
(active, non_exhaustive_omitted_patterns_lint, "1.57.0", Some(89554), None),

// -------------------------------------------------------------------------
// feature-group-end: actual feature gates
// -------------------------------------------------------------------------
4 changes: 4 additions & 0 deletions compiler/rustc_lint_defs/src/builtin.rs
Original file line number Diff line number Diff line change
@@ -6,6 +6,7 @@
use crate::{declare_lint, declare_lint_pass, FutureIncompatibilityReason};
use rustc_span::edition::Edition;
use rustc_span::symbol::sym;

declare_lint! {
/// The `forbidden_lint_groups` lint detects violations of
@@ -3476,6 +3477,8 @@ declare_lint! {
/// }
///
/// // in crate B
/// #![feature(non_exhaustive_omitted_patterns_lint)]
///
/// match Bar::A {
/// Bar::A => {},
/// #[warn(non_exhaustive_omitted_patterns)]
@@ -3512,6 +3515,7 @@ declare_lint! {
pub NON_EXHAUSTIVE_OMITTED_PATTERNS,
Allow,
"detect when patterns of types marked `non_exhaustive` are missed",
@feature_gate = sym::non_exhaustive_omitted_patterns_lint;
}

declare_lint! {
1 change: 1 addition & 0 deletions compiler/rustc_span/src/symbol.rs
Original file line number Diff line number Diff line change
@@ -893,6 +893,7 @@ symbols! {
nomem,
non_ascii_idents,
non_exhaustive,
non_exhaustive_omitted_patterns_lint,
non_modrs_mods,
none_error,
nontemporal_store,
3 changes: 3 additions & 0 deletions library/alloc/src/collections/btree/set.rs
Original file line number Diff line number Diff line change
@@ -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
@@ -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
@@ -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
1 change: 1 addition & 0 deletions library/alloc/src/lib.rs
Original file line number Diff line number Diff line change
@@ -73,6 +73,7 @@
not(test),
not(any(test, bootstrap)),
any(not(feature = "miri-test-libstd"), test, doctest),
no_global_oom_handling,
target_has_atomic = "ptr"
))
)]
25 changes: 25 additions & 0 deletions library/core/src/char/methods.rs
Original file line number Diff line number Diff line change
@@ -377,6 +377,8 @@ impl char {
/// ```
/// assert_eq!('❤'.escape_unicode().to_string(), "\\u{2764}");
/// ```
#[must_use = "this returns the escaped char as an iterator, \
without modifying the original"]
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn escape_unicode(self) -> EscapeUnicode {
@@ -453,6 +455,8 @@ impl char {
/// ```
/// assert_eq!('\n'.escape_debug().to_string(), "\\n");
/// ```
#[must_use = "this returns the escaped char as an iterator, \
without modifying the original"]
#[stable(feature = "char_escape_debug", since = "1.20.0")]
#[inline]
pub fn escape_debug(self) -> EscapeDebug {
@@ -507,6 +511,8 @@ impl char {
/// ```
/// assert_eq!('"'.escape_default().to_string(), "\\\"");
/// ```
#[must_use = "this returns the escaped char as an iterator, \
without modifying the original"]
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn escape_default(self) -> EscapeDefault {
@@ -692,6 +698,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 {
@@ -724,6 +731,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 {
@@ -756,6 +764,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 {
@@ -784,6 +793,7 @@ impl char {
///
/// assert!(!'越'.is_whitespace());
/// ```
#[must_use]
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn is_whitespace(self) -> bool {
@@ -812,6 +822,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 {
@@ -837,6 +848,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 {
@@ -852,6 +864,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)
@@ -881,6 +894,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 {
@@ -1060,6 +1074,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]
@@ -1237,6 +1252,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]
@@ -1270,6 +1286,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]
@@ -1303,6 +1320,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]
@@ -1339,6 +1357,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]
@@ -1372,6 +1391,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]
@@ -1408,6 +1428,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]
@@ -1445,6 +1466,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]
@@ -1478,6 +1500,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]
@@ -1528,6 +1551,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]
@@ -1563,6 +1587,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]
1 change: 1 addition & 0 deletions library/core/src/lib.rs
Original file line number Diff line number Diff line change
@@ -65,6 +65,7 @@
doc(cfg_hide(
not(test),
any(not(feature = "miri-test-libstd"), test, doctest),
no_fp_fmt_parse,
target_pointer_width = "16",
target_pointer_width = "32",
target_pointer_width = "64",
7 changes: 7 additions & 0 deletions library/core/src/num/f32.rs
Original file line number Diff line number Diff line change
@@ -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]
@@ -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]
@@ -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]
@@ -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]
@@ -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]
@@ -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]
@@ -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]
9 changes: 9 additions & 0 deletions library/core/src/num/f64.rs
Original file line number Diff line number Diff line change
@@ -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]
@@ -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]
@@ -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]
@@ -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]
@@ -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]
@@ -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]
@@ -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]
26 changes: 14 additions & 12 deletions library/core/src/num/int_macros.rs
Original file line number Diff line number Diff line change
@@ -2199,7 +2199,8 @@ macro_rules! int_impl {
}
}

/// Returns the logarithm of the number with respect to an arbitrary base.
/// Returns the logarithm of the number with respect to an arbitrary base,
/// rounded down.
///
/// This method might not be optimized owing to implementation details;
/// `log2` can produce results more efficiently for base 2, and `log10`
@@ -2208,8 +2209,8 @@ macro_rules! int_impl {
/// # Panics
///
/// When the number is zero, or if the base is not at least 2; it
/// panics in debug mode and the return value is wrapped to 0 in release
/// mode (the only situation in which the method can return 0).
/// panics in debug mode and the return value is 0 in release
/// mode.
///
/// # Examples
///
@@ -2237,13 +2238,12 @@ macro_rules! int_impl {
}
}

/// Returns the base 2 logarithm of the number.
/// Returns the base 2 logarithm of the number, rounded down.
///
/// # Panics
///
/// When the number is zero it panics in debug mode and the return value
/// is wrapped to 0 in release mode (the only situation in which the
/// method can return 0).
/// is 0 in release mode.
///
/// # Examples
///
@@ -2271,13 +2271,12 @@ macro_rules! int_impl {
}
}

/// Returns the base 10 logarithm of the number.
/// Returns the base 10 logarithm of the number, rounded down.
///
/// # Panics
///
/// When the number is zero it panics in debug mode and the return value
/// is wrapped to 0 in release mode (the only situation in which the
/// method can return 0).
/// is 0 in release mode.
///
/// # Example
///
@@ -2305,7 +2304,8 @@ macro_rules! int_impl {
}
}

/// Returns the logarithm of the number with respect to an arbitrary base.
/// Returns the logarithm of the number with respect to an arbitrary base,
/// rounded down.
///
/// Returns `None` if the number is negative or zero, or if the base is not at least 2.
///
@@ -2345,7 +2345,7 @@ macro_rules! int_impl {
}
}

/// Returns the base 2 logarithm of the number.
/// Returns the base 2 logarithm of the number, rounded down.
///
/// Returns `None` if the number is negative or zero.
///
@@ -2369,7 +2369,7 @@ macro_rules! int_impl {
}
}

/// Returns the base 10 logarithm of the number.
/// Returns the base 10 logarithm of the number, rounded down.
///
/// Returns `None` if the number is negative or zero.
///
@@ -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)]
@@ -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)]
11 changes: 11 additions & 0 deletions library/core/src/num/mod.rs
Original file line number Diff line number Diff line change
@@ -259,6 +259,7 @@ impl u8 {
/// 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.43.0")]
#[inline]
@@ -419,6 +420,7 @@ impl u8 {
/// 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]
@@ -452,6 +454,7 @@ impl u8 {
/// 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]
@@ -485,6 +488,7 @@ impl u8 {
/// 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]
@@ -521,6 +525,7 @@ impl u8 {
/// 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]
@@ -554,6 +559,7 @@ impl u8 {
/// 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]
@@ -590,6 +596,7 @@ impl u8 {
/// 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]
@@ -627,6 +634,7 @@ impl u8 {
/// 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]
@@ -660,6 +668,7 @@ impl u8 {
/// 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]
@@ -710,6 +719,7 @@ impl u8 {
/// 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]
@@ -745,6 +755,7 @@ impl u8 {
/// 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]
1 change: 1 addition & 0 deletions library/core/src/num/nonzero.rs
Original file line number Diff line number Diff line change
@@ -878,6 +878,7 @@ macro_rules! nonzero_unsigned_is_power_of_two {
#[doc = concat!("let ten = std::num::", stringify!($Ty), "::new(10).unwrap();")]
/// assert!(!ten.is_power_of_two());
/// ```
#[must_use]
#[unstable(feature = "nonzero_is_power_of_two", issue = "81106")]
#[inline]
pub const fn is_power_of_two(self) -> bool {
3 changes: 3 additions & 0 deletions library/core/src/num/saturating.rs
Original file line number Diff line number Diff line change
@@ -847,6 +847,7 @@ macro_rules! saturating_int_impl_signed {
#[doc = concat!("assert!(Saturating(10", stringify!($t), ").is_positive());")]
#[doc = concat!("assert!(!Saturating(-10", stringify!($t), ").is_positive());")]
/// ```
#[must_use]
#[inline]
#[unstable(feature = "saturating_int_impl", issue = "87920")]
pub const fn is_positive(self) -> bool {
@@ -867,6 +868,7 @@ macro_rules! saturating_int_impl_signed {
#[doc = concat!("assert!(Saturating(-10", stringify!($t), ").is_negative());")]
#[doc = concat!("assert!(!Saturating(10", stringify!($t), ").is_negative());")]
/// ```
#[must_use]
#[inline]
#[unstable(feature = "saturating_int_impl", issue = "87920")]
pub const fn is_negative(self) -> bool {
@@ -925,6 +927,7 @@ macro_rules! saturating_int_impl_unsigned {
#[doc = concat!("assert!(Saturating(16", stringify!($t), ").is_power_of_two());")]
#[doc = concat!("assert!(!Saturating(10", stringify!($t), ").is_power_of_two());")]
/// ```
#[must_use]
#[inline]
#[unstable(feature = "saturating_int_impl", issue = "87920")]
pub fn is_power_of_two(self) -> bool {
26 changes: 13 additions & 13 deletions library/core/src/num/uint_macros.rs
Original file line number Diff line number Diff line change
@@ -658,7 +658,8 @@ macro_rules! uint_impl {
}
}

/// Returns the logarithm of the number with respect to an arbitrary base.
/// Returns the logarithm of the number with respect to an arbitrary base,
/// rounded down.
///
/// This method might not be optimized owing to implementation details;
/// `log2` can produce results more efficiently for base 2, and `log10`
@@ -667,8 +668,7 @@ macro_rules! uint_impl {
/// # Panics
///
/// When the number is negative, zero, or if the base is not at least 2;
/// it panics in debug mode and the return value is wrapped to 0 in
/// release mode (the only situation in which the method can return 0).
/// it panics in debug mode and the return value is 0 in release mode.
///
/// # Examples
///
@@ -696,13 +696,12 @@ macro_rules! uint_impl {
}
}

/// Returns the base 2 logarithm of the number.
/// Returns the base 2 logarithm of the number, rounded down.
///
/// # Panics
///
/// When the number is negative or zero it panics in debug mode and
/// the return value is wrapped to 0 in release mode (the only situation in
/// which the method can return 0).
/// the return value is 0 in release mode.
///
/// # Examples
///
@@ -730,13 +729,12 @@ macro_rules! uint_impl {
}
}

/// Returns the base 10 logarithm of the number.
/// Returns the base 10 logarithm of the number, rounded down.
///
/// # Panics
///
/// When the number is negative or zero it panics in debug mode and the
/// return value is wrapped to 0 in release mode (the only situation in
/// which the method can return 0).
/// return value is 0 in release mode.
///
/// # Example
///
@@ -764,7 +762,8 @@ macro_rules! uint_impl {
}
}

/// Returns the logarithm of the number with respect to an arbitrary base.
/// Returns the logarithm of the number with respect to an arbitrary base,
/// rounded down.
///
/// Returns `None` if the number is zero, or if the base is not at least 2.
///
@@ -804,7 +803,7 @@ macro_rules! uint_impl {
}
}

/// Returns the base 2 logarithm of the number.
/// Returns the base 2 logarithm of the number, rounded down.
///
/// Returns `None` if the number is zero.
///
@@ -828,7 +827,7 @@ macro_rules! uint_impl {
}
}

/// Returns the base 10 logarithm of the number.
/// Returns the base 10 logarithm of the number, rounded down.
///
/// Returns `None` if the number is zero.
///
@@ -2087,6 +2086,7 @@ macro_rules! uint_impl {
#[doc = concat!("assert!(16", stringify!($SelfT), ".is_power_of_two());")]
#[doc = concat!("assert!(!10", stringify!($SelfT), ".is_power_of_two());")]
/// ```
#[must_use]
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_stable(feature = "const_is_power_of_two", since = "1.32.0")]
#[inline(always)]
@@ -2120,7 +2120,7 @@ macro_rules! uint_impl {
/// Returns the smallest power of two greater than or equal to `self`.
///
/// When return value overflows (i.e., `self > (1 << (N-1))` for type
/// `uN`), it panics in debug mode and return value is wrapped to 0 in
/// `uN`), it panics in debug mode and the return value is wrapped to 0 in
/// release mode (the only situation in which method can return 0).
///
/// # Examples
3 changes: 3 additions & 0 deletions library/core/src/num/wrapping.rs
Original file line number Diff line number Diff line change
@@ -844,6 +844,7 @@ macro_rules! wrapping_int_impl_signed {
#[doc = concat!("assert!(Wrapping(10", stringify!($t), ").is_positive());")]
#[doc = concat!("assert!(!Wrapping(-10", stringify!($t), ").is_positive());")]
/// ```
#[must_use]
#[inline]
#[unstable(feature = "wrapping_int_impl", issue = "32463")]
pub const fn is_positive(self) -> bool {
@@ -864,6 +865,7 @@ macro_rules! wrapping_int_impl_signed {
#[doc = concat!("assert!(Wrapping(-10", stringify!($t), ").is_negative());")]
#[doc = concat!("assert!(!Wrapping(10", stringify!($t), ").is_negative());")]
/// ```
#[must_use]
#[inline]
#[unstable(feature = "wrapping_int_impl", issue = "32463")]
pub const fn is_negative(self) -> bool {
@@ -911,6 +913,7 @@ macro_rules! wrapping_int_impl_unsigned {
#[doc = concat!("assert!(Wrapping(16", stringify!($t), ").is_power_of_two());")]
#[doc = concat!("assert!(!Wrapping(10", stringify!($t), ").is_power_of_two());")]
/// ```
#[must_use]
#[inline]
#[unstable(feature = "wrapping_int_impl", issue = "32463")]
pub fn is_power_of_two(self) -> bool {
1 change: 1 addition & 0 deletions library/core/src/str/mod.rs
Original file line number Diff line number Diff line change
@@ -188,6 +188,7 @@ impl str {
/// // third byte of `老`
/// assert!(!s.is_char_boundary(8));
/// ```
#[must_use]
#[stable(feature = "is_char_boundary", since = "1.9.0")]
#[inline]
pub fn is_char_boundary(&self, index: usize) -> bool {
1 change: 1 addition & 0 deletions library/core/src/time.rs
Original file line number Diff line number Diff line change
@@ -291,6 +291,7 @@ impl Duration {
/// assert!(!Duration::from_nanos(1).is_zero());
/// assert!(!Duration::from_secs(1).is_zero());
/// ```
#[must_use]
#[stable(feature = "duration_zero", since = "1.53.0")]
#[rustc_const_stable(feature = "duration_zero", since = "1.53.0")]
#[inline]
2 changes: 1 addition & 1 deletion src/bootstrap/test.rs
Original file line number Diff line number Diff line change
@@ -898,7 +898,7 @@ impl Step for RustdocGUI {
let out_dir = builder.test_out(self.target).join("rustdoc-gui");

// We remove existing folder to be sure there won't be artifacts remaining.
let _ = fs::remove_dir_all(&out_dir);
builder.clear_if_dirty(&out_dir, &builder.rustdoc(self.compiler));

let src_path = builder.build.src.join("src/test/rustdoc-gui/src");
// We generate docs for the libraries present in the rustdoc-gui's src folder.
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#![deny(non_exhaustive_omitted_patterns)]
//~^ ERROR the `non_exhaustive_omitted_patterns` lint is unstable
//~| ERROR the `non_exhaustive_omitted_patterns` lint is unstable
#![allow(non_exhaustive_omitted_patterns)]
//~^ ERROR the `non_exhaustive_omitted_patterns` lint is unstable
//~| ERROR the `non_exhaustive_omitted_patterns` lint is unstable

fn main() {
enum Foo {
A, B, C,
}

#[allow(non_exhaustive_omitted_patterns)]
match Foo::A {
Foo::A => {}
Foo::B => {}
}
//~^^^^^ ERROR the `non_exhaustive_omitted_patterns` lint is unstable
//~| ERROR the `non_exhaustive_omitted_patterns` lint is unstable
//~| ERROR the `non_exhaustive_omitted_patterns` lint is unstable
//~| ERROR the `non_exhaustive_omitted_patterns` lint is unstable

match Foo::A {
Foo::A => {}
Foo::B => {}
#[warn(non_exhaustive_omitted_patterns)]
_ => {}
}
//~^^^ ERROR the `non_exhaustive_omitted_patterns` lint is unstable
//~| ERROR the `non_exhaustive_omitted_patterns` lint is unstable
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
error[E0658]: the `non_exhaustive_omitted_patterns` lint is unstable
--> $DIR/feature-gate-non_exhaustive_omitted_patterns_lint.rs:1:1
|
LL | #![deny(non_exhaustive_omitted_patterns)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #89554 <https://github.com/rust-lang/rust/issues/89554> for more information
= help: add `#![feature(non_exhaustive_omitted_patterns_lint)]` to the crate attributes to enable

error[E0658]: the `non_exhaustive_omitted_patterns` lint is unstable
--> $DIR/feature-gate-non_exhaustive_omitted_patterns_lint.rs:4:1
|
LL | #![allow(non_exhaustive_omitted_patterns)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #89554 <https://github.com/rust-lang/rust/issues/89554> for more information
= help: add `#![feature(non_exhaustive_omitted_patterns_lint)]` to the crate attributes to enable

error[E0658]: the `non_exhaustive_omitted_patterns` lint is unstable
--> $DIR/feature-gate-non_exhaustive_omitted_patterns_lint.rs:13:5
|
LL | #[allow(non_exhaustive_omitted_patterns)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #89554 <https://github.com/rust-lang/rust/issues/89554> for more information
= help: add `#![feature(non_exhaustive_omitted_patterns_lint)]` to the crate attributes to enable

error[E0658]: the `non_exhaustive_omitted_patterns` lint is unstable
--> $DIR/feature-gate-non_exhaustive_omitted_patterns_lint.rs:13:5
|
LL | #[allow(non_exhaustive_omitted_patterns)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #89554 <https://github.com/rust-lang/rust/issues/89554> for more information
= help: add `#![feature(non_exhaustive_omitted_patterns_lint)]` to the crate attributes to enable

error[E0658]: the `non_exhaustive_omitted_patterns` lint is unstable
--> $DIR/feature-gate-non_exhaustive_omitted_patterns_lint.rs:26:9
|
LL | #[warn(non_exhaustive_omitted_patterns)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #89554 <https://github.com/rust-lang/rust/issues/89554> for more information
= help: add `#![feature(non_exhaustive_omitted_patterns_lint)]` to the crate attributes to enable

error[E0658]: the `non_exhaustive_omitted_patterns` lint is unstable
--> $DIR/feature-gate-non_exhaustive_omitted_patterns_lint.rs:1:1
|
LL | #![deny(non_exhaustive_omitted_patterns)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #89554 <https://github.com/rust-lang/rust/issues/89554> for more information
= help: add `#![feature(non_exhaustive_omitted_patterns_lint)]` to the crate attributes to enable

error[E0658]: the `non_exhaustive_omitted_patterns` lint is unstable
--> $DIR/feature-gate-non_exhaustive_omitted_patterns_lint.rs:4:1
|
LL | #![allow(non_exhaustive_omitted_patterns)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #89554 <https://github.com/rust-lang/rust/issues/89554> for more information
= help: add `#![feature(non_exhaustive_omitted_patterns_lint)]` to the crate attributes to enable

error[E0658]: the `non_exhaustive_omitted_patterns` lint is unstable
--> $DIR/feature-gate-non_exhaustive_omitted_patterns_lint.rs:13:5
|
LL | #[allow(non_exhaustive_omitted_patterns)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #89554 <https://github.com/rust-lang/rust/issues/89554> for more information
= help: add `#![feature(non_exhaustive_omitted_patterns_lint)]` to the crate attributes to enable

error[E0658]: the `non_exhaustive_omitted_patterns` lint is unstable
--> $DIR/feature-gate-non_exhaustive_omitted_patterns_lint.rs:13:5
|
LL | #[allow(non_exhaustive_omitted_patterns)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #89554 <https://github.com/rust-lang/rust/issues/89554> for more information
= help: add `#![feature(non_exhaustive_omitted_patterns_lint)]` to the crate attributes to enable

error[E0658]: the `non_exhaustive_omitted_patterns` lint is unstable
--> $DIR/feature-gate-non_exhaustive_omitted_patterns_lint.rs:26:9
|
LL | #[warn(non_exhaustive_omitted_patterns)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #89554 <https://github.com/rust-lang/rust/issues/89554> for more information
= help: add `#![feature(non_exhaustive_omitted_patterns_lint)]` to the crate attributes to enable

error: aborting due to 10 previous errors

For more information about this error, try `rustc --explain E0658`.
2 changes: 2 additions & 0 deletions src/test/ui/rfc-2008-non-exhaustive/reachable-patterns.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// Test that the `non_exhaustive_omitted_patterns` lint is triggered correctly.

#![feature(non_exhaustive_omitted_patterns_lint)]

// aux-build:enums.rs
extern crate enums;

40 changes: 20 additions & 20 deletions src/test/ui/rfc-2008-non-exhaustive/reachable-patterns.stderr
Original file line number Diff line number Diff line change
@@ -1,47 +1,47 @@
warning: some fields are not explicitly listed
--> $DIR/reachable-patterns.rs:127:9
--> $DIR/reachable-patterns.rs:129:9
|
LL | VariantNonExhaustive::Bar { x, .. } => {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ field `y` not listed
|
note: the lint level is defined here
--> $DIR/reachable-patterns.rs:124:12
--> $DIR/reachable-patterns.rs:126:12
|
LL | #[warn(non_exhaustive_omitted_patterns)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= help: ensure that all fields are mentioned explicitly by adding the suggested fields
= note: the pattern is of type `VariantNonExhaustive` and the `non_exhaustive_omitted_patterns` attribute was found

warning: some fields are not explicitly listed
--> $DIR/reachable-patterns.rs:132:9
--> $DIR/reachable-patterns.rs:134:9
|
LL | let FunctionalRecord { first_field, second_field, .. } = FunctionalRecord::default();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ field `third_field` not listed
|
note: the lint level is defined here
--> $DIR/reachable-patterns.rs:131:12
--> $DIR/reachable-patterns.rs:133:12
|
LL | #[warn(non_exhaustive_omitted_patterns)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= help: ensure that all fields are mentioned explicitly by adding the suggested fields
= note: the pattern is of type `FunctionalRecord` and the `non_exhaustive_omitted_patterns` attribute was found

warning: some fields are not explicitly listed
--> $DIR/reachable-patterns.rs:140:29
--> $DIR/reachable-patterns.rs:142:29
|
LL | let NestedStruct { bar: NormalStruct { first_field, .. }, .. } = NestedStruct::default();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ field `second_field` not listed
|
note: the lint level is defined here
--> $DIR/reachable-patterns.rs:139:12
--> $DIR/reachable-patterns.rs:141:12
|
LL | #[warn(non_exhaustive_omitted_patterns)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= help: ensure that all fields are mentioned explicitly by adding the suggested fields
= note: the pattern is of type `NormalStruct` and the `non_exhaustive_omitted_patterns` attribute was found

warning: some fields are not explicitly listed
--> $DIR/reachable-patterns.rs:140:9
--> $DIR/reachable-patterns.rs:142:9
|
LL | let NestedStruct { bar: NormalStruct { first_field, .. }, .. } = NestedStruct::default();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ field `foo` not listed
@@ -50,63 +50,63 @@ LL | let NestedStruct { bar: NormalStruct { first_field, .. }, .. } = Nested
= note: the pattern is of type `NestedStruct` and the `non_exhaustive_omitted_patterns` attribute was found

error: some variants are not matched explicitly
--> $DIR/reachable-patterns.rs:54:9
--> $DIR/reachable-patterns.rs:56:9
|
LL | _ => {}
| ^ pattern `Struct { .. }` not covered
|
note: the lint level is defined here
--> $DIR/reachable-patterns.rs:53:16
--> $DIR/reachable-patterns.rs:55:16
|
LL | #[deny(non_exhaustive_omitted_patterns)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= help: ensure that all variants are matched explicitly by adding the suggested match arms
= note: the matched value is of type `NonExhaustiveEnum` and the `non_exhaustive_omitted_patterns` attribute was found

error: some variants are not matched explicitly
--> $DIR/reachable-patterns.rs:61:9
--> $DIR/reachable-patterns.rs:63:9
|
LL | _ => {}
| ^ pattern `Tuple(_)` not covered
|
note: the lint level is defined here
--> $DIR/reachable-patterns.rs:60:16
--> $DIR/reachable-patterns.rs:62:16
|
LL | #[deny(non_exhaustive_omitted_patterns)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= help: ensure that all variants are matched explicitly by adding the suggested match arms
= note: the matched value is of type `NonExhaustiveEnum` and the `non_exhaustive_omitted_patterns` attribute was found

error: some variants are not matched explicitly
--> $DIR/reachable-patterns.rs:71:9
--> $DIR/reachable-patterns.rs:73:9
|
LL | _ => {}
| ^ pattern `Unit` not covered
|
note: the lint level is defined here
--> $DIR/reachable-patterns.rs:70:16
--> $DIR/reachable-patterns.rs:72:16
|
LL | #[deny(non_exhaustive_omitted_patterns)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= help: ensure that all variants are matched explicitly by adding the suggested match arms
= note: the matched value is of type `NonExhaustiveEnum` and the `non_exhaustive_omitted_patterns` attribute was found

error: some variants are not matched explicitly
--> $DIR/reachable-patterns.rs:88:32
--> $DIR/reachable-patterns.rs:90:32
|
LL | NestedNonExhaustive::A(_) => {}
| ^ patterns `Tuple(_)` and `Struct { .. }` not covered
|
note: the lint level is defined here
--> $DIR/reachable-patterns.rs:85:12
--> $DIR/reachable-patterns.rs:87:12
|
LL | #[deny(non_exhaustive_omitted_patterns)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= help: ensure that all variants are matched explicitly by adding the suggested match arms
= note: the matched value is of type `NonExhaustiveEnum` and the `non_exhaustive_omitted_patterns` attribute was found

error: some variants are not matched explicitly
--> $DIR/reachable-patterns.rs:90:9
--> $DIR/reachable-patterns.rs:92:9
|
LL | _ => {}
| ^ pattern `C` not covered
@@ -115,27 +115,27 @@ LL | _ => {}
= note: the matched value is of type `NestedNonExhaustive` and the `non_exhaustive_omitted_patterns` attribute was found

error: some variants are not matched explicitly
--> $DIR/reachable-patterns.rs:120:9
--> $DIR/reachable-patterns.rs:122:9
|
LL | _ => {}
| ^ patterns `HostUnreachable`, `NetworkUnreachable`, `NetworkDown` and 18 more not covered
|
note: the lint level is defined here
--> $DIR/reachable-patterns.rs:97:12
--> $DIR/reachable-patterns.rs:99:12
|
LL | #[deny(non_exhaustive_omitted_patterns)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= help: ensure that all variants are matched explicitly by adding the suggested match arms
= note: the matched value is of type `ErrorKind` and the `non_exhaustive_omitted_patterns` attribute was found

error: some variants are not matched explicitly
--> $DIR/reachable-patterns.rs:157:9
--> $DIR/reachable-patterns.rs:159:9
|
LL | _ => {}
| ^ pattern `A(_)` not covered
|
note: the lint level is defined here
--> $DIR/reachable-patterns.rs:155:12
--> $DIR/reachable-patterns.rs:157:12
|
LL | #[deny(non_exhaustive_omitted_patterns)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
15 changes: 15 additions & 0 deletions src/test/ui/wasm/simd-to-array-80108.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// only-wasm32
// build-pass
#![feature(repr_simd)]

// Regression test for #80108


#[repr(simd)]
pub struct Vector([i32; 4]);

impl Vector {
pub const fn to_array(self) -> [i32; 4] {
self.0
}
}