Skip to content

Commit a152b28

Browse files
committed
simplify the declaration of the legacy integer modules (std::u32 etc.)
1 parent a09fbe2 commit a152b28

File tree

14 files changed

+63
-208
lines changed

14 files changed

+63
-208
lines changed

library/core/src/lib.rs

Lines changed: 12 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -256,43 +256,18 @@ mod internal_macros;
256256
#[macro_use]
257257
mod int_macros;
258258

259-
#[rustc_diagnostic_item = "i128_legacy_mod"]
260-
#[path = "num/shells/i128.rs"]
261-
pub mod i128;
262-
#[rustc_diagnostic_item = "i16_legacy_mod"]
263-
#[path = "num/shells/i16.rs"]
264-
pub mod i16;
265-
#[rustc_diagnostic_item = "i32_legacy_mod"]
266-
#[path = "num/shells/i32.rs"]
267-
pub mod i32;
268-
#[rustc_diagnostic_item = "i64_legacy_mod"]
269-
#[path = "num/shells/i64.rs"]
270-
pub mod i64;
271-
#[rustc_diagnostic_item = "i8_legacy_mod"]
272-
#[path = "num/shells/i8.rs"]
273-
pub mod i8;
274-
#[rustc_diagnostic_item = "isize_legacy_mod"]
275-
#[path = "num/shells/isize.rs"]
276-
pub mod isize;
277-
278-
#[rustc_diagnostic_item = "u128_legacy_mod"]
279-
#[path = "num/shells/u128.rs"]
280-
pub mod u128;
281-
#[rustc_diagnostic_item = "u16_legacy_mod"]
282-
#[path = "num/shells/u16.rs"]
283-
pub mod u16;
284-
#[rustc_diagnostic_item = "u32_legacy_mod"]
285-
#[path = "num/shells/u32.rs"]
286-
pub mod u32;
287-
#[rustc_diagnostic_item = "u64_legacy_mod"]
288-
#[path = "num/shells/u64.rs"]
289-
pub mod u64;
290-
#[rustc_diagnostic_item = "u8_legacy_mod"]
291-
#[path = "num/shells/u8.rs"]
292-
pub mod u8;
293-
#[rustc_diagnostic_item = "usize_legacy_mod"]
294-
#[path = "num/shells/usize.rs"]
295-
pub mod usize;
259+
legacy_int_module! { i128, #[stable(feature = "i128", since = "1.26.0")] }
260+
legacy_int_module! { i16 }
261+
legacy_int_module! { i32 }
262+
legacy_int_module! { i64 }
263+
legacy_int_module! { i8 }
264+
legacy_int_module! { isize }
265+
legacy_int_module! { u128, #[stable(feature = "i128", since = "1.26.0")] }
266+
legacy_int_module! { u16 }
267+
legacy_int_module! { u32 }
268+
legacy_int_module! { u64 }
269+
legacy_int_module! { u8 }
270+
legacy_int_module! { usize }
296271

297272
#[path = "num/f128.rs"]
298273
pub mod f128;

library/core/src/num/shells/i128.rs

Lines changed: 0 additions & 11 deletions
This file was deleted.

library/core/src/num/shells/i16.rs

Lines changed: 0 additions & 11 deletions
This file was deleted.

library/core/src/num/shells/i32.rs

Lines changed: 0 additions & 11 deletions
This file was deleted.

library/core/src/num/shells/i64.rs

Lines changed: 0 additions & 11 deletions
This file was deleted.

library/core/src/num/shells/i8.rs

Lines changed: 0 additions & 11 deletions
This file was deleted.
Lines changed: 51 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,58 @@
11
#![doc(hidden)]
22

3-
macro_rules! int_module {
4-
($T:ident) => (int_module!($T, #[stable(feature = "rust1", since = "1.0.0")]););
3+
macro_rules! legacy_int_module {
4+
($T:ident) => (legacy_int_module!($T, #[stable(feature = "rust1", since = "1.0.0")]););
55
($T:ident, #[$attr:meta]) => (
6-
#[doc = concat!(
7-
"The smallest value that can be represented by this integer type. Use ",
8-
"[`", stringify!($T), "::MIN", "`] instead."
9-
)]
10-
///
11-
/// # Examples
12-
///
13-
/// ```rust
14-
/// // deprecated way
15-
#[doc = concat!("let min = std::", stringify!($T), "::MIN;")]
16-
///
17-
/// // intended way
18-
#[doc = concat!("let min = ", stringify!($T), "::MIN;")]
19-
/// ```
20-
///
216
#[$attr]
22-
#[deprecated(since = "TBD", note = "replaced by the `MIN` associated constant on this type")]
23-
#[rustc_diagnostic_item = concat!(stringify!($T), "_legacy_const_min")]
24-
pub const MIN: $T = $T::MIN;
25-
26-
#[doc = concat!(
27-
"The largest value that can be represented by this integer type. Use ",
28-
"[`", stringify!($T), "::MAX", "`] instead."
7+
#[deprecated(
8+
since = "TBD",
9+
note = "all constants in this module replaced by associated constants on the type"
2910
)]
30-
///
31-
/// # Examples
32-
///
33-
/// ```rust
34-
/// // deprecated way
35-
#[doc = concat!("let max = std::", stringify!($T), "::MAX;")]
36-
///
37-
/// // intended way
38-
#[doc = concat!("let max = ", stringify!($T), "::MAX;")]
39-
/// ```
40-
///
41-
#[$attr]
42-
#[deprecated(since = "TBD", note = "replaced by the `MAX` associated constant on this type")]
43-
#[rustc_diagnostic_item = concat!(stringify!($T), "_legacy_const_max")]
44-
pub const MAX: $T = $T::MAX;
11+
#[rustc_diagnostic_item = concat!(stringify!($T), "_legacy_mod")]
12+
pub mod $T {
13+
#![doc = concat!("Redundant constants module for the [`", stringify!($T), "` primitive type][", stringify!($T), "].")]
14+
//!
15+
//! New code should use the associated constants directly on the primitive type.
16+
17+
#[doc = concat!(
18+
"The smallest value that can be represented by this integer type. Use ",
19+
"[`", stringify!($T), "::MIN", "`] instead."
20+
)]
21+
///
22+
/// # Examples
23+
///
24+
/// ```rust
25+
/// // deprecated way
26+
#[doc = concat!("let min = std::", stringify!($T), "::MIN;")]
27+
///
28+
/// // intended way
29+
#[doc = concat!("let min = ", stringify!($T), "::MIN;")]
30+
/// ```
31+
///
32+
#[$attr]
33+
#[deprecated(since = "TBD", note = "replaced by the `MIN` associated constant on this type")]
34+
#[rustc_diagnostic_item = concat!(stringify!($T), "_legacy_const_min")]
35+
pub const MIN: $T = $T::MIN;
36+
37+
#[doc = concat!(
38+
"The largest value that can be represented by this integer type. Use ",
39+
"[`", stringify!($T), "::MAX", "`] instead."
40+
)]
41+
///
42+
/// # Examples
43+
///
44+
/// ```rust
45+
/// // deprecated way
46+
#[doc = concat!("let max = std::", stringify!($T), "::MAX;")]
47+
///
48+
/// // intended way
49+
#[doc = concat!("let max = ", stringify!($T), "::MAX;")]
50+
/// ```
51+
///
52+
#[$attr]
53+
#[deprecated(since = "TBD", note = "replaced by the `MAX` associated constant on this type")]
54+
#[rustc_diagnostic_item = concat!(stringify!($T), "_legacy_const_max")]
55+
pub const MAX: $T = $T::MAX;
56+
}
4557
)
4658
}

library/core/src/num/shells/isize.rs

Lines changed: 0 additions & 11 deletions
This file was deleted.

library/core/src/num/shells/u128.rs

Lines changed: 0 additions & 11 deletions
This file was deleted.

library/core/src/num/shells/u16.rs

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)