Skip to content

Commit 552eda7

Browse files
committed
std: Stabilize APIs for the 1.9 release
This commit applies all stabilizations, renamings, and deprecations that the library team has decided on for the upcoming 1.9 release. All tracking issues have gone through a cycle-long "final comment period" and the specific APIs stabilized/deprecated are: Stable * `std::panic` * `std::panic::catch_unwind` (renamed from `recover`) * `std::panic::resume_unwind` (renamed from `propagate`) * `std::panic::AssertUnwindSafe` (renamed from `AssertRecoverSafe`) * `std::panic::UnwindSafe` (renamed from `RecoverSafe`) * `str::is_char_boundary` * `<*const T>::as_ref` * `<*mut T>::as_ref` * `<*mut T>::as_mut` * `AsciiExt::make_ascii_uppercase` * `AsciiExt::make_ascii_lowercase` * `char::decode_utf16` * `char::DecodeUtf16` * `char::DecodeUtf16Error` * `char::DecodeUtf16Error::unpaired_surrogate` * `BTreeSet::take` * `BTreeSet::replace` * `BTreeSet::get` * `HashSet::take` * `HashSet::replace` * `HashSet::get` * `OsString::with_capacity` * `OsString::clear` * `OsString::capacity` * `OsString::reserve` * `OsString::reserve_exact` * `OsStr::is_empty` * `OsStr::len` * `std::os::unix::thread` * `RawPthread` * `JoinHandleExt` * `JoinHandleExt::as_pthread_t` * `JoinHandleExt::into_pthread_t` * `HashSet::hasher` * `HashMap::hasher` * `CommandExt::exec` * `File::try_clone` * `SocketAddr::set_ip` * `SocketAddr::set_port` * `SocketAddrV4::set_ip` * `SocketAddrV4::set_port` * `SocketAddrV6::set_ip` * `SocketAddrV6::set_port` * `SocketAddrV6::set_flowinfo` * `SocketAddrV6::set_scope_id` * `<[T]>::copy_from_slice` * `ptr::read_volatile` * `ptr::write_volatile` * The `#[deprecated]` attribute * `OpenOptions::create_new` Deprecated * `std::raw::Slice` - use raw parts of `slice` module instead * `std::raw::Repr` - use raw parts of `slice` module instead * `str::char_range_at` - use slicing plus `chars()` plus `len_utf8` * `str::char_range_at_reverse` - use slicing plus `chars().rev()` plus `len_utf8` * `str::char_at` - use slicing plus `chars()` * `str::char_at_reverse` - use slicing plus `chars().rev()` * `str::slice_shift_char` - use `chars()` plus `Chars::as_str` * `CommandExt::session_leader` - use `before_exec` instead. Closes rust-lang#27719 cc rust-lang#27751 (deprecating the `Slice` bits) Closes rust-lang#27754 Closes rust-lang#27780 Closes rust-lang#27809 Closes rust-lang#27811 Closes rust-lang#27830 Closes rust-lang#28050 Closes rust-lang#29453 Closes rust-lang#29791 Closes rust-lang#29935 Closes rust-lang#30014 Closes rust-lang#30752 Closes rust-lang#31262 cc rust-lang#31398 (still need to deal with `before_exec`) Closes rust-lang#31405 Closes rust-lang#31572 Closes rust-lang#31755 Closes rust-lang#31756
1 parent 8694b4f commit 552eda7

File tree

58 files changed

+508
-328
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+508
-328
lines changed

src/compiletest/compiletest.rs

+20-11
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
#![feature(box_syntax)]
1414
#![feature(libc)]
1515
#![feature(rustc_private)]
16-
#![feature(str_char)]
1716
#![feature(test)]
1817
#![feature(question_mark)]
1918

@@ -412,16 +411,26 @@ fn extract_gdb_version(full_version_line: Option<String>) -> Option<String> {
412411

413412
// used to be a regex "(^|[^0-9])([0-9]\.[0-9]+)"
414413
for (pos, c) in full_version_line.char_indices() {
415-
if !c.is_digit(10) { continue }
416-
if pos + 2 >= full_version_line.len() { continue }
417-
if full_version_line.char_at(pos + 1) != '.' { continue }
418-
if !full_version_line.char_at(pos + 2).is_digit(10) { continue }
419-
if pos > 0 && full_version_line.char_at_reverse(pos).is_digit(10) {
414+
if !c.is_digit(10) {
415+
continue
416+
}
417+
if pos + 2 >= full_version_line.len() {
418+
continue
419+
}
420+
if full_version_line[pos + 1..].chars().next().unwrap() != '.' {
421+
continue
422+
}
423+
if !full_version_line[pos + 2..].chars().next().unwrap().is_digit(10) {
424+
continue
425+
}
426+
if pos > 0 && full_version_line[..pos].chars().next_back()
427+
.unwrap().is_digit(10) {
420428
continue
421429
}
422430
let mut end = pos + 3;
423431
while end < full_version_line.len() &&
424-
full_version_line.char_at(end).is_digit(10) {
432+
full_version_line[end..].chars().next()
433+
.unwrap().is_digit(10) {
425434
end += 1;
426435
}
427436
return Some(full_version_line[pos..end].to_owned());
@@ -453,13 +462,13 @@ fn extract_lldb_version(full_version_line: Option<String>) -> Option<String> {
453462
for (pos, l) in full_version_line.char_indices() {
454463
if l != 'l' && l != 'L' { continue }
455464
if pos + 5 >= full_version_line.len() { continue }
456-
let l = full_version_line.char_at(pos + 1);
465+
let l = full_version_line[pos + 1..].chars().next().unwrap();
457466
if l != 'l' && l != 'L' { continue }
458-
let d = full_version_line.char_at(pos + 2);
467+
let d = full_version_line[pos + 2..].chars().next().unwrap();
459468
if d != 'd' && d != 'D' { continue }
460-
let b = full_version_line.char_at(pos + 3);
469+
let b = full_version_line[pos + 3..].chars().next().unwrap();
461470
if b != 'b' && b != 'B' { continue }
462-
let dash = full_version_line.char_at(pos + 4);
471+
let dash = full_version_line[pos + 4..].chars().next().unwrap();
463472
if dash != '-' { continue }
464473

465474
let vers = full_version_line[pos + 5..].chars().take_while(|c| {

src/compiletest/errors.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ fn parse_expected(last_nonfollow_error: Option<usize>,
115115
tag: &str)
116116
-> Option<(WhichLine, ExpectedError)> {
117117
let start = match line.find(tag) { Some(i) => i, None => return None };
118-
let (follow, adjusts) = if line.char_at(start + tag.len()) == '|' {
118+
let (follow, adjusts) = if line[start + tag.len()..].chars().next().unwrap() == '|' {
119119
(true, 0)
120120
} else {
121121
(false, line[start + tag.len()..].chars().take_while(|c| *c == '^').count())

src/compiletest/runtest.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1177,7 +1177,7 @@ fn scan_char(haystack: &str, needle: char, idx: &mut usize) -> bool {
11771177
if *idx >= haystack.len() {
11781178
return false;
11791179
}
1180-
let ch = haystack.char_at(*idx);
1180+
let ch = haystack[*idx..].chars().next().unwrap();
11811181
if ch != needle {
11821182
return false;
11831183
}
@@ -1188,7 +1188,7 @@ fn scan_char(haystack: &str, needle: char, idx: &mut usize) -> bool {
11881188
fn scan_integer(haystack: &str, idx: &mut usize) -> bool {
11891189
let mut i = *idx;
11901190
while i < haystack.len() {
1191-
let ch = haystack.char_at(i);
1191+
let ch = haystack[i..].chars().next().unwrap();
11921192
if ch < '0' || '9' < ch {
11931193
break;
11941194
}
@@ -1208,7 +1208,7 @@ fn scan_string(haystack: &str, needle: &str, idx: &mut usize) -> bool {
12081208
if haystack_i >= haystack.len() {
12091209
return false;
12101210
}
1211-
let ch = haystack.char_at(haystack_i);
1211+
let ch = haystack[haystack_i..].chars().next().unwrap();
12121212
haystack_i += ch.len_utf8();
12131213
if !scan_char(needle, ch, &mut needle_i) {
12141214
return false;

src/libcollections/btree/set.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ impl<T: Ord> BTreeSet<T> {
379379
/// The value may be any borrowed form of the set's value type,
380380
/// but the ordering on the borrowed form *must* match the
381381
/// ordering on the value type.
382-
#[unstable(feature = "set_recovery", issue = "28050")]
382+
#[stable(feature = "set_recovery", since = "1.9.0")]
383383
pub fn get<Q: ?Sized>(&self, value: &Q) -> Option<&T>
384384
where T: Borrow<Q>,
385385
Q: Ord
@@ -502,7 +502,7 @@ impl<T: Ord> BTreeSet<T> {
502502

503503
/// Adds a value to the set, replacing the existing value, if any, that is equal to the given
504504
/// one. Returns the replaced value.
505-
#[unstable(feature = "set_recovery", issue = "28050")]
505+
#[stable(feature = "set_recovery", since = "1.9.0")]
506506
pub fn replace(&mut self, value: T) -> Option<T> {
507507
Recover::replace(&mut self.map, value)
508508
}
@@ -538,7 +538,7 @@ impl<T: Ord> BTreeSet<T> {
538538
/// The value may be any borrowed form of the set's value type,
539539
/// but the ordering on the borrowed form *must* match the
540540
/// ordering on the value type.
541-
#[unstable(feature = "set_recovery", issue = "28050")]
541+
#[stable(feature = "set_recovery", since = "1.9.0")]
542542
pub fn take<Q: ?Sized>(&mut self, value: &Q) -> Option<T>
543543
where T: Borrow<Q>,
544544
Q: Ord

src/libcollections/lib.rs

-2
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,13 @@
2727
test(no_crate_inject, attr(allow(unused_variables), deny(warnings))))]
2828

2929
#![cfg_attr(test, allow(deprecated))] // rand
30-
#![cfg_attr(not(test), feature(copy_from_slice))] // impl [T]
3130
#![cfg_attr(not(stage0), deny(warnings))]
3231

3332
#![feature(alloc)]
3433
#![feature(allow_internal_unstable)]
3534
#![feature(box_patterns)]
3635
#![feature(box_syntax)]
3736
#![feature(core_intrinsics)]
38-
#![feature(decode_utf16)]
3937
#![feature(dropck_parametricity)]
4038
#![feature(fmt_internals)]
4139
#![feature(heap_api)]

src/libcollections/slice.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -845,14 +845,13 @@ impl<T> [T] {
845845
/// # Example
846846
///
847847
/// ```rust
848-
/// #![feature(copy_from_slice)]
849848
/// let mut dst = [0, 0, 0];
850849
/// let src = [1, 2, 3];
851850
///
852851
/// dst.copy_from_slice(&src);
853852
/// assert_eq!(src, dst);
854853
/// ```
855-
#[unstable(feature = "copy_from_slice", issue = "31755")]
854+
#[stable(feature = "copy_from_slice", since = "1.9.0")]
856855
pub fn copy_from_slice(&mut self, src: &[T]) where T: Copy {
857856
core_slice::SliceExt::copy_from_slice(self, src)
858857
}

src/libcollections/str.rs

+21-8
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,6 @@ impl str {
228228
/// # Examples
229229
///
230230
/// ```
231-
/// #![feature(str_char)]
232-
///
233231
/// let s = "Löwe 老虎 Léopard";
234232
/// assert!(s.is_char_boundary(0));
235233
/// // start of `老`
@@ -242,12 +240,7 @@ impl str {
242240
/// // third byte of `老`
243241
/// assert!(!s.is_char_boundary(8));
244242
/// ```
245-
#[unstable(feature = "str_char",
246-
reason = "it is unclear whether this method pulls its weight \
247-
with the existence of the char_indices iterator or \
248-
this method may want to be replaced with checked \
249-
slicing",
250-
issue = "27754")]
243+
#[stable(feature = "is_char_boundary", since = "1.9.0")]
251244
#[inline]
252245
pub fn is_char_boundary(&self, index: usize) -> bool {
253246
core_str::StrExt::is_char_boundary(self, index)
@@ -374,6 +367,7 @@ impl str {
374367
///
375368
/// ```
376369
/// #![feature(str_char)]
370+
/// #![allow(deprecated)]
377371
///
378372
/// use std::str::CharRange;
379373
///
@@ -408,6 +402,9 @@ impl str {
408402
removed altogether",
409403
issue = "27754")]
410404
#[inline]
405+
#[rustc_deprecated(reason = "use slicing plus chars() plus len_utf8",
406+
since = "1.9.0")]
407+
#[allow(deprecated)]
411408
pub fn char_range_at(&self, start: usize) -> CharRange {
412409
core_str::StrExt::char_range_at(self, start)
413410
}
@@ -432,6 +429,7 @@ impl str {
432429
///
433430
/// ```
434431
/// #![feature(str_char)]
432+
/// #![allow(deprecated)]
435433
///
436434
/// use std::str::CharRange;
437435
///
@@ -466,6 +464,9 @@ impl str {
466464
eventually removed altogether",
467465
issue = "27754")]
468466
#[inline]
467+
#[rustc_deprecated(reason = "use slicing plus chars().rev() plus len_utf8",
468+
since = "1.9.0")]
469+
#[allow(deprecated)]
469470
pub fn char_range_at_reverse(&self, start: usize) -> CharRange {
470471
core_str::StrExt::char_range_at_reverse(self, start)
471472
}
@@ -481,6 +482,7 @@ impl str {
481482
///
482483
/// ```
483484
/// #![feature(str_char)]
485+
/// #![allow(deprecated)]
484486
///
485487
/// let s = "abπc";
486488
/// assert_eq!(s.char_at(1), 'b');
@@ -495,6 +497,9 @@ impl str {
495497
subslice",
496498
issue = "27754")]
497499
#[inline]
500+
#[allow(deprecated)]
501+
#[rustc_deprecated(reason = "use slicing plus chars()",
502+
since = "1.9.0")]
498503
pub fn char_at(&self, i: usize) -> char {
499504
core_str::StrExt::char_at(self, i)
500505
}
@@ -511,6 +516,7 @@ impl str {
511516
///
512517
/// ```
513518
/// #![feature(str_char)]
519+
/// #![allow(deprecated)]
514520
///
515521
/// let s = "abπc";
516522
/// assert_eq!(s.char_at_reverse(1), 'a');
@@ -523,6 +529,9 @@ impl str {
523529
cases generate panics",
524530
issue = "27754")]
525531
#[inline]
532+
#[rustc_deprecated(reason = "use slicing plus chars().rev()",
533+
since = "1.9.0")]
534+
#[allow(deprecated)]
526535
pub fn char_at_reverse(&self, i: usize) -> char {
527536
core_str::StrExt::char_at_reverse(self, i)
528537
}
@@ -541,6 +550,7 @@ impl str {
541550
///
542551
/// ```
543552
/// #![feature(str_char)]
553+
/// #![allow(deprecated)]
544554
///
545555
/// let s = "Łódź"; // \u{141}o\u{301}dz\u{301}
546556
/// let (c, s1) = s.slice_shift_char().unwrap();
@@ -559,6 +569,9 @@ impl str {
559569
and/or char_indices iterators",
560570
issue = "27754")]
561571
#[inline]
572+
#[rustc_deprecated(reason = "use chars() plus Chars::as_str",
573+
since = "1.9.0")]
574+
#[allow(deprecated)]
562575
pub fn slice_shift_char(&self) -> Option<(char, &str)> {
563576
core_str::StrExt::slice_shift_char(self)
564577
}

src/libcollections/string.rs

+11-10
Original file line numberDiff line numberDiff line change
@@ -1037,14 +1037,13 @@ impl String {
10371037
#[inline]
10381038
#[stable(feature = "rust1", since = "1.0.0")]
10391039
pub fn pop(&mut self) -> Option<char> {
1040-
let len = self.len();
1041-
if len == 0 {
1042-
return None;
1043-
}
1044-
1045-
let ch = self.char_at_reverse(len);
1040+
let ch = match self.chars().rev().next() {
1041+
Some(ch) => ch,
1042+
None => return None,
1043+
};
1044+
let newlen = self.len() - ch.len_utf8();
10461045
unsafe {
1047-
self.vec.set_len(len - ch.len_utf8());
1046+
self.vec.set_len(newlen);
10481047
}
10491048
Some(ch)
10501049
}
@@ -1075,11 +1074,13 @@ impl String {
10751074
#[inline]
10761075
#[stable(feature = "rust1", since = "1.0.0")]
10771076
pub fn remove(&mut self, idx: usize) -> char {
1078-
let len = self.len();
1079-
assert!(idx < len);
1077+
let ch = match self[idx..].chars().next() {
1078+
Some(ch) => ch,
1079+
None => panic!("cannot remove a char from the end of a string"),
1080+
};
10801081

1081-
let ch = self.char_at(idx);
10821082
let next = idx + ch.len_utf8();
1083+
let len = self.len();
10831084
unsafe {
10841085
ptr::copy(self.vec.as_ptr().offset(next as isize),
10851086
self.vec.as_mut_ptr().offset(idx as isize),

src/libcollectionstest/lib.rs

-3
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,11 @@
1010

1111
#![deny(warnings)]
1212

13-
#![feature(ascii)]
1413
#![feature(binary_heap_extras)]
1514
#![feature(box_syntax)]
1615
#![feature(btree_range)]
1716
#![feature(collections)]
1817
#![feature(collections_bound)]
19-
#![feature(copy_from_slice)]
2018
#![feature(const_fn)]
2119
#![feature(fn_traits)]
2220
#![feature(enumset)]
@@ -25,7 +23,6 @@
2523
#![feature(map_values_mut)]
2624
#![feature(pattern)]
2725
#![feature(rand)]
28-
#![feature(set_recovery)]
2926
#![feature(step_by)]
3027
#![feature(str_char)]
3128
#![feature(str_escape)]

src/libcollectionstest/str.rs

+6
Original file line numberDiff line numberDiff line change
@@ -464,12 +464,14 @@ fn test_is_whitespace() {
464464
}
465465

466466
#[test]
467+
#[allow(deprecated)]
467468
fn test_slice_shift_char() {
468469
let data = "ประเทศไทย中";
469470
assert_eq!(data.slice_shift_char(), Some(('ป', "ระเทศไทย中")));
470471
}
471472

472473
#[test]
474+
#[allow(deprecated)]
473475
fn test_slice_shift_char_2() {
474476
let empty = "";
475477
assert_eq!(empty.slice_shift_char(), None);
@@ -657,6 +659,7 @@ fn test_contains_char() {
657659
}
658660

659661
#[test]
662+
#[allow(deprecated)]
660663
fn test_char_at() {
661664
let s = "ศไทย中华Việt Nam";
662665
let v = vec!['ศ','ไ','ท','ย','中','华','V','i','ệ','t',' ','N','a','m'];
@@ -668,6 +671,7 @@ fn test_char_at() {
668671
}
669672

670673
#[test]
674+
#[allow(deprecated)]
671675
fn test_char_at_reverse() {
672676
let s = "ศไทย中华Việt Nam";
673677
let v = vec!['ศ','ไ','ท','ย','中','华','V','i','ệ','t',' ','N','a','m'];
@@ -745,6 +749,7 @@ fn test_total_ord() {
745749
}
746750

747751
#[test]
752+
#[allow(deprecated)]
748753
fn test_char_range_at() {
749754
let data = "b¢€𤭢𤭢€¢b";
750755
assert_eq!('b', data.char_range_at(0).ch);
@@ -758,6 +763,7 @@ fn test_char_range_at() {
758763
}
759764

760765
#[test]
766+
#[allow(deprecated)]
761767
fn test_char_range_at_reverse_underflow() {
762768
assert_eq!("abc".char_range_at_reverse(0).next, 0);
763769
}

0 commit comments

Comments
 (0)