Skip to content

Commit 22aaa41

Browse files
authored
Rollup merge of #153873 - folkertdev:deprecate-char-max, r=Mark-Simulacrum
deprecate `std::char` constants and functions similar to how constants in those modules for numeric types have been deprecated. The `std::char` module contains: Three stable constants that this PR deprecates. These already link to their associated constant equivalents. - `MAX` - `REPLACEMENT_CHARACTER` - `UNICODE_VERSION` two unstable constants that this PR removes. The constants are already stablized as associated constants on `char`. - `MAX_LEN_UTF8` - `MAX_LEN_UTF16` Four stable functions that this PR deprecates. These already link to their method equivalents. - `fn decode_utf16` - `fn from_digit` - `fn from_u32` - `fn from_u32_unchecked⚠` discussion at [#t-libs > should `std::char::{MIN, MAX}` be deprecated?](https://rust-lang.zulipchat.com/#narrow/channel/219381-t-libs/topic/should.20.60std.3A.3Achar.3A.3A.7BMIN.2C.20MAX.7D.60.20be.20deprecated.3F/with/579444750). r? libs-api
2 parents 6b7aa2d + ee9b61c commit 22aaa41

2 files changed

Lines changed: 13 additions & 11 deletions

File tree

library/core/src/char/mod.rs

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -93,31 +93,31 @@ const MAX_THREE_B: u32 = 0x10000;
9393

9494
/// The highest valid code point a `char` can have, `'\u{10FFFF}'`. Use [`char::MAX`] instead.
9595
#[stable(feature = "rust1", since = "1.0.0")]
96+
#[deprecated(since = "TBD", note = "replaced by the `MAX` associated constant on `char`")]
9697
pub const MAX: char = char::MAX;
9798

98-
/// The maximum number of bytes required to [encode](char::encode_utf8) a `char` to
99-
/// UTF-8 encoding.
100-
#[unstable(feature = "char_max_len", issue = "121714")]
101-
pub const MAX_LEN_UTF8: usize = char::MAX_LEN_UTF8;
102-
103-
/// The maximum number of two-byte units required to [encode](char::encode_utf16) a `char`
104-
/// to UTF-16 encoding.
105-
#[unstable(feature = "char_max_len", issue = "121714")]
106-
pub const MAX_LEN_UTF16: usize = char::MAX_LEN_UTF16;
107-
10899
/// `U+FFFD REPLACEMENT CHARACTER` (�) is used in Unicode to represent a
109100
/// decoding error. Use [`char::REPLACEMENT_CHARACTER`] instead.
110101
#[stable(feature = "decode_utf16", since = "1.9.0")]
102+
#[deprecated(
103+
since = "TBD",
104+
note = "replaced by the `REPLACEMENT_CHARACTER` associated constant on `char`"
105+
)]
111106
pub const REPLACEMENT_CHARACTER: char = char::REPLACEMENT_CHARACTER;
112107

113108
/// The version of [Unicode](https://www.unicode.org/) that the Unicode parts of
114109
/// `char` and `str` methods are based on. Use [`char::UNICODE_VERSION`] instead.
115110
#[stable(feature = "unicode_version", since = "1.45.0")]
111+
#[deprecated(
112+
since = "TBD",
113+
note = "replaced by the `UNICODE_VERSION` associated constant on `char`"
114+
)]
116115
pub const UNICODE_VERSION: (u8, u8, u8) = char::UNICODE_VERSION;
117116

118117
/// Creates an iterator over the UTF-16 encoded code points in `iter`, returning
119118
/// unpaired surrogates as `Err`s. Use [`char::decode_utf16`] instead.
120119
#[stable(feature = "decode_utf16", since = "1.9.0")]
120+
#[deprecated(since = "TBD", note = "replaced by the `decode_utf16` method on `char`")]
121121
#[inline]
122122
pub fn decode_utf16<I: IntoIterator<Item = u16>>(iter: I) -> DecodeUtf16<I::IntoIter> {
123123
self::decode::decode_utf16(iter)
@@ -126,6 +126,7 @@ pub fn decode_utf16<I: IntoIterator<Item = u16>>(iter: I) -> DecodeUtf16<I::Into
126126
/// Converts a `u32` to a `char`. Use [`char::from_u32`] instead.
127127
#[stable(feature = "rust1", since = "1.0.0")]
128128
#[rustc_const_stable(feature = "const_char_convert", since = "1.67.0")]
129+
#[deprecated(since = "TBD", note = "replaced by the `from_u32` method on `char`")]
129130
#[must_use]
130131
#[inline]
131132
pub const fn from_u32(i: u32) -> Option<char> {
@@ -136,6 +137,7 @@ pub const fn from_u32(i: u32) -> Option<char> {
136137
/// instead.
137138
#[stable(feature = "char_from_unchecked", since = "1.5.0")]
138139
#[rustc_const_stable(feature = "const_char_from_u32_unchecked", since = "1.81.0")]
140+
#[deprecated(since = "TBD", note = "replaced by the `from_u32_unchecked` method on `char`")]
139141
#[must_use]
140142
#[inline]
141143
pub const unsafe fn from_u32_unchecked(i: u32) -> char {
@@ -146,6 +148,7 @@ pub const unsafe fn from_u32_unchecked(i: u32) -> char {
146148
/// Converts a digit in the given radix to a `char`. Use [`char::from_digit`] instead.
147149
#[stable(feature = "rust1", since = "1.0.0")]
148150
#[rustc_const_stable(feature = "const_char_convert", since = "1.67.0")]
151+
#[deprecated(since = "TBD", note = "replaced by the `from_digit` method on `char`")]
149152
#[must_use]
150153
#[inline]
151154
pub const fn from_digit(num: u32, radix: u32) -> Option<char> {

library/coretests/tests/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
#![feature(bstr)]
1313
#![feature(cfg_target_has_reliable_f16_f128)]
1414
#![feature(char_internals)]
15-
#![feature(char_max_len)]
1615
#![feature(clone_to_uninit)]
1716
#![feature(cmp_minmax)]
1817
#![feature(const_array)]

0 commit comments

Comments
 (0)