Skip to content

Commit b0ecdf9

Browse files
Delete deprecated APIs
Removes std_unicode, char::decode_utf8, ptr::offset_to, io::Read::chars.
1 parent 866a713 commit b0ecdf9

File tree

14 files changed

+1
-540
lines changed

14 files changed

+1
-540
lines changed

src/Cargo.lock

-9
Original file line numberDiff line numberDiff line change
@@ -2615,18 +2615,9 @@ dependencies = [
26152615
"rustc_lsan 0.0.0",
26162616
"rustc_msan 0.0.0",
26172617
"rustc_tsan 0.0.0",
2618-
"std_unicode 0.0.0",
26192618
"unwind 0.0.0",
26202619
]
26212620

2622-
[[package]]
2623-
name = "std_unicode"
2624-
version = "0.0.0"
2625-
dependencies = [
2626-
"compiler_builtins 0.0.0",
2627-
"core 0.0.0",
2628-
]
2629-
26302621
[[package]]
26312622
name = "string_cache"
26322623
version = "0.7.3"

src/bootstrap/compile.rs

-1
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,6 @@ pub fn std_cargo(builder: &Builder,
157157
cargo.arg("--features").arg("c mem")
158158
.args(&["-p", "alloc"])
159159
.args(&["-p", "compiler_builtins"])
160-
.args(&["-p", "std_unicode"])
161160
.arg("--manifest-path")
162161
.arg(builder.src.join("src/rustc/compiler_builtins_shim/Cargo.toml"));
163162
} else {

src/bootstrap/dist.rs

-1
Original file line numberDiff line numberDiff line change
@@ -856,7 +856,6 @@ impl Step for Src {
856856
"src/librustc_msan",
857857
"src/librustc_tsan",
858858
"src/libstd",
859-
"src/libstd_unicode",
860859
"src/libunwind",
861860
"src/rustc/compiler_builtins_shim",
862861
"src/rustc/libc_shim",

src/bootstrap/doc.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,7 @@ impl Step for Std {
489489
// Keep a whitelist so we do not build internal stdlib crates, these will be
490490
// build by the rustc step later if enabled.
491491
cargo.arg("--no-deps");
492-
for krate in &["alloc", "core", "std", "std_unicode"] {
492+
for krate in &["alloc", "core", "std"] {
493493
cargo.arg("-p").arg(krate);
494494
// Create all crate output directories first to make sure rustdoc uses
495495
// relative links.

src/libcore/char/decode.rs

-127
Original file line numberDiff line numberDiff line change
@@ -11,135 +11,8 @@
1111
//! UTF-8 and UTF-16 decoding iterators
1212
1313
use fmt;
14-
use iter::FusedIterator;
1514
use super::from_u32_unchecked;
1615

17-
/// An iterator over an iterator of bytes of the characters the bytes represent
18-
/// as UTF-8
19-
#[unstable(feature = "decode_utf8", issue = "33906")]
20-
#[rustc_deprecated(since = "1.27.0", reason = "Use str::from_utf8 instead:
21-
https://doc.rust-lang.org/nightly/std/str/struct.Utf8Error.html#examples")]
22-
#[derive(Clone, Debug)]
23-
#[allow(deprecated)]
24-
pub struct DecodeUtf8<I: Iterator<Item = u8>>(::iter::Peekable<I>);
25-
26-
/// Decodes an `Iterator` of bytes as UTF-8.
27-
#[unstable(feature = "decode_utf8", issue = "33906")]
28-
#[rustc_deprecated(since = "1.27.0", reason = "Use str::from_utf8 instead:
29-
https://doc.rust-lang.org/nightly/std/str/struct.Utf8Error.html#examples")]
30-
#[allow(deprecated)]
31-
#[inline]
32-
pub fn decode_utf8<I: IntoIterator<Item = u8>>(i: I) -> DecodeUtf8<I::IntoIter> {
33-
DecodeUtf8(i.into_iter().peekable())
34-
}
35-
36-
/// `<DecodeUtf8 as Iterator>::next` returns this for an invalid input sequence.
37-
#[unstable(feature = "decode_utf8", issue = "33906")]
38-
#[rustc_deprecated(since = "1.27.0", reason = "Use str::from_utf8 instead:
39-
https://doc.rust-lang.org/nightly/std/str/struct.Utf8Error.html#examples")]
40-
#[derive(PartialEq, Eq, Debug)]
41-
#[allow(deprecated)]
42-
pub struct InvalidSequence(());
43-
44-
#[unstable(feature = "decode_utf8", issue = "33906")]
45-
#[allow(deprecated)]
46-
impl<I: Iterator<Item = u8>> Iterator for DecodeUtf8<I> {
47-
type Item = Result<char, InvalidSequence>;
48-
#[inline]
49-
50-
fn next(&mut self) -> Option<Result<char, InvalidSequence>> {
51-
self.0.next().map(|first_byte| {
52-
// Emit InvalidSequence according to
53-
// Unicode §5.22 Best Practice for U+FFFD Substitution
54-
// http://www.unicode.org/versions/Unicode9.0.0/ch05.pdf#G40630
55-
56-
// Roughly: consume at least one byte,
57-
// then validate one byte at a time and stop before the first unexpected byte
58-
// (which might be the valid start of the next byte sequence).
59-
60-
let mut code_point;
61-
macro_rules! first_byte {
62-
($mask: expr) => {
63-
code_point = u32::from(first_byte & $mask)
64-
}
65-
}
66-
macro_rules! continuation_byte {
67-
() => { continuation_byte!(0x80..=0xBF) };
68-
($range: pat) => {
69-
match self.0.peek() {
70-
Some(&byte @ $range) => {
71-
code_point = (code_point << 6) | u32::from(byte & 0b0011_1111);
72-
self.0.next();
73-
}
74-
_ => return Err(InvalidSequence(()))
75-
}
76-
}
77-
}
78-
79-
match first_byte {
80-
0x00..=0x7F => {
81-
first_byte!(0b1111_1111);
82-
}
83-
0xC2..=0xDF => {
84-
first_byte!(0b0001_1111);
85-
continuation_byte!();
86-
}
87-
0xE0 => {
88-
first_byte!(0b0000_1111);
89-
continuation_byte!(0xA0..=0xBF); // 0x80..=0x9F here are overlong
90-
continuation_byte!();
91-
}
92-
0xE1..=0xEC | 0xEE..=0xEF => {
93-
first_byte!(0b0000_1111);
94-
continuation_byte!();
95-
continuation_byte!();
96-
}
97-
0xED => {
98-
first_byte!(0b0000_1111);
99-
continuation_byte!(0x80..=0x9F); // 0xA0..0xBF here are surrogates
100-
continuation_byte!();
101-
}
102-
0xF0 => {
103-
first_byte!(0b0000_0111);
104-
continuation_byte!(0x90..=0xBF); // 0x80..0x8F here are overlong
105-
continuation_byte!();
106-
continuation_byte!();
107-
}
108-
0xF1..=0xF3 => {
109-
first_byte!(0b0000_0111);
110-
continuation_byte!();
111-
continuation_byte!();
112-
continuation_byte!();
113-
}
114-
0xF4 => {
115-
first_byte!(0b0000_0111);
116-
continuation_byte!(0x80..=0x8F); // 0x90..0xBF here are beyond char::MAX
117-
continuation_byte!();
118-
continuation_byte!();
119-
}
120-
_ => return Err(InvalidSequence(())) // Illegal first byte, overlong, or beyond MAX
121-
}
122-
unsafe {
123-
Ok(from_u32_unchecked(code_point))
124-
}
125-
})
126-
}
127-
128-
#[inline]
129-
fn size_hint(&self) -> (usize, Option<usize>) {
130-
let (lower, upper) = self.0.size_hint();
131-
132-
// A code point is at most 4 bytes long.
133-
let min_code_points = lower / 4;
134-
135-
(min_code_points, upper)
136-
}
137-
}
138-
139-
#[unstable(feature = "decode_utf8", issue = "33906")]
140-
#[allow(deprecated)]
141-
impl<I: FusedIterator<Item = u8>> FusedIterator for DecodeUtf8<I> {}
142-
14316
/// An iterator that decodes UTF-16 encoded code points from an iterator of `u16`s.
14417
#[stable(feature = "decode_utf16", since = "1.9.0")]
14518
#[derive(Clone, Debug)]

src/libcore/char/mod.rs

-5
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,6 @@ pub use self::decode::{decode_utf16, DecodeUtf16, DecodeUtf16Error};
5050
pub use unicode::tables::UNICODE_VERSION;
5151
#[unstable(feature = "unicode_version", issue = "49726")]
5252
pub use unicode::version::UnicodeVersion;
53-
#[unstable(feature = "decode_utf8", issue = "33906")]
54-
#[rustc_deprecated(since = "1.27.0", reason = "Use str::from_utf8 instead:
55-
https://doc.rust-lang.org/nightly/std/str/struct.Utf8Error.html#examples")]
56-
#[allow(deprecated)]
57-
pub use self::decode::{decode_utf8, DecodeUtf8, InvalidSequence};
5853

5954
use fmt::{self, Write};
6055
use iter::FusedIterator;

src/libcore/ptr.rs

-80
Original file line numberDiff line numberDiff line change
@@ -680,46 +680,6 @@ impl<T: ?Sized> *const T {
680680
}
681681
}
682682

683-
/// Calculates the distance between two pointers. The returned value is in
684-
/// units of T: the distance in bytes is divided by `mem::size_of::<T>()`.
685-
///
686-
/// If the address different between the two pointers ia not a multiple of
687-
/// `mem::size_of::<T>()` then the result of the division is rounded towards
688-
/// zero.
689-
///
690-
/// This function returns `None` if `T` is a zero-sized type.
691-
///
692-
/// # Examples
693-
///
694-
/// Basic usage:
695-
///
696-
/// ```
697-
/// #![feature(offset_to)]
698-
/// #![allow(deprecated)]
699-
///
700-
/// fn main() {
701-
/// let a = [0; 5];
702-
/// let ptr1: *const i32 = &a[1];
703-
/// let ptr2: *const i32 = &a[3];
704-
/// assert_eq!(ptr1.offset_to(ptr2), Some(2));
705-
/// assert_eq!(ptr2.offset_to(ptr1), Some(-2));
706-
/// assert_eq!(unsafe { ptr1.offset(2) }, ptr2);
707-
/// assert_eq!(unsafe { ptr2.offset(-2) }, ptr1);
708-
/// }
709-
/// ```
710-
#[unstable(feature = "offset_to", issue = "41079")]
711-
#[rustc_deprecated(since = "1.27.0", reason = "Replaced by `wrapping_offset_from`, with the \
712-
opposite argument order. If you're writing unsafe code, consider `offset_from`.")]
713-
#[inline]
714-
pub fn offset_to(self, other: *const T) -> Option<isize> where T: Sized {
715-
let size = mem::size_of::<T>();
716-
if size == 0 {
717-
None
718-
} else {
719-
Some(other.wrapping_offset_from(self))
720-
}
721-
}
722-
723683
/// Calculates the distance between two pointers. The returned value is in
724684
/// units of T: the distance in bytes is divided by `mem::size_of::<T>()`.
725685
///
@@ -1464,46 +1424,6 @@ impl<T: ?Sized> *mut T {
14641424
}
14651425
}
14661426

1467-
/// Calculates the distance between two pointers. The returned value is in
1468-
/// units of T: the distance in bytes is divided by `mem::size_of::<T>()`.
1469-
///
1470-
/// If the address different between the two pointers ia not a multiple of
1471-
/// `mem::size_of::<T>()` then the result of the division is rounded towards
1472-
/// zero.
1473-
///
1474-
/// This function returns `None` if `T` is a zero-sized type.
1475-
///
1476-
/// # Examples
1477-
///
1478-
/// Basic usage:
1479-
///
1480-
/// ```
1481-
/// #![feature(offset_to)]
1482-
/// #![allow(deprecated)]
1483-
///
1484-
/// fn main() {
1485-
/// let mut a = [0; 5];
1486-
/// let ptr1: *mut i32 = &mut a[1];
1487-
/// let ptr2: *mut i32 = &mut a[3];
1488-
/// assert_eq!(ptr1.offset_to(ptr2), Some(2));
1489-
/// assert_eq!(ptr2.offset_to(ptr1), Some(-2));
1490-
/// assert_eq!(unsafe { ptr1.offset(2) }, ptr2);
1491-
/// assert_eq!(unsafe { ptr2.offset(-2) }, ptr1);
1492-
/// }
1493-
/// ```
1494-
#[unstable(feature = "offset_to", issue = "41079")]
1495-
#[rustc_deprecated(since = "1.27.0", reason = "Replaced by `wrapping_offset_from`, with the \
1496-
opposite argument order. If you're writing unsafe code, consider `offset_from`.")]
1497-
#[inline]
1498-
pub fn offset_to(self, other: *const T) -> Option<isize> where T: Sized {
1499-
let size = mem::size_of::<T>();
1500-
if size == 0 {
1501-
None
1502-
} else {
1503-
Some(other.wrapping_offset_from(self))
1504-
}
1505-
}
1506-
15071427
/// Calculates the distance between two pointers. The returned value is in
15081428
/// units of T: the distance in bytes is divided by `mem::size_of::<T>()`.
15091429
///

src/libcore/tests/char.rs

-51
Original file line numberDiff line numberDiff line change
@@ -363,54 +363,3 @@ fn eu_iterator_specializations() {
363363
check('\u{12340}');
364364
check('\u{10FFFF}');
365365
}
366-
367-
#[test]
368-
#[allow(deprecated)]
369-
fn test_decode_utf8() {
370-
macro_rules! assert_decode_utf8 {
371-
($input_bytes: expr, $expected_str: expr) => {
372-
let input_bytes: &[u8] = &$input_bytes;
373-
let s = char::decode_utf8(input_bytes.iter().cloned())
374-
.map(|r_b| r_b.unwrap_or('\u{FFFD}'))
375-
.collect::<String>();
376-
assert_eq!(s, $expected_str,
377-
"input bytes: {:?}, expected str: {:?}, result: {:?}",
378-
input_bytes, $expected_str, s);
379-
assert_eq!(String::from_utf8_lossy(&$input_bytes), $expected_str);
380-
}
381-
}
382-
383-
assert_decode_utf8!([], "");
384-
assert_decode_utf8!([0x41], "A");
385-
assert_decode_utf8!([0xC1, 0x81], "��");
386-
assert_decode_utf8!([0xE2, 0x99, 0xA5], "♥");
387-
assert_decode_utf8!([0xE2, 0x99, 0xA5, 0x41], "♥A");
388-
assert_decode_utf8!([0xE2, 0x99], "�");
389-
assert_decode_utf8!([0xE2, 0x99, 0x41], "�A");
390-
assert_decode_utf8!([0xC0], "�");
391-
assert_decode_utf8!([0xC0, 0x41], "�A");
392-
assert_decode_utf8!([0x80], "�");
393-
assert_decode_utf8!([0x80, 0x41], "�A");
394-
assert_decode_utf8!([0xFE], "�");
395-
assert_decode_utf8!([0xFE, 0x41], "�A");
396-
assert_decode_utf8!([0xFF], "�");
397-
assert_decode_utf8!([0xFF, 0x41], "�A");
398-
assert_decode_utf8!([0xC0, 0x80], "��");
399-
400-
// Surrogates
401-
assert_decode_utf8!([0xED, 0x9F, 0xBF], "\u{D7FF}");
402-
assert_decode_utf8!([0xED, 0xA0, 0x80], "���");
403-
assert_decode_utf8!([0xED, 0xBF, 0x80], "���");
404-
assert_decode_utf8!([0xEE, 0x80, 0x80], "\u{E000}");
405-
406-
// char::MAX
407-
assert_decode_utf8!([0xF4, 0x8F, 0xBF, 0xBF], "\u{10FFFF}");
408-
assert_decode_utf8!([0xF4, 0x8F, 0xBF, 0x41], "�A");
409-
assert_decode_utf8!([0xF4, 0x90, 0x80, 0x80], "����");
410-
411-
// 5 and 6 bytes sequence
412-
// Part of the original design of UTF-8,
413-
// but invalid now that UTF-8 is artificially restricted to match the range of UTF-16.
414-
assert_decode_utf8!([0xF8, 0x80, 0x80, 0x80, 0x80], "�����");
415-
assert_decode_utf8!([0xFC, 0x80, 0x80, 0x80, 0x80, 0x80], "������");
416-
}

src/libstd/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ core = { path = "../libcore" }
2222
libc = { path = "../rustc/libc_shim" }
2323
compiler_builtins = { path = "../rustc/compiler_builtins_shim" }
2424
profiler_builtins = { path = "../libprofiler_builtins", optional = true }
25-
std_unicode = { path = "../libstd_unicode" }
2625
unwind = { path = "../libunwind" }
2726

2827
[dev-dependencies]

0 commit comments

Comments
 (0)