Stabilize char_max_len
This commit is contained in:
parent
c8551d3c63
commit
f9dcc6b21c
13 changed files with 17 additions and 26 deletions
|
|
@ -99,7 +99,6 @@
|
|||
#![feature(cast_maybe_uninit)]
|
||||
#![feature(cell_get_cloned)]
|
||||
#![feature(char_internals)]
|
||||
#![feature(char_max_len)]
|
||||
#![feature(clone_to_uninit)]
|
||||
#![feature(coerce_unsized)]
|
||||
#![feature(const_convert)]
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
#[cfg(test)]
|
||||
mod tests;
|
||||
|
||||
use core::char::{MAX_LEN_UTF8, encode_utf8_raw};
|
||||
use core::char::encode_utf8_raw;
|
||||
use core::hash::{Hash, Hasher};
|
||||
pub use core::wtf8::{CodePoint, Wtf8};
|
||||
#[cfg(not(test))]
|
||||
|
|
@ -166,7 +166,7 @@ impl Wtf8Buf {
|
|||
/// This does **not** include the WTF-8 concatenation check or `is_known_utf8` check.
|
||||
/// Copied from String::push.
|
||||
unsafe fn push_code_point_unchecked(&mut self, code_point: CodePoint) {
|
||||
let mut bytes = [0; MAX_LEN_UTF8];
|
||||
let mut bytes = [0; char::MAX_LEN_UTF8];
|
||||
let bytes = encode_utf8_raw(code_point.to_u32(), &mut bytes);
|
||||
self.bytes.extend_from_slice(bytes)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@
|
|||
#![feature(array_into_iter_constructors)]
|
||||
#![feature(assert_matches)]
|
||||
#![feature(char_internals)]
|
||||
#![feature(char_max_len)]
|
||||
#![feature(copied_into_inner)]
|
||||
#![feature(core_intrinsics)]
|
||||
#![feature(exact_size_is_empty)]
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@
|
|||
#![feature(iter_array_chunks)]
|
||||
#![feature(assert_matches)]
|
||||
#![feature(wtf8_internals)]
|
||||
#![feature(char_max_len)]
|
||||
#![feature(cow_is_borrowed)]
|
||||
#![feature(core_intrinsics)]
|
||||
#![feature(deque_extend_front)]
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
use std::assert_matches::assert_matches;
|
||||
use std::borrow::Cow;
|
||||
use std::char::MAX_LEN_UTF8;
|
||||
use std::cmp::Ordering::{Equal, Greater, Less};
|
||||
use std::str::{from_utf8, from_utf8_unchecked};
|
||||
|
||||
|
|
@ -1232,7 +1231,7 @@ fn test_to_uppercase_rev_iterator() {
|
|||
#[test]
|
||||
#[cfg_attr(miri, ignore)] // Miri is too slow
|
||||
fn test_chars_decoding() {
|
||||
let mut bytes = [0; MAX_LEN_UTF8];
|
||||
let mut bytes = [0; char::MAX_LEN_UTF8];
|
||||
for c in (0..0x110000).filter_map(std::char::from_u32) {
|
||||
let s = c.encode_utf8(&mut bytes);
|
||||
if Some(c) != s.chars().next() {
|
||||
|
|
@ -1244,7 +1243,7 @@ fn test_chars_decoding() {
|
|||
#[test]
|
||||
#[cfg_attr(miri, ignore)] // Miri is too slow
|
||||
fn test_chars_rev_decoding() {
|
||||
let mut bytes = [0; MAX_LEN_UTF8];
|
||||
let mut bytes = [0; char::MAX_LEN_UTF8];
|
||||
for c in (0..0x110000).filter_map(std::char::from_u32) {
|
||||
let s = c.encode_utf8(&mut bytes);
|
||||
if Some(c) != s.chars().rev().next() {
|
||||
|
|
|
|||
|
|
@ -74,12 +74,12 @@ impl char {
|
|||
|
||||
/// The maximum number of bytes required to [encode](char::encode_utf8) a `char` to
|
||||
/// UTF-8 encoding.
|
||||
#[unstable(feature = "char_max_len", issue = "121714")]
|
||||
#[stable(feature = "char_max_len_assoc", since = "CURRENT_RUSTC_VERSION")]
|
||||
pub const MAX_LEN_UTF8: usize = 4;
|
||||
|
||||
/// The maximum number of two-byte units required to [encode](char::encode_utf16) a `char`
|
||||
/// to UTF-16 encoding.
|
||||
#[unstable(feature = "char_max_len", issue = "121714")]
|
||||
#[stable(feature = "char_max_len_assoc", since = "CURRENT_RUSTC_VERSION")]
|
||||
pub const MAX_LEN_UTF16: usize = 2;
|
||||
|
||||
/// `U+FFFD REPLACEMENT CHARACTER` (<28>) is used in Unicode to represent a
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
#![stable(feature = "rust1", since = "1.0.0")]
|
||||
|
||||
use crate::cell::{Cell, Ref, RefCell, RefMut, SyncUnsafeCell, UnsafeCell};
|
||||
use crate::char::{EscapeDebugExtArgs, MAX_LEN_UTF8};
|
||||
use crate::char::EscapeDebugExtArgs;
|
||||
use crate::hint::assert_unchecked;
|
||||
use crate::marker::{PhantomData, PointeeSized};
|
||||
use crate::num::fmt as numfmt;
|
||||
|
|
@ -181,7 +181,7 @@ pub trait Write {
|
|||
/// ```
|
||||
#[stable(feature = "fmt_write_char", since = "1.1.0")]
|
||||
fn write_char(&mut self, c: char) -> Result {
|
||||
self.write_str(c.encode_utf8(&mut [0; MAX_LEN_UTF8]))
|
||||
self.write_str(c.encode_utf8(&mut [0; char::MAX_LEN_UTF8]))
|
||||
}
|
||||
|
||||
/// Glue for usage of the [`write!`] macro with implementors of this trait.
|
||||
|
|
@ -2983,7 +2983,7 @@ impl Display for char {
|
|||
if f.options.flags & (flags::WIDTH_FLAG | flags::PRECISION_FLAG) == 0 {
|
||||
f.write_char(*self)
|
||||
} else {
|
||||
f.pad(self.encode_utf8(&mut [0; MAX_LEN_UTF8]))
|
||||
f.pad(self.encode_utf8(&mut [0; char::MAX_LEN_UTF8]))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,7 +38,6 @@
|
|||
issue = "27721"
|
||||
)]
|
||||
|
||||
use crate::char::MAX_LEN_UTF8;
|
||||
use crate::cmp::Ordering;
|
||||
use crate::convert::TryInto as _;
|
||||
use crate::slice::memchr;
|
||||
|
|
@ -563,7 +562,7 @@ impl Pattern for char {
|
|||
|
||||
#[inline]
|
||||
fn into_searcher<'a>(self, haystack: &'a str) -> Self::Searcher<'a> {
|
||||
let mut utf8_encoded = [0; MAX_LEN_UTF8];
|
||||
let mut utf8_encoded = [0; char::MAX_LEN_UTF8];
|
||||
let utf8_size = self
|
||||
.encode_utf8(&mut utf8_encoded)
|
||||
.len()
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
// implementations, so, we'll have to add more doc(hidden)s anyway
|
||||
#![doc(hidden)]
|
||||
|
||||
use crate::char::{MAX_LEN_UTF16, encode_utf16_raw};
|
||||
use crate::char::encode_utf16_raw;
|
||||
use crate::clone::CloneToUninit;
|
||||
use crate::fmt::{self, Write};
|
||||
use crate::hash::{Hash, Hasher};
|
||||
|
|
@ -541,7 +541,7 @@ impl Iterator for EncodeWide<'_> {
|
|||
return Some(tmp);
|
||||
}
|
||||
|
||||
let mut buf = [0; MAX_LEN_UTF16];
|
||||
let mut buf = [0; char::MAX_LEN_UTF16];
|
||||
self.code_points.next().map(|code_point| {
|
||||
let n = encode_utf16_raw(code_point.to_u32(), &mut buf).len();
|
||||
if n == 2 {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
use std::char::MAX_LEN_UTF8;
|
||||
use std::str::FromStr;
|
||||
use std::{char, str};
|
||||
|
||||
|
|
@ -259,7 +258,7 @@ fn test_escape_unicode() {
|
|||
#[test]
|
||||
fn test_encode_utf8() {
|
||||
fn check(input: char, expect: &[u8]) {
|
||||
let mut buf = [0; MAX_LEN_UTF8];
|
||||
let mut buf = [0; char::MAX_LEN_UTF8];
|
||||
let ptr = buf.as_ptr();
|
||||
let s = input.encode_utf8(&mut buf);
|
||||
assert_eq!(s.as_ptr() as usize, ptr as usize);
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ use rand::RngCore;
|
|||
target_vendor = "apple",
|
||||
))]
|
||||
use crate::assert_matches::assert_matches;
|
||||
use crate::char::MAX_LEN_UTF8;
|
||||
#[cfg(any(
|
||||
windows,
|
||||
target_os = "freebsd",
|
||||
|
|
@ -174,7 +173,7 @@ fn file_test_io_non_positional_read() {
|
|||
#[test]
|
||||
fn file_test_io_seek_and_tell_smoke_test() {
|
||||
let message = "ten-four";
|
||||
let mut read_mem = [0; MAX_LEN_UTF8];
|
||||
let mut read_mem = [0; char::MAX_LEN_UTF8];
|
||||
let set_cursor = 4 as u64;
|
||||
let tell_pos_pre_read;
|
||||
let tell_pos_post_read;
|
||||
|
|
@ -405,7 +404,7 @@ fn file_test_io_seek_shakedown() {
|
|||
let chunk_one: &str = "qwer";
|
||||
let chunk_two: &str = "asdf";
|
||||
let chunk_three: &str = "zxcv";
|
||||
let mut read_mem = [0; MAX_LEN_UTF8];
|
||||
let mut read_mem = [0; char::MAX_LEN_UTF8];
|
||||
let tmpdir = tmpdir();
|
||||
let filename = &tmpdir.join("file_rt_io_file_test_seek_shakedown.txt");
|
||||
{
|
||||
|
|
@ -782,7 +781,7 @@ fn file_test_directoryinfo_readdir() {
|
|||
check!(w.write(msg));
|
||||
}
|
||||
let files = check!(fs::read_dir(dir));
|
||||
let mut mem = [0; MAX_LEN_UTF8];
|
||||
let mut mem = [0; char::MAX_LEN_UTF8];
|
||||
for f in files {
|
||||
let f = f.unwrap().path();
|
||||
{
|
||||
|
|
|
|||
|
|
@ -276,7 +276,6 @@
|
|||
#![feature(cfg_sanitizer_cfi)]
|
||||
#![feature(cfg_target_thread_local)]
|
||||
#![feature(cfi_encoding)]
|
||||
#![feature(char_max_len)]
|
||||
#![feature(const_trait_impl)]
|
||||
#![feature(core_float_math)]
|
||||
#![feature(decl_macro)]
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
#![unstable(issue = "none", feature = "windows_stdio")]
|
||||
|
||||
use core::char::MAX_LEN_UTF8;
|
||||
use core::str::utf8_char_width;
|
||||
|
||||
use crate::mem::MaybeUninit;
|
||||
|
|
@ -427,7 +426,7 @@ fn utf16_to_utf8(utf16: &[u16], utf8: &mut [u8]) -> io::Result<usize> {
|
|||
|
||||
impl IncompleteUtf8 {
|
||||
pub const fn new() -> IncompleteUtf8 {
|
||||
IncompleteUtf8 { bytes: [0; MAX_LEN_UTF8], len: 0 }
|
||||
IncompleteUtf8 { bytes: [0; char::MAX_LEN_UTF8], len: 0 }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue