Skip to content

Commit 97bdd31

Browse files
committed
Add "soft deprecation" notice to old MIN/MAX docs
1 parent 3529834 commit 97bdd31

File tree

2 files changed

+41
-12
lines changed

2 files changed

+41
-12
lines changed

src/libcore/num/int_macros.rs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,18 @@
33
macro_rules! int_module {
44
($T:ident) => (int_module!($T, #[stable(feature = "rust1", since = "1.0.0")]););
55
($T:ident, #[$attr:meta]) => (
6-
/// The smallest value that can be represented by this integer type.
7-
#[$attr]
8-
pub const MIN: $T = $T::min_value();
9-
/// The largest value that can be represented by this integer type.
10-
#[$attr]
11-
pub const MAX: $T = $T::max_value();
6+
doc_comment! {
7+
concat!("The smallest value that can be represented by this integer type.
8+
Use [`", stringify!($T), "::MIN", "`](../../std/primitive.", stringify!($T), ".html#associatedconstant.MIN) instead."),
9+
#[$attr]
10+
pub const MIN: $T = $T::min_value();
11+
}
12+
13+
doc_comment! {
14+
concat!("The largest value that can be represented by this integer type.
15+
Use [`", stringify!($T), "::MAX", "`](../../std/primitive.", stringify!($T), ".html#associatedconstant.MAX) instead."),
16+
#[$attr]
17+
pub const MAX: $T = $T::max_value();
18+
}
1219
)
1320
}

src/libcore/num/uint_macros.rs

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,35 @@
11
#![doc(hidden)]
22

3+
macro_rules! doc_comment {
4+
($x:expr, $($tt:tt)*) => {
5+
#[doc = $x]
6+
$($tt)*
7+
};
8+
}
9+
310
macro_rules! uint_module {
411
($T:ident) => (uint_module!($T, #[stable(feature = "rust1", since = "1.0.0")]););
512
($T:ident, #[$attr:meta]) => (
6-
/// The smallest value that can be represented by this integer type.
7-
#[$attr]
8-
pub const MIN: $T = $T::min_value();
9-
/// The largest value that can be represented by this integer type.
10-
#[$attr]
11-
pub const MAX: $T = $T::max_value();
13+
doc_comment! {
14+
concat!("**This method is soft-deprecated.**
15+
16+
Although using it won’t cause compilation warning,
17+
new code should use [`", stringify!($T), "::MIN", "`] instead.
18+
19+
The smallest value that can be represented by this integer type."),
20+
#[$attr]
21+
pub const MIN: $T = $T::min_value();
22+
}
23+
24+
doc_comment! {
25+
concat!("**This method is soft-deprecated.**
26+
27+
Although using it won’t cause compilation warning,
28+
new code should use [`", stringify!($T), "::MAX", "`] instead.
29+
30+
The largest value that can be represented by this integer type."),
31+
#[$attr]
32+
pub const MAX: $T = $T::max_value();
33+
}
1234
)
1335
}

0 commit comments

Comments
 (0)