Skip to content

Commit

Permalink
Add "soft deprecation" notice to old MIN/MAX docs
Browse files Browse the repository at this point in the history
  • Loading branch information
faern committed Feb 12, 2020
1 parent 3529834 commit 97bdd31
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 12 deletions.
19 changes: 13 additions & 6 deletions src/libcore/num/int_macros.rs
Expand Up @@ -3,11 +3,18 @@
macro_rules! int_module {
($T:ident) => (int_module!($T, #[stable(feature = "rust1", since = "1.0.0")]););
($T:ident, #[$attr:meta]) => (
/// The smallest value that can be represented by this integer type.
#[$attr]
pub const MIN: $T = $T::min_value();
/// The largest value that can be represented by this integer type.
#[$attr]
pub const MAX: $T = $T::max_value();
doc_comment! {
concat!("The smallest value that can be represented by this integer type.
Use [`", stringify!($T), "::MIN", "`](../../std/primitive.", stringify!($T), ".html#associatedconstant.MIN) instead."),
#[$attr]
pub const MIN: $T = $T::min_value();
}

doc_comment! {
concat!("The largest value that can be represented by this integer type.
Use [`", stringify!($T), "::MAX", "`](../../std/primitive.", stringify!($T), ".html#associatedconstant.MAX) instead."),
#[$attr]
pub const MAX: $T = $T::max_value();
}
)
}
34 changes: 28 additions & 6 deletions src/libcore/num/uint_macros.rs
@@ -1,13 +1,35 @@
#![doc(hidden)]

macro_rules! doc_comment {
($x:expr, $($tt:tt)*) => {
#[doc = $x]
$($tt)*
};
}

macro_rules! uint_module {
($T:ident) => (uint_module!($T, #[stable(feature = "rust1", since = "1.0.0")]););
($T:ident, #[$attr:meta]) => (
/// The smallest value that can be represented by this integer type.
#[$attr]
pub const MIN: $T = $T::min_value();
/// The largest value that can be represented by this integer type.
#[$attr]
pub const MAX: $T = $T::max_value();
doc_comment! {
concat!("**This method is soft-deprecated.**
Although using it won’t cause compilation warning,
new code should use [`", stringify!($T), "::MIN", "`] instead.
The smallest value that can be represented by this integer type."),
#[$attr]
pub const MIN: $T = $T::min_value();
}

doc_comment! {
concat!("**This method is soft-deprecated.**
Although using it won’t cause compilation warning,
new code should use [`", stringify!($T), "::MAX", "`] instead.
The largest value that can be represented by this integer type."),
#[$attr]
pub const MAX: $T = $T::max_value();
}
)
}

0 comments on commit 97bdd31

Please sign in to comment.