Skip to content

Commit 0e882fc

Browse files
committed
Stabilize char_max_len
1 parent c90bcb9 commit 0e882fc

File tree

13 files changed

+17
-26
lines changed

13 files changed

+17
-26
lines changed

library/alloc/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@
9999
#![feature(cast_maybe_uninit)]
100100
#![feature(cell_get_cloned)]
101101
#![feature(char_internals)]
102-
#![feature(char_max_len)]
103102
#![feature(clone_to_uninit)]
104103
#![feature(coerce_unsized)]
105104
#![feature(const_convert)]

library/alloc/src/wtf8/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#[cfg(test)]
1515
mod tests;
1616

17-
use core::char::{MAX_LEN_UTF8, encode_utf8_raw};
17+
use core::char::encode_utf8_raw;
1818
use core::hash::{Hash, Hasher};
1919
pub use core::wtf8::{CodePoint, Wtf8};
2020
#[cfg(not(test))]
@@ -166,7 +166,7 @@ impl Wtf8Buf {
166166
/// This does **not** include the WTF-8 concatenation check or `is_known_utf8` check.
167167
/// Copied from String::push.
168168
unsafe fn push_code_point_unchecked(&mut self, code_point: CodePoint) {
169-
let mut bytes = [0; MAX_LEN_UTF8];
169+
let mut bytes = [0; char::MAX_LEN_UTF8];
170170
let bytes = encode_utf8_raw(code_point.to_u32(), &mut bytes);
171171
self.bytes.extend_from_slice(bytes)
172172
}

library/alloctests/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#![feature(array_into_iter_constructors)]
2020
#![feature(assert_matches)]
2121
#![feature(char_internals)]
22-
#![feature(char_max_len)]
2322
#![feature(copied_into_inner)]
2423
#![feature(core_intrinsics)]
2524
#![feature(exact_size_is_empty)]

library/alloctests/tests/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
#![feature(iter_array_chunks)]
44
#![feature(assert_matches)]
55
#![feature(wtf8_internals)]
6-
#![feature(char_max_len)]
76
#![feature(cow_is_borrowed)]
87
#![feature(core_intrinsics)]
98
#![feature(deque_extend_front)]

library/alloctests/tests/str.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
use std::assert_matches::assert_matches;
44
use std::borrow::Cow;
5-
use std::char::MAX_LEN_UTF8;
65
use std::cmp::Ordering::{Equal, Greater, Less};
76
use std::str::{from_utf8, from_utf8_unchecked};
87

@@ -1232,7 +1231,7 @@ fn test_to_uppercase_rev_iterator() {
12321231
#[test]
12331232
#[cfg_attr(miri, ignore)] // Miri is too slow
12341233
fn test_chars_decoding() {
1235-
let mut bytes = [0; MAX_LEN_UTF8];
1234+
let mut bytes = [0; char::MAX_LEN_UTF8];
12361235
for c in (0..0x110000).filter_map(std::char::from_u32) {
12371236
let s = c.encode_utf8(&mut bytes);
12381237
if Some(c) != s.chars().next() {
@@ -1244,7 +1243,7 @@ fn test_chars_decoding() {
12441243
#[test]
12451244
#[cfg_attr(miri, ignore)] // Miri is too slow
12461245
fn test_chars_rev_decoding() {
1247-
let mut bytes = [0; MAX_LEN_UTF8];
1246+
let mut bytes = [0; char::MAX_LEN_UTF8];
12481247
for c in (0..0x110000).filter_map(std::char::from_u32) {
12491248
let s = c.encode_utf8(&mut bytes);
12501249
if Some(c) != s.chars().rev().next() {

library/core/src/char/methods.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,12 @@ impl char {
7474

7575
/// The maximum number of bytes required to [encode](char::encode_utf8) a `char` to
7676
/// UTF-8 encoding.
77-
#[unstable(feature = "char_max_len", issue = "121714")]
77+
#[stable(feature = "char_max_len_assoc", since = "CURRENT_RUSTC_VERSION")]
7878
pub const MAX_LEN_UTF8: usize = 4;
7979

8080
/// The maximum number of two-byte units required to [encode](char::encode_utf16) a `char`
8181
/// to UTF-16 encoding.
82-
#[unstable(feature = "char_max_len", issue = "121714")]
82+
#[stable(feature = "char_max_len_assoc", since = "CURRENT_RUSTC_VERSION")]
8383
pub const MAX_LEN_UTF16: usize = 2;
8484

8585
/// `U+FFFD REPLACEMENT CHARACTER` (�) is used in Unicode to represent a

library/core/src/fmt/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#![stable(feature = "rust1", since = "1.0.0")]
44

55
use crate::cell::{Cell, Ref, RefCell, RefMut, SyncUnsafeCell, UnsafeCell};
6-
use crate::char::{EscapeDebugExtArgs, MAX_LEN_UTF8};
6+
use crate::char::EscapeDebugExtArgs;
77
use crate::marker::{PhantomData, PointeeSized};
88
use crate::num::fmt as numfmt;
99
use crate::ops::Deref;
@@ -179,7 +179,7 @@ pub trait Write {
179179
/// ```
180180
#[stable(feature = "fmt_write_char", since = "1.1.0")]
181181
fn write_char(&mut self, c: char) -> Result {
182-
self.write_str(c.encode_utf8(&mut [0; MAX_LEN_UTF8]))
182+
self.write_str(c.encode_utf8(&mut [0; char::MAX_LEN_UTF8]))
183183
}
184184

185185
/// Glue for usage of the [`write!`] macro with implementors of this trait.
@@ -2775,7 +2775,7 @@ impl Display for char {
27752775
if f.options.flags & (flags::WIDTH_FLAG | flags::PRECISION_FLAG) == 0 {
27762776
f.write_char(*self)
27772777
} else {
2778-
f.pad(self.encode_utf8(&mut [0; MAX_LEN_UTF8]))
2778+
f.pad(self.encode_utf8(&mut [0; char::MAX_LEN_UTF8]))
27792779
}
27802780
}
27812781
}

library/core/src/str/pattern.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
issue = "27721"
3939
)]
4040

41-
use crate::char::MAX_LEN_UTF8;
4241
use crate::cmp::Ordering;
4342
use crate::convert::TryInto as _;
4443
use crate::slice::memchr;
@@ -563,7 +562,7 @@ impl Pattern for char {
563562

564563
#[inline]
565564
fn into_searcher<'a>(self, haystack: &'a str) -> Self::Searcher<'a> {
566-
let mut utf8_encoded = [0; MAX_LEN_UTF8];
565+
let mut utf8_encoded = [0; char::MAX_LEN_UTF8];
567566
let utf8_size = self
568567
.encode_utf8(&mut utf8_encoded)
569568
.len()

library/core/src/wtf8.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
// implementations, so, we'll have to add more doc(hidden)s anyway
2020
#![doc(hidden)]
2121

22-
use crate::char::{MAX_LEN_UTF16, encode_utf16_raw};
22+
use crate::char::encode_utf16_raw;
2323
use crate::clone::CloneToUninit;
2424
use crate::fmt::{self, Write};
2525
use crate::hash::{Hash, Hasher};
@@ -541,7 +541,7 @@ impl Iterator for EncodeWide<'_> {
541541
return Some(tmp);
542542
}
543543

544-
let mut buf = [0; MAX_LEN_UTF16];
544+
let mut buf = [0; char::MAX_LEN_UTF16];
545545
self.code_points.next().map(|code_point| {
546546
let n = encode_utf16_raw(code_point.to_u32(), &mut buf).len();
547547
if n == 2 {

library/coretests/tests/char.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use std::char::MAX_LEN_UTF8;
21
use std::str::FromStr;
32
use std::{char, str};
43

@@ -259,7 +258,7 @@ fn test_escape_unicode() {
259258
#[test]
260259
fn test_encode_utf8() {
261260
fn check(input: char, expect: &[u8]) {
262-
let mut buf = [0; MAX_LEN_UTF8];
261+
let mut buf = [0; char::MAX_LEN_UTF8];
263262
let ptr = buf.as_ptr();
264263
let s = input.encode_utf8(&mut buf);
265264
assert_eq!(s.as_ptr() as usize, ptr as usize);

0 commit comments

Comments
 (0)