Skip to content

Commit

Permalink
Unbreak tidy's feature parser
Browse files Browse the repository at this point in the history
    tidy error: /git/rust/library/core/src/num/nonzero.rs:67: malformed stability attribute: missing `feature` key
    tidy error: /git/rust/library/core/src/num/nonzero.rs:82: malformed stability attribute: missing `feature` key
    tidy error: /git/rust/library/core/src/num/nonzero.rs:98: malformed stability attribute: missing the `since` key
    tidy error: /git/rust/library/core/src/num/nonzero.rs:112: malformed stability attribute: missing `feature` key
    tidy error: /git/rust/library/core/src/num/nonzero.rs:450: malformed stability attribute: missing `feature` key
    some tidy checks failed
  • Loading branch information
dtolnay committed Dec 8, 2023
1 parent 0f66ffc commit 4a13b47
Showing 1 changed file with 29 additions and 39 deletions.
68 changes: 29 additions & 39 deletions library/core/src/num/nonzero.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ macro_rules! impl_nonzero_fmt {

macro_rules! nonzero_integer {
(
#[$stability:meta]
#[$const_new_unchecked_stability:meta]
Self = $Ty:ident,
Primitive = $signedness:ident $Int:ident,
$(UnsignedNonZero = $UnsignedNonZero:ident,)?
UnsignedPrimitive = $UnsignedPrimitive:ty,
feature = $feature:literal,
original_stabilization = $since:literal,

// Used in doc comments.
leading_zeros_test = $leading_zeros_test:expr,
Expand Down Expand Up @@ -64,7 +64,7 @@ macro_rules! nonzero_integer {
/// ```
///
/// [null pointer optimization]: crate::option#representation
#[stable(feature = $feature, since = $since)]
#[$stability]
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
#[repr(transparent)]
#[rustc_layout_scalar_valid_range_start(1)]
Expand All @@ -79,8 +79,8 @@ macro_rules! nonzero_integer {
/// # Safety
///
/// The value must not be zero.
#[stable(feature = $feature, since = $since)]
#[rustc_const_stable(feature = $feature, since = $since)]
#[$stability]
#[$const_new_unchecked_stability]
#[must_use]
#[inline]
pub const unsafe fn new_unchecked(n: $Int) -> Self {
Expand All @@ -95,7 +95,7 @@ macro_rules! nonzero_integer {
}

/// Creates a non-zero if the given value is not zero.
#[stable(feature = $feature, since = $since)]
#[$stability]
#[rustc_const_stable(feature = "const_nonzero_int_methods", since = "1.47.0")]
#[must_use]
#[inline]
Expand All @@ -109,7 +109,7 @@ macro_rules! nonzero_integer {
}

/// Returns the value as a primitive type.
#[stable(feature = $feature, since = $since)]
#[$stability]
#[inline]
#[rustc_const_stable(feature = "const_nonzero_get", since = "1.34.0")]
pub const fn get(self) -> $Int {
Expand Down Expand Up @@ -447,8 +447,7 @@ macro_rules! nonzero_integer {
}

impl_nonzero_fmt! {
#[stable(feature = $feature, since = $since)]
(Debug, Display, Binary, Octal, LowerHex, UpperHex) for $Ty
#[$stability] (Debug, Display, Binary, Octal, LowerHex, UpperHex) for $Ty
}

#[stable(feature = "nonzero_parse", since = "1.35.0")]
Expand All @@ -464,6 +463,27 @@ macro_rules! nonzero_integer {

nonzero_integer_signedness_dependent_impls!($Ty $signedness $Int);
};

(Self = $Ty:ident, Primitive = unsigned $Int:ident, $($rest:tt)*) => {
nonzero_integer! {
#[stable(feature = "nonzero", since = "1.28.0")]
#[rustc_const_stable(feature = "nonzero", since = "1.28.0")]
Self = $Ty,
Primitive = unsigned $Int,
UnsignedPrimitive = $Int,
$($rest)*
}
};

(Self = $Ty:ident, Primitive = signed $Int:ident, $($rest:tt)*) => {
nonzero_integer! {
#[stable(feature = "signed_nonzero", since = "1.34.0")]
#[rustc_const_stable(feature = "signed_nonzero", since = "1.34.0")]
Self = $Ty,
Primitive = signed $Int,
$($rest)*
}
};
}

macro_rules! nonzero_integer_signedness_dependent_impls {
Expand Down Expand Up @@ -1239,54 +1259,36 @@ macro_rules! sign_dependent_expr {
nonzero_integer! {
Self = NonZeroU8,
Primitive = unsigned u8,
UnsignedPrimitive = u8,
feature = "nonzero",
original_stabilization = "1.28.0",
leading_zeros_test = u8::MAX,
}

nonzero_integer! {
Self = NonZeroU16,
Primitive = unsigned u16,
UnsignedPrimitive = u16,
feature = "nonzero",
original_stabilization = "1.28.0",
leading_zeros_test = u16::MAX,
}

nonzero_integer! {
Self = NonZeroU32,
Primitive = unsigned u32,
UnsignedPrimitive = u32,
feature = "nonzero",
original_stabilization = "1.28.0",
leading_zeros_test = u32::MAX,
}

nonzero_integer! {
Self = NonZeroU64,
Primitive = unsigned u64,
UnsignedPrimitive = u64,
feature = "nonzero",
original_stabilization = "1.28.0",
leading_zeros_test = u64::MAX,
}

nonzero_integer! {
Self = NonZeroU128,
Primitive = unsigned u128,
UnsignedPrimitive = u128,
feature = "nonzero",
original_stabilization = "1.28.0",
leading_zeros_test = u128::MAX,
}

nonzero_integer! {
Self = NonZeroUsize,
Primitive = unsigned usize,
UnsignedPrimitive = usize,
feature = "nonzero",
original_stabilization = "1.28.0",
leading_zeros_test = usize::MAX,
}

Expand All @@ -1295,8 +1297,6 @@ nonzero_integer! {
Primitive = signed i8,
UnsignedNonZero = NonZeroU8,
UnsignedPrimitive = u8,
feature = "signed_nonzero",
original_stabilization = "1.34.0",
leading_zeros_test = -1i8,
}

Expand All @@ -1305,8 +1305,6 @@ nonzero_integer! {
Primitive = signed i16,
UnsignedNonZero = NonZeroU16,
UnsignedPrimitive = u16,
feature = "signed_nonzero",
original_stabilization = "1.34.0",
leading_zeros_test = -1i16,
}

Expand All @@ -1315,8 +1313,6 @@ nonzero_integer! {
Primitive = signed i32,
UnsignedNonZero = NonZeroU32,
UnsignedPrimitive = u32,
feature = "signed_nonzero",
original_stabilization = "1.34.0",
leading_zeros_test = -1i32,
}

Expand All @@ -1325,8 +1321,6 @@ nonzero_integer! {
Primitive = signed i64,
UnsignedNonZero = NonZeroU64,
UnsignedPrimitive = u64,
feature = "signed_nonzero",
original_stabilization = "1.34.0",
leading_zeros_test = -1i64,
}

Expand All @@ -1335,8 +1329,6 @@ nonzero_integer! {
Primitive = signed i128,
UnsignedNonZero = NonZeroU128,
UnsignedPrimitive = u128,
feature = "signed_nonzero",
original_stabilization = "1.34.0",
leading_zeros_test = -1i128,
}

Expand All @@ -1345,7 +1337,5 @@ nonzero_integer! {
Primitive = signed isize,
UnsignedNonZero = NonZeroUsize,
UnsignedPrimitive = usize,
feature = "signed_nonzero",
original_stabilization = "1.34.0",
leading_zeros_test = -1isize,
}

0 comments on commit 4a13b47

Please sign in to comment.