Skip to content

Commit 728eea7

Browse files
committed
Auto merge of #33853 - alexcrichton:remove-deprecated, r=aturon
std: Clean out old unstable + deprecated APIs These should all have been deprecated for at least one cycle, so this commit cleans them all out.
2 parents 12d1659 + b64c9d5 commit 728eea7

29 files changed

+52
-1212
lines changed

src/libcollections/str.rs

-239
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,6 @@ impl<S: Borrow<str>> SliceConcatExt<str> for [S] {
112112
}
113113
}
114114

115-
/// Deprecated, renamed to EncodeUtf16
116-
#[unstable(feature = "str_utf16", issue = "27714")]
117-
#[rustc_deprecated(since = "1.8.0", reason = "renamed to EncodeUtf16")]
118-
pub type Utf16Units<'a> = EncodeUtf16<'a>;
119-
120115
/// External iterator for a string's UTF-16 code units.
121116
///
122117
/// For use with the `std::iter` module.
@@ -352,230 +347,6 @@ impl str {
352347
core_str::StrExt::slice_mut_unchecked(self, begin, end)
353348
}
354349

355-
/// Given a byte position, returns the next `char` and its index.
356-
///
357-
/// # Panics
358-
///
359-
/// If `i` is greater than or equal to the length of the string.
360-
/// If `i` is not the index of the beginning of a valid UTF-8 sequence.
361-
///
362-
/// # Examples
363-
///
364-
/// This example manually iterates through the code points of a string;
365-
/// this should normally be
366-
/// done by `.chars()` or `.char_indices()`.
367-
///
368-
/// ```
369-
/// #![feature(str_char)]
370-
/// #![allow(deprecated)]
371-
///
372-
/// use std::str::CharRange;
373-
///
374-
/// let s = "中华Việt Nam";
375-
/// let mut i = 0;
376-
/// while i < s.len() {
377-
/// let CharRange {ch, next} = s.char_range_at(i);
378-
/// println!("{}: {}", i, ch);
379-
/// i = next;
380-
/// }
381-
/// ```
382-
///
383-
/// This outputs:
384-
///
385-
/// ```text
386-
/// 0: 中
387-
/// 3: 华
388-
/// 6: V
389-
/// 7: i
390-
/// 8: e
391-
/// 9:
392-
/// 11:
393-
/// 13: t
394-
/// 14:
395-
/// 15: N
396-
/// 16: a
397-
/// 17: m
398-
/// ```
399-
#[unstable(feature = "str_char",
400-
reason = "often replaced by char_indices, this method may \
401-
be removed in favor of just char_at() or eventually \
402-
removed altogether",
403-
issue = "27754")]
404-
#[inline]
405-
#[rustc_deprecated(reason = "use slicing plus chars() plus len_utf8",
406-
since = "1.9.0")]
407-
#[allow(deprecated)]
408-
pub fn char_range_at(&self, start: usize) -> CharRange {
409-
core_str::StrExt::char_range_at(self, start)
410-
}
411-
412-
/// Given a byte position, returns the previous `char` and its position.
413-
///
414-
/// Note that Unicode has many features, such as combining marks, ligatures,
415-
/// and direction marks, that need to be taken into account to correctly reverse a string.
416-
///
417-
/// Returns 0 for next index if called on start index 0.
418-
///
419-
/// # Panics
420-
///
421-
/// If `i` is greater than the length of the string.
422-
/// If `i` is not an index following a valid UTF-8 sequence.
423-
///
424-
/// # Examples
425-
///
426-
/// This example manually iterates through the code points of a string;
427-
/// this should normally be
428-
/// done by `.chars().rev()` or `.char_indices()`.
429-
///
430-
/// ```
431-
/// #![feature(str_char)]
432-
/// #![allow(deprecated)]
433-
///
434-
/// use std::str::CharRange;
435-
///
436-
/// let s = "中华Việt Nam";
437-
/// let mut i = s.len();
438-
/// while i > 0 {
439-
/// let CharRange {ch, next} = s.char_range_at_reverse(i);
440-
/// println!("{}: {}", i, ch);
441-
/// i = next;
442-
/// }
443-
/// ```
444-
///
445-
/// This outputs:
446-
///
447-
/// ```text
448-
/// 18: m
449-
/// 17: a
450-
/// 16: N
451-
/// 15:
452-
/// 14: t
453-
/// 13:
454-
/// 11:
455-
/// 9: e
456-
/// 8: i
457-
/// 7: V
458-
/// 6: 华
459-
/// 3: 中
460-
/// ```
461-
#[unstable(feature = "str_char",
462-
reason = "often replaced by char_indices, this method may \
463-
be removed in favor of just char_at_reverse() or \
464-
eventually removed altogether",
465-
issue = "27754")]
466-
#[inline]
467-
#[rustc_deprecated(reason = "use slicing plus chars().rev() plus len_utf8",
468-
since = "1.9.0")]
469-
#[allow(deprecated)]
470-
pub fn char_range_at_reverse(&self, start: usize) -> CharRange {
471-
core_str::StrExt::char_range_at_reverse(self, start)
472-
}
473-
474-
/// Given a byte position, returns the `char` at that position.
475-
///
476-
/// # Panics
477-
///
478-
/// If `i` is greater than or equal to the length of the string.
479-
/// If `i` is not the index of the beginning of a valid UTF-8 sequence.
480-
///
481-
/// # Examples
482-
///
483-
/// ```
484-
/// #![feature(str_char)]
485-
/// #![allow(deprecated)]
486-
///
487-
/// let s = "abπc";
488-
/// assert_eq!(s.char_at(1), 'b');
489-
/// assert_eq!(s.char_at(2), 'π');
490-
/// assert_eq!(s.char_at(4), 'c');
491-
/// ```
492-
#[unstable(feature = "str_char",
493-
reason = "frequently replaced by the chars() iterator, this \
494-
method may be removed or possibly renamed in the \
495-
future; it is normally replaced by chars/char_indices \
496-
iterators or by getting the first char from a \
497-
subslice",
498-
issue = "27754")]
499-
#[inline]
500-
#[allow(deprecated)]
501-
#[rustc_deprecated(reason = "use slicing plus chars()",
502-
since = "1.9.0")]
503-
pub fn char_at(&self, i: usize) -> char {
504-
core_str::StrExt::char_at(self, i)
505-
}
506-
507-
/// Given a byte position, returns the `char` at that position, counting
508-
/// from the end.
509-
///
510-
/// # Panics
511-
///
512-
/// If `i` is greater than the length of the string.
513-
/// If `i` is not an index following a valid UTF-8 sequence.
514-
///
515-
/// # Examples
516-
///
517-
/// ```
518-
/// #![feature(str_char)]
519-
/// #![allow(deprecated)]
520-
///
521-
/// let s = "abπc";
522-
/// assert_eq!(s.char_at_reverse(1), 'a');
523-
/// assert_eq!(s.char_at_reverse(2), 'b');
524-
/// assert_eq!(s.char_at_reverse(3), 'π');
525-
/// ```
526-
#[unstable(feature = "str_char",
527-
reason = "see char_at for more details, but reverse semantics \
528-
are also somewhat unclear, especially with which \
529-
cases generate panics",
530-
issue = "27754")]
531-
#[inline]
532-
#[rustc_deprecated(reason = "use slicing plus chars().rev()",
533-
since = "1.9.0")]
534-
#[allow(deprecated)]
535-
pub fn char_at_reverse(&self, i: usize) -> char {
536-
core_str::StrExt::char_at_reverse(self, i)
537-
}
538-
539-
/// Retrieves the first `char` from a `&str` and returns it.
540-
///
541-
/// Note that a single Unicode character (grapheme cluster)
542-
/// can be composed of multiple `char`s.
543-
///
544-
/// This does not allocate a new string; instead, it returns a slice that
545-
/// points one code point beyond the code point that was shifted.
546-
///
547-
/// `None` is returned if the slice is empty.
548-
///
549-
/// # Examples
550-
///
551-
/// ```
552-
/// #![feature(str_char)]
553-
/// #![allow(deprecated)]
554-
///
555-
/// let s = "Łódź"; // \u{141}o\u{301}dz\u{301}
556-
/// let (c, s1) = s.slice_shift_char().unwrap();
557-
///
558-
/// assert_eq!(c, 'Ł');
559-
/// assert_eq!(s1, "ódź");
560-
///
561-
/// let (c, s2) = s1.slice_shift_char().unwrap();
562-
///
563-
/// assert_eq!(c, 'o');
564-
/// assert_eq!(s2, "\u{301}dz\u{301}");
565-
/// ```
566-
#[unstable(feature = "str_char",
567-
reason = "awaiting conventions about shifting and slices and \
568-
may not be warranted with the existence of the chars \
569-
and/or char_indices iterators",
570-
issue = "27754")]
571-
#[inline]
572-
#[rustc_deprecated(reason = "use chars() plus Chars::as_str",
573-
since = "1.9.0")]
574-
#[allow(deprecated)]
575-
pub fn slice_shift_char(&self) -> Option<(char, &str)> {
576-
core_str::StrExt::slice_shift_char(self)
577-
}
578-
579350
/// Divide one string slice into two at an index.
580351
///
581352
/// The argument, `mid`, should be a byte offset from the start of the
@@ -867,16 +638,6 @@ impl str {
867638
core_str::StrExt::lines_any(self)
868639
}
869640

870-
/// Returns an iterator of `u16` over the string encoded as UTF-16.
871-
#[unstable(feature = "str_utf16",
872-
reason = "this functionality may only be provided by libunicode",
873-
issue = "27714")]
874-
#[rustc_deprecated(since = "1.8.0", reason = "renamed to encode_utf16")]
875-
#[allow(deprecated)]
876-
pub fn utf16_units(&self) -> Utf16Units {
877-
Utf16Units { encoder: Utf16Encoder::new(self[..].chars()) }
878-
}
879-
880641
/// Returns an iterator of `u16` over the string encoded as UTF-16.
881642
#[stable(feature = "encode_utf16", since = "1.8.0")]
882643
pub fn encode_utf16(&self) -> EncodeUtf16 {

src/libcollectionstest/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
#![feature(pattern)]
2626
#![feature(rand)]
2727
#![feature(step_by)]
28-
#![feature(str_char)]
2928
#![feature(str_escape)]
3029
#![feature(test)]
3130
#![feature(unboxed_closures)]

src/libcollectionstest/str.rs

-58
Original file line numberDiff line numberDiff line change
@@ -479,20 +479,6 @@ fn test_is_whitespace() {
479479
assert!(!" _ ".chars().all(|c| c.is_whitespace()));
480480
}
481481

482-
#[test]
483-
#[allow(deprecated)]
484-
fn test_slice_shift_char() {
485-
let data = "ประเทศไทย中";
486-
assert_eq!(data.slice_shift_char(), Some(('ป', "ระเทศไทย中")));
487-
}
488-
489-
#[test]
490-
#[allow(deprecated)]
491-
fn test_slice_shift_char_2() {
492-
let empty = "";
493-
assert_eq!(empty.slice_shift_char(), None);
494-
}
495-
496482
#[test]
497483
fn test_is_utf8() {
498484
// deny overlong encodings
@@ -674,30 +660,6 @@ fn test_contains_char() {
674660
assert!(!"".contains('a'));
675661
}
676662

677-
#[test]
678-
#[allow(deprecated)]
679-
fn test_char_at() {
680-
let s = "ศไทย中华Việt Nam";
681-
let v = vec!['ศ','ไ','ท','ย','中','华','V','i','ệ','t',' ','N','a','m'];
682-
let mut pos = 0;
683-
for ch in &v {
684-
assert!(s.char_at(pos) == *ch);
685-
pos += ch.to_string().len();
686-
}
687-
}
688-
689-
#[test]
690-
#[allow(deprecated)]
691-
fn test_char_at_reverse() {
692-
let s = "ศไทย中华Việt Nam";
693-
let v = vec!['ศ','ไ','ท','ย','中','华','V','i','ệ','t',' ','N','a','m'];
694-
let mut pos = s.len();
695-
for ch in v.iter().rev() {
696-
assert!(s.char_at_reverse(pos) == *ch);
697-
pos -= ch.to_string().len();
698-
}
699-
}
700-
701663
#[test]
702664
fn test_split_at() {
703665
let s = "ศไทย中华Việt Nam";
@@ -764,26 +726,6 @@ fn test_total_ord() {
764726
assert_eq!("22".cmp("1234"), Greater);
765727
}
766728

767-
#[test]
768-
#[allow(deprecated)]
769-
fn test_char_range_at() {
770-
let data = "b¢€𤭢𤭢€¢b";
771-
assert_eq!('b', data.char_range_at(0).ch);
772-
assert_eq!('¢', data.char_range_at(1).ch);
773-
assert_eq!('€', data.char_range_at(3).ch);
774-
assert_eq!('𤭢', data.char_range_at(6).ch);
775-
assert_eq!('𤭢', data.char_range_at(10).ch);
776-
assert_eq!('€', data.char_range_at(14).ch);
777-
assert_eq!('¢', data.char_range_at(17).ch);
778-
assert_eq!('b', data.char_range_at(19).ch);
779-
}
780-
781-
#[test]
782-
#[allow(deprecated)]
783-
fn test_char_range_at_reverse_underflow() {
784-
assert_eq!("abc".char_range_at_reverse(0).next, 0);
785-
}
786-
787729
#[test]
788730
fn test_iterator() {
789731
let s = "ศไทย中华Việt Nam";

0 commit comments

Comments
 (0)