diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2016-05-24 14:24:44 -0700 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2016-05-30 20:46:32 -0700 |
| commit | b64c9d56700e2c41207166fe8709711ff02488ff (patch) | |
| tree | 82e982ea6a6840e3f0f4d3d82a4d2ad24771200b /src | |
| parent | a967611d8ffececb5ed0ecf6a205b464d7a5a31e (diff) | |
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.
Diffstat (limited to 'src')
29 files changed, 52 insertions, 1212 deletions
diff --git a/src/libcollections/str.rs b/src/libcollections/str.rs index f3770816cb6..d7c11f32404 100644 --- a/src/libcollections/str.rs +++ b/src/libcollections/str.rs @@ -112,11 +112,6 @@ impl<S: Borrow<str>> SliceConcatExt<str> for [S] { } } -/// Deprecated, renamed to EncodeUtf16 -#[unstable(feature = "str_utf16", issue = "27714")] -#[rustc_deprecated(since = "1.8.0", reason = "renamed to EncodeUtf16")] -pub type Utf16Units<'a> = EncodeUtf16<'a>; - /// External iterator for a string's UTF-16 code units. /// /// For use with the `std::iter` module. @@ -352,230 +347,6 @@ impl str { core_str::StrExt::slice_mut_unchecked(self, begin, end) } - /// Given a byte position, returns the next `char` and its index. - /// - /// # Panics - /// - /// If `i` is greater than or equal to the length of the string. - /// If `i` is not the index of the beginning of a valid UTF-8 sequence. - /// - /// # Examples - /// - /// This example manually iterates through the code points of a string; - /// this should normally be - /// done by `.chars()` or `.char_indices()`. - /// - /// ``` - /// #![feature(str_char)] - /// #![allow(deprecated)] - /// - /// use std::str::CharRange; - /// - /// let s = "中华Việt Nam"; - /// let mut i = 0; - /// while i < s.len() { - /// let CharRange {ch, next} = s.char_range_at(i); - /// println!("{}: {}", i, ch); - /// i = next; - /// } - /// ``` - /// - /// This outputs: - /// - /// ```text - /// 0: 中 - /// 3: 华 - /// 6: V - /// 7: i - /// 8: e - /// 9: - /// 11: - /// 13: t - /// 14: - /// 15: N - /// 16: a - /// 17: m - /// ``` - #[unstable(feature = "str_char", - reason = "often replaced by char_indices, this method may \ - be removed in favor of just char_at() or eventually \ - removed altogether", - issue = "27754")] - #[inline] - #[rustc_deprecated(reason = "use slicing plus chars() plus len_utf8", - since = "1.9.0")] - #[allow(deprecated)] - pub fn char_range_at(&self, start: usize) -> CharRange { - core_str::StrExt::char_range_at(self, start) - } - - /// Given a byte position, returns the previous `char` and its position. - /// - /// Note that Unicode has many features, such as combining marks, ligatures, - /// and direction marks, that need to be taken into account to correctly reverse a string. - /// - /// Returns 0 for next index if called on start index 0. - /// - /// # Panics - /// - /// If `i` is greater than the length of the string. - /// If `i` is not an index following a valid UTF-8 sequence. - /// - /// # Examples - /// - /// This example manually iterates through the code points of a string; - /// this should normally be - /// done by `.chars().rev()` or `.char_indices()`. - /// - /// ``` - /// #![feature(str_char)] - /// #![allow(deprecated)] - /// - /// use std::str::CharRange; - /// - /// let s = "中华Việt Nam"; - /// let mut i = s.len(); - /// while i > 0 { - /// let CharRange {ch, next} = s.char_range_at_reverse(i); - /// println!("{}: {}", i, ch); - /// i = next; - /// } - /// ``` - /// - /// This outputs: - /// - /// ```text - /// 18: m - /// 17: a - /// 16: N - /// 15: - /// 14: t - /// 13: - /// 11: - /// 9: e - /// 8: i - /// 7: V - /// 6: 华 - /// 3: 中 - /// ``` - #[unstable(feature = "str_char", - reason = "often replaced by char_indices, this method may \ - be removed in favor of just char_at_reverse() or \ - eventually removed altogether", - issue = "27754")] - #[inline] - #[rustc_deprecated(reason = "use slicing plus chars().rev() plus len_utf8", - since = "1.9.0")] - #[allow(deprecated)] - pub fn char_range_at_reverse(&self, start: usize) -> CharRange { - core_str::StrExt::char_range_at_reverse(self, start) - } - - /// Given a byte position, returns the `char` at that position. - /// - /// # Panics - /// - /// If `i` is greater than or equal to the length of the string. - /// If `i` is not the index of the beginning of a valid UTF-8 sequence. - /// - /// # Examples - /// - /// ``` - /// #![feature(str_char)] - /// #![allow(deprecated)] - /// - /// let s = "abπc"; - /// assert_eq!(s.char_at(1), 'b'); - /// assert_eq!(s.char_at(2), 'π'); - /// assert_eq!(s.char_at(4), 'c'); - /// ``` - #[unstable(feature = "str_char", - reason = "frequently replaced by the chars() iterator, this \ - method may be removed or possibly renamed in the \ - future; it is normally replaced by chars/char_indices \ - iterators or by getting the first char from a \ - subslice", - issue = "27754")] - #[inline] - #[allow(deprecated)] - #[rustc_deprecated(reason = "use slicing plus chars()", - since = "1.9.0")] - pub fn char_at(&self, i: usize) -> char { - core_str::StrExt::char_at(self, i) - } - - /// Given a byte position, returns the `char` at that position, counting - /// from the end. - /// - /// # Panics - /// - /// If `i` is greater than the length of the string. - /// If `i` is not an index following a valid UTF-8 sequence. - /// - /// # Examples - /// - /// ``` - /// #![feature(str_char)] - /// #![allow(deprecated)] - /// - /// let s = "abπc"; - /// assert_eq!(s.char_at_reverse(1), 'a'); - /// assert_eq!(s.char_at_reverse(2), 'b'); - /// assert_eq!(s.char_at_reverse(3), 'π'); - /// ``` - #[unstable(feature = "str_char", - reason = "see char_at for more details, but reverse semantics \ - are also somewhat unclear, especially with which \ - cases generate panics", - issue = "27754")] - #[inline] - #[rustc_deprecated(reason = "use slicing plus chars().rev()", - since = "1.9.0")] - #[allow(deprecated)] - pub fn char_at_reverse(&self, i: usize) -> char { - core_str::StrExt::char_at_reverse(self, i) - } - - /// Retrieves the first `char` from a `&str` and returns it. - /// - /// Note that a single Unicode character (grapheme cluster) - /// can be composed of multiple `char`s. - /// - /// This does not allocate a new string; instead, it returns a slice that - /// points one code point beyond the code point that was shifted. - /// - /// `None` is returned if the slice is empty. - /// - /// # Examples - /// - /// ``` - /// #![feature(str_char)] - /// #![allow(deprecated)] - /// - /// let s = "Łódź"; // \u{141}o\u{301}dz\u{301} - /// let (c, s1) = s.slice_shift_char().unwrap(); - /// - /// assert_eq!(c, 'Ł'); - /// assert_eq!(s1, "ódź"); - /// - /// let (c, s2) = s1.slice_shift_char().unwrap(); - /// - /// assert_eq!(c, 'o'); - /// assert_eq!(s2, "\u{301}dz\u{301}"); - /// ``` - #[unstable(feature = "str_char", - reason = "awaiting conventions about shifting and slices and \ - may not be warranted with the existence of the chars \ - and/or char_indices iterators", - issue = "27754")] - #[inline] - #[rustc_deprecated(reason = "use chars() plus Chars::as_str", - since = "1.9.0")] - #[allow(deprecated)] - pub fn slice_shift_char(&self) -> Option<(char, &str)> { - core_str::StrExt::slice_shift_char(self) - } - /// Divide one string slice into two at an index. /// /// The argument, `mid`, should be a byte offset from the start of the @@ -868,16 +639,6 @@ impl str { } /// Returns an iterator of `u16` over the string encoded as UTF-16. - #[unstable(feature = "str_utf16", - reason = "this functionality may only be provided by libunicode", - issue = "27714")] - #[rustc_deprecated(since = "1.8.0", reason = "renamed to encode_utf16")] - #[allow(deprecated)] - pub fn utf16_units(&self) -> Utf16Units { - Utf16Units { encoder: Utf16Encoder::new(self[..].chars()) } - } - - /// Returns an iterator of `u16` over the string encoded as UTF-16. #[stable(feature = "encode_utf16", since = "1.8.0")] pub fn encode_utf16(&self) -> EncodeUtf16 { EncodeUtf16 { encoder: Utf16Encoder::new(self[..].chars()) } diff --git a/src/libcollectionstest/lib.rs b/src/libcollectionstest/lib.rs index bae21f1bd9b..e9754bc98aa 100644 --- a/src/libcollectionstest/lib.rs +++ b/src/libcollectionstest/lib.rs @@ -25,7 +25,6 @@ #![feature(pattern)] #![feature(rand)] #![feature(step_by)] -#![feature(str_char)] #![feature(str_escape)] #![feature(test)] #![feature(unboxed_closures)] diff --git a/src/libcollectionstest/str.rs b/src/libcollectionstest/str.rs index a1820a1cb96..124b85bfca8 100644 --- a/src/libcollectionstest/str.rs +++ b/src/libcollectionstest/str.rs @@ -480,20 +480,6 @@ fn test_is_whitespace() { } #[test] -#[allow(deprecated)] -fn test_slice_shift_char() { - let data = "ประเทศไทย中"; - assert_eq!(data.slice_shift_char(), Some(('ป', "ระเทศไทย中"))); -} - -#[test] -#[allow(deprecated)] -fn test_slice_shift_char_2() { - let empty = ""; - assert_eq!(empty.slice_shift_char(), None); -} - -#[test] fn test_is_utf8() { // deny overlong encodings assert!(from_utf8(&[0xc0, 0x80]).is_err()); @@ -675,30 +661,6 @@ fn test_contains_char() { } #[test] -#[allow(deprecated)] -fn test_char_at() { - let s = "ศไทย中华Việt Nam"; - let v = vec!['ศ','ไ','ท','ย','中','华','V','i','ệ','t',' ','N','a','m']; - let mut pos = 0; - for ch in &v { - assert!(s.char_at(pos) == *ch); - pos += ch.to_string().len(); - } -} - -#[test] -#[allow(deprecated)] -fn test_char_at_reverse() { - let s = "ศไทย中华Việt Nam"; - let v = vec!['ศ','ไ','ท','ย','中','华','V','i','ệ','t',' ','N','a','m']; - let mut pos = s.len(); - for ch in v.iter().rev() { - assert!(s.char_at_reverse(pos) == *ch); - pos -= ch.to_string().len(); - } -} - -#[test] fn test_split_at() { let s = "ศไทย中华Việt Nam"; for (index, _) in s.char_indices() { @@ -765,26 +727,6 @@ fn test_total_ord() { } #[test] -#[allow(deprecated)] -fn test_char_range_at() { - let data = "b¢€𤭢𤭢€¢b"; - assert_eq!('b', data.char_range_at(0).ch); - assert_eq!('¢', data.char_range_at(1).ch); - assert_eq!('€', data.char_range_at(3).ch); - assert_eq!('𤭢', data.char_range_at(6).ch); - assert_eq!('𤭢', data.char_range_at(10).ch); - assert_eq!('€', data.char_range_at(14).ch); - assert_eq!('¢', data.char_range_at(17).ch); - assert_eq!('b', data.char_range_at(19).ch); -} - -#[test] -#[allow(deprecated)] -fn test_char_range_at_reverse_underflow() { - assert_eq!("abc".char_range_at_reverse(0).next, 0); -} - -#[test] fn test_iterator() { let s = "ศไทย中华Việt Nam"; let v = ['ศ','ไ','ท','ย','中','华','V','i','ệ','t',' ','N','a','m']; diff --git a/src/libcore/cell.rs b/src/libcore/cell.rs index 4929088201d..684c90d6ae6 100644 --- a/src/libcore/cell.rs +++ b/src/libcore/cell.rs @@ -692,40 +692,6 @@ impl<'b, T: ?Sized> Ref<'b, T> { borrow: orig.borrow, } } - - /// Make a new `Ref` for an optional component of the borrowed data, e.g. an - /// enum variant. - /// - /// The `RefCell` is already immutably borrowed, so this cannot fail. - /// - /// This is an associated function that needs to be used as - /// `Ref::filter_map(...)`. A method would interfere with methods of the - /// same name on the contents of a `RefCell` used through `Deref`. - /// - /// # Example - /// - /// ``` - /// # #![feature(cell_extras)] - /// use std::cell::{RefCell, Ref}; - /// - /// let c = RefCell::new(Ok(5)); - /// let b1: Ref<Result<u32, ()>> = c.borrow(); - /// let b2: Ref<u32> = Ref::filter_map(b1, |o| o.as_ref().ok()).unwrap(); - /// assert_eq!(*b2, 5) - /// ``` - #[unstable(feature = "cell_extras", reason = "recently added", - issue = "27746")] - #[rustc_deprecated(since = "1.8.0", reason = "can be built on `Ref::map`: \ - https://crates.io/crates/ref_filter_map")] - #[inline] - pub fn filter_map<U: ?Sized, F>(orig: Ref<'b, T>, f: F) -> Option<Ref<'b, U>> - where F: FnOnce(&T) -> Option<&U> - { - f(orig.value).map(move |new| Ref { - value: new, - borrow: orig.borrow, - }) - } } #[unstable(feature = "coerce_unsized", issue = "27732")] @@ -765,47 +731,6 @@ impl<'b, T: ?Sized> RefMut<'b, T> { borrow: orig.borrow, } } - - /// Make a new `RefMut` for an optional component of the borrowed data, e.g. - /// an enum variant. - /// - /// The `RefCell` is already mutably borrowed, so this cannot fail. - /// - /// This is an associated function that needs to be used as - /// `RefMut::filter_map(...)`. A method would interfere with methods of the - /// same name on the contents of a `RefCell` used through `Deref`. - /// - /// # Example - /// - /// ``` - /// # #![feature(cell_extras)] - /// use std::cell::{RefCell, RefMut}; - /// - /// let c = RefCell::new(Ok(5)); - /// { - /// let b1: RefMut<Result<u32, ()>> = c.borrow_mut(); - /// let mut b2: RefMut<u32> = RefMut::filter_map(b1, |o| { - /// o.as_mut().ok() - /// }).unwrap(); - /// assert_eq!(*b2, 5); - /// *b2 = 42; - /// } - /// assert_eq!(*c.borrow(), Ok(42)); - /// ``` - #[unstable(feature = "cell_extras", reason = "recently added", - issue = "27746")] - #[rustc_deprecated(since = "1.8.0", reason = "can be built on `RefMut::map`: \ - https://crates.io/crates/ref_filter_map")] - #[inline] - pub fn filter_map<U: ?Sized, F>(orig: RefMut<'b, T>, f: F) -> Option<RefMut<'b, U>> - where F: FnOnce(&mut T) -> Option<&mut U> - { - let RefMut { value, borrow } = orig; - f(value).map(move |new| RefMut { - value: new, - borrow: borrow, - }) - } } struct BorrowRefMut<'b> { diff --git a/src/libcore/raw.rs b/src/libcore/raw.rs index 19226d81f16..6b2122451db 100644 --- a/src/libcore/raw.rs +++ b/src/libcore/raw.rs @@ -18,63 +18,6 @@ //! //! Their definition should always match the ABI defined in `rustc::back::abi`. -use clone::Clone; -use marker::Copy; -use mem; - -/// The representation of a slice like `&[T]`. -/// -/// This struct is guaranteed to have the layout of types like `&[T]`, -/// `&str`, and `Box<[T]>`, but is not the type of such slices -/// (e.g. the fields are not directly accessible on a `&[T]`) nor does -/// it control that layout (changing the definition will not change -/// the layout of a `&[T]`). It is only designed to be used by unsafe -/// code that needs to manipulate the low-level details. -/// -/// However, it is not recommended to use this type for such code, -/// since there are alternatives which may be safer: -/// -/// - Creating a slice from a data pointer and length can be done with -/// `std::slice::from_raw_parts` or `std::slice::from_raw_parts_mut` -/// instead of `std::mem::transmute`ing a value of type `Slice`. -/// - Extracting the data pointer and length from a slice can be -/// performed with the `as_ptr` (or `as_mut_ptr`) and `len` -/// methods. -/// -/// If one does decide to convert a slice value to a `Slice`, the -/// `Repr` trait in this module provides a method for a safe -/// conversion from `&[T]` (and `&str`) to a `Slice`, more type-safe -/// than a call to `transmute`. -/// -/// # Examples -/// -/// ``` -/// #![feature(raw)] -/// -/// use std::raw::{self, Repr}; -/// -/// let slice: &[u16] = &[1, 2, 3, 4]; -/// -/// let repr: raw::Slice<u16> = slice.repr(); -/// println!("data pointer = {:?}, length = {}", repr.data, repr.len); -/// ``` -#[repr(C)] -#[allow(missing_debug_implementations)] -#[rustc_deprecated(reason = "use raw accessors/constructors in `slice` module", - since = "1.9.0")] -#[unstable(feature = "raw", issue = "27751")] -pub struct Slice<T> { - pub data: *const T, - pub len: usize, -} - -#[allow(deprecated)] -impl<T> Copy for Slice<T> {} -#[allow(deprecated)] -impl<T> Clone for Slice<T> { - fn clone(&self) -> Slice<T> { *self } -} - /// The representation of a trait object like `&SomeTrait`. /// /// This struct has the same layout as types like `&SomeTrait` and @@ -154,22 +97,3 @@ pub struct TraitObject { pub data: *mut (), pub vtable: *mut (), } - -/// This trait is meant to map equivalences between raw structs and their -/// corresponding rust values. -#[rustc_deprecated(reason = "use raw accessors/constructors in `slice` module", - since = "1.9.0")] -#[unstable(feature = "raw", issue = "27751")] -pub unsafe trait Repr<T> { - /// This function "unwraps" a rust value (without consuming it) into its raw - /// struct representation. This can be used to read/write different values - /// for the struct. This is a safe method because by default it does not - /// enable write-access to the fields of the return value in safe code. - #[inline] - fn repr(&self) -> T { unsafe { mem::transmute_copy(&self) } } -} - -#[allow(deprecated)] -unsafe impl<T> Repr<Slice<T>> for [T] {} -#[allow(deprecated)] -unsafe impl Repr<Slice<u8>> for str {} diff --git a/src/libcore/str/mod.rs b/src/libcore/str/mod.rs index 2c34caf63b8..0e57068a616 100644 --- a/src/libcore/str/mod.rs +++ b/src/libcore/str/mod.rs @@ -17,7 +17,7 @@ use self::pattern::Pattern; use self::pattern::{Searcher, ReverseSearcher, DoubleEndedSearcher}; -use char::{self, CharExt}; +use char; use clone::Clone; use convert::AsRef; use default::Default; @@ -1663,40 +1663,6 @@ pub trait StrExt { where P::Searcher: ReverseSearcher<'a>; #[stable(feature = "is_char_boundary", since = "1.9.0")] fn is_char_boundary(&self, index: usize) -> bool; - #[unstable(feature = "str_char", - reason = "often replaced by char_indices, this method may \ - be removed in favor of just char_at() or eventually \ - removed altogether", - issue = "27754")] - #[rustc_deprecated(reason = "use slicing plus chars() plus len_utf8", - since = "1.9.0")] - fn char_range_at(&self, start: usize) -> CharRange; - #[unstable(feature = "str_char", - reason = "often replaced by char_indices, this method may \ - be removed in favor of just char_at_reverse() or \ - eventually removed altogether", - issue = "27754")] - #[rustc_deprecated(reason = "use slicing plus chars().rev() plus len_utf8", - since = "1.9.0")] - fn char_range_at_reverse(&self, start: usize) -> CharRange; - #[unstable(feature = "str_char", - reason = "frequently replaced by the chars() iterator, this \ - method may be removed or possibly renamed in the \ - future; it is normally replaced by chars/char_indices \ - iterators or by getting the first char from a \ - subslice", - issue = "27754")] - #[rustc_deprecated(reason = "use slicing plus chars()", - since = "1.9.0")] - fn char_at(&self, i: usize) -> char; - #[unstable(feature = "str_char", - reason = "see char_at for more details, but reverse semantics \ - are also somewhat unclear, especially with which \ - cases generate panics", - issue = "27754")] - #[rustc_deprecated(reason = "use slicing plus chars().rev()", - since = "1.9.0")] - fn char_at_reverse(&self, i: usize) -> char; #[stable(feature = "core", since = "1.6.0")] fn as_bytes(&self) -> &[u8]; #[stable(feature = "core", since = "1.6.0")] @@ -1709,14 +1675,6 @@ pub trait StrExt { fn split_at(&self, mid: usize) -> (&str, &str); #[stable(feature = "core", since = "1.6.0")] fn split_at_mut(&mut self, mid: usize) -> (&mut str, &mut str); - #[unstable(feature = "str_char", - reason = "awaiting conventions about shifting and slices and \ - may not be warranted with the existence of the chars \ - and/or char_indices iterators", - issue = "27754")] - #[rustc_deprecated(reason = "use chars() plus Chars::as_str", - since = "1.9.0")] - fn slice_shift_char(&self) -> Option<(char, &str)>; #[stable(feature = "core", since = "1.6.0")] fn as_ptr(&self) -> *const u8; #[stable(feature = "core", since = "1.6.0")] @@ -1946,55 +1904,6 @@ impl StrExt for str { } #[inline] - fn char_range_at(&self, i: usize) -> CharRange { - let (c, n) = char_range_at_raw(self.as_bytes(), i); - CharRange { ch: unsafe { char::from_u32_unchecked(c) }, next: n } - } - - #[inline] - fn char_range_at_reverse(&self, start: usize) -> CharRange { - let mut prev = start; - - prev = prev.saturating_sub(1); - if self.as_bytes()[prev] < 128 { - return CharRange{ch: self.as_bytes()[prev] as char, next: prev} - } - - // Multibyte case is a fn to allow char_range_at_reverse to inline cleanly - fn multibyte_char_range_at_reverse(s: &str, mut i: usize) -> CharRange { - // while there is a previous byte == 10...... - while i > 0 && s.as_bytes()[i] & !CONT_MASK == TAG_CONT_U8 { - i -= 1; - } - - let first= s.as_bytes()[i]; - let w = UTF8_CHAR_WIDTH[first as usize]; - assert!(w != 0); - - let mut val = utf8_first_byte(first, w as u32); - val = utf8_acc_cont_byte(val, s.as_bytes()[i + 1]); - if w > 2 { val = utf8_acc_cont_byte(val, s.as_bytes()[i + 2]); } - if w > 3 { val = utf8_acc_cont_byte(val, s.as_bytes()[i + 3]); } - - CharRange {ch: unsafe { char::from_u32_unchecked(val) }, next: i} - } - - multibyte_char_range_at_reverse(self, prev) - } - - #[inline] - #[allow(deprecated)] - fn char_at(&self, i: usize) -> char { - self.char_range_at(i).ch - } - - #[inline] - #[allow(deprecated)] - fn char_at_reverse(&self, i: usize) -> char { - self.char_range_at_reverse(i).ch - } - - #[inline] fn as_bytes(&self) -> &[u8] { unsafe { mem::transmute(self) } } @@ -2041,18 +1950,6 @@ impl StrExt for str { } #[inline] - #[allow(deprecated)] - fn slice_shift_char(&self) -> Option<(char, &str)> { - if self.is_empty() { - None - } else { - let ch = self.char_at(0); - let next_s = unsafe { self.slice_unchecked(ch.len_utf8(), self.len()) }; - Some((ch, next_s)) - } - } - - #[inline] fn as_ptr(&self) -> *const u8 { self as *const str as *const u8 } @@ -2077,31 +1974,6 @@ impl AsRef<[u8]> for str { } } -/// Pluck a code point out of a UTF-8-like byte slice and return the -/// index of the next code point. -#[inline] -fn char_range_at_raw(bytes: &[u8], i: usize) -> (u32, usize) { - if bytes[i] < 128 { - return (bytes[i] as u32, i + 1); - } - - // Multibyte case is a fn to allow char_range_at to inline cleanly - fn multibyte_char_range_at(bytes: &[u8], i: usize) -> (u32, usize) { - let first = bytes[i]; - let w = UTF8_CHAR_WIDTH[first as usize]; - assert!(w != 0); - - let mut val = utf8_first_byte(first, w as u32); - val = utf8_acc_cont_byte(val, bytes[i + 1]); - if w > 2 { val = utf8_acc_cont_byte(val, bytes[i + 2]); } - if w > 3 { val = utf8_acc_cont_byte(val, bytes[i + 3]); } - - (val, i + w as usize) - } - - multibyte_char_range_at(bytes, i) -} - #[stable(feature = "rust1", since = "1.0.0")] impl<'a> Default for &'a str { fn default() -> &'a str { "" } diff --git a/src/libcoretest/cell.rs b/src/libcoretest/cell.rs index c0b22274ee9..a635620d12a 100644 --- a/src/libcoretest/cell.rs +++ b/src/libcoretest/cell.rs @@ -159,20 +159,6 @@ fn ref_map_accessor() { } #[test] -#[allow(deprecated)] -fn ref_filter_map_accessor() { - struct X(RefCell<Result<u32, ()>>); - impl X { - fn accessor(&self) -> Option<Ref<u32>> { - Ref::filter_map(self.0.borrow(), |r| r.as_ref().ok()) - } - } - let x = X(RefCell::new(Ok(7))); - let d: Ref<u32> = x.accessor().unwrap(); - assert_eq!(*d, 7); -} - -#[test] fn ref_mut_map_accessor() { struct X(RefCell<(u32, char)>); impl X { @@ -190,24 +176,6 @@ fn ref_mut_map_accessor() { } #[test] -#[allow(deprecated)] -fn ref_mut_filter_map_accessor() { - struct X(RefCell<Result<u32, ()>>); - impl X { - fn accessor(&self) -> Option<RefMut<u32>> { - RefMut::filter_map(self.0.borrow_mut(), |r| r.as_mut().ok()) - } - } - let x = X(RefCell::new(Ok(7))); - { - let mut d: RefMut<u32> = x.accessor().unwrap(); - assert_eq!(*d, 7); - *d += 1; - } - assert_eq!(*x.0.borrow(), Ok(8)); -} - -#[test] fn as_unsafe_cell() { let c1: Cell<usize> = Cell::new(0); c1.set(1); diff --git a/src/libstd/panic.rs b/src/libstd/panic.rs index 016130e9998..d8cadf09cb2 100644 --- a/src/libstd/panic.rs +++ b/src/libstd/panic.rs @@ -25,21 +25,7 @@ use thread::Result; #[stable(feature = "panic_hooks", since = "1.10.0")] pub use panicking::{take_hook, set_hook, PanicInfo, Location}; -/// -#[rustc_deprecated(since = "1.9.0", reason = "renamed to set_hook")] -#[unstable(feature = "panic_handler", reason = "awaiting feedback", issue = "30449")] -pub fn set_handler<F>(handler: F) where F: Fn(&PanicInfo) + 'static + Sync + Send { - set_hook(Box::new(handler)) -} - -/// -#[rustc_deprecated(since = "1.9.0", reason = "renamed to take_hook")] -#[unstable(feature = "panic_handler", reason = "awaiting feedback", issue = "30449")] -pub fn take_handler() -> Box<Fn(&PanicInfo) + 'static + Sync + Send> { - take_hook() -} - -/// A marker trait which represents "unwind safe" types in Rust. +/// A marker trait which represents "panic safe" types in Rust. /// /// This trait is implemented by default for many types and behaves similarly in /// terms of inference of implementation to the `Send` and `Sync` traits. The @@ -117,14 +103,6 @@ pub fn take_handler() -> Box<Fn(&PanicInfo) + 'static + Sync + Send> { across an unwind boundary"] pub trait UnwindSafe {} -/// Deprecated, renamed to UnwindSafe -#[unstable(feature = "recover", reason = "awaiting feedback", issue = "27719")] -#[rustc_deprecated(reason = "renamed to `UnwindSafe`", since = "1.9.0")] -pub trait RecoverSafe {} -#[unstable(feature = "recover", reason = "awaiting feedback", issue = "27719")] -#[allow(deprecated)] -impl<T: UnwindSafe> RecoverSafe for T {} - /// A marker trait representing types where a shared reference is considered /// unwind safe. /// @@ -202,11 +180,6 @@ pub struct AssertUnwindSafe<T>( pub T ); -/// Deprecated, renamed to `AssertUnwindSafe` -#[unstable(feature = "recover", issue = "27719")] -#[rustc_deprecated(reason = "renamed to `AssertUnwindSafe`", since = "1.9.0")] -pub struct AssertRecoverSafe<T>(pub T); - // Implementations of the `UnwindSafe` trait: // // * By default everything is unwind safe @@ -234,9 +207,6 @@ impl<T: ?Sized> UnwindSafe for Mutex<T> {} impl<T: ?Sized> UnwindSafe for RwLock<T> {} #[stable(feature = "catch_unwind", since = "1.9.0")] impl<T> UnwindSafe for AssertUnwindSafe<T> {} -#[unstable(feature = "recover", issue = "27719")] -#[allow(deprecated)] -impl<T> UnwindSafe for AssertRecoverSafe<T> {} // not covered via the Shared impl above b/c the inner contents use // Cell/AtomicUsize, but the usage here is unwind safe so we can lift the @@ -256,9 +226,6 @@ impl RefUnwindSafe for .. {} impl<T: ?Sized> !RefUnwindSafe for UnsafeCell<T> {} #[stable(feature = "catch_unwind", since = "1.9.0")] impl<T> RefUnwindSafe for AssertUnwindSafe<T> {} -#[unstable(feature = "recover", issue = "27719")] -#[allow(deprecated)] -impl<T> RefUnwindSafe for AssertRecoverSafe<T> {} #[stable(feature = "catch_unwind", since = "1.9.0")] impl<T> Deref for AssertUnwindSafe<T> { @@ -285,53 +252,6 @@ impl<R, F: FnOnce() -> R> FnOnce<()> for AssertUnwindSafe<F> { } } -#[allow(deprecated)] -impl<T> AssertRecoverSafe<T> { - /// Creates a new `AssertRecoverSafe` wrapper around the provided type. - #[unstable(feature = "recover", reason = "awaiting feedback", issue = "27719")] - #[rustc_deprecated(reason = "the type's field is now public, construct it directly", - since = "1.9.0")] - pub fn new(t: T) -> AssertRecoverSafe<T> { - AssertRecoverSafe(t) - } - - /// Consumes the `AssertRecoverSafe`, returning the wrapped value. - #[unstable(feature = "recover", reason = "awaiting feedback", issue = "27719")] - #[rustc_deprecated(reason = "the type's field is now public, access it directly", - since = "1.9.0")] - pub fn into_inner(self) -> T { - self.0 - } -} - -#[unstable(feature = "recover", issue = "27719")] -#[allow(deprecated)] -impl<T> Deref for AssertRecoverSafe<T> { - type Target = T; - - fn deref(&self) -> &T { - &self.0 - } -} - -#[unstable(feature = "recover", issue = "27719")] -#[allow(deprecated)] -impl<T> DerefMut for AssertRecoverSafe<T> { - fn deref_mut(&mut self) -> &mut T { - &mut self.0 - } -} - -#[unstable(feature = "recover", issue = "27719")] -#[allow(deprecated)] -impl<R, F: FnOnce() -> R> FnOnce<()> for AssertRecoverSafe<F> { - type Output = R; - - extern "rust-call" fn call_once(self, _args: ()) -> R { - (self.0)() - } -} - /// Invokes a closure, capturing the cause of an unwinding panic if one occurs. /// /// This function will return `Ok` with the closure's result if the closure @@ -388,13 +308,6 @@ pub fn catch_unwind<F: FnOnce() -> R + UnwindSafe, R>(f: F) -> Result<R> { } } -/// Deprecated, renamed to `catch_unwind` -#[unstable(feature = "recover", reason = "awaiting feedback", issue = "27719")] -#[rustc_deprecated(reason = "renamed to `catch_unwind`", since = "1.9.0")] -pub fn recover<F: FnOnce() -> R + UnwindSafe, R>(f: F) -> Result<R> { - catch_unwind(f) -} - /// Triggers a panic without invoking the panic hook. /// /// This is designed to be used in conjunction with `catch_unwind` to, for @@ -424,10 +337,3 @@ pub fn recover<F: FnOnce() -> R + UnwindSafe, R>(f: F) -> Result<R> { pub fn resume_unwind(payload: Box<Any + Send>) -> ! { panicking::rust_panic(payload) } - -/// Deprecated, use resume_unwind instead -#[unstable(feature = "panic_propagate", reason = "awaiting feedback", issue = "30752")] -#[rustc_deprecated(reason = "renamed to `resume_unwind`", since = "1.9.0")] -pub fn propagate(payload: Box<Any + Send>) -> ! { - resume_unwind(payload) -} diff --git a/src/libstd/sync/rwlock.rs b/src/libstd/sync/rwlock.rs index e1e764bd255..03d3483902d 100644 --- a/src/libstd/sync/rwlock.rs +++ b/src/libstd/sync/rwlock.rs @@ -468,42 +468,6 @@ impl<'rwlock, T: ?Sized> RwLockReadGuard<'rwlock, T> { } }) } - - /// Transform this guard to hold a sub-borrow of the original data. - /// - /// Applies the supplied closure to the data, returning a new lock - /// guard referencing the borrow returned by the closure. - /// - /// # Examples - /// - /// ```rust - /// # #![feature(guard_map)] - /// # use std::sync::{RwLockReadGuard, RwLock}; - /// let x = RwLock::new(vec![1, 2]); - /// - /// let y = RwLockReadGuard::map(x.read().unwrap(), |v| &v[0]); - /// assert_eq!(*y, 1); - /// ``` - #[unstable(feature = "guard_map", - reason = "recently added, needs RFC for stabilization, - questionable interaction with Condvar", - issue = "27746")] - #[rustc_deprecated(since = "1.8.0", - reason = "unsound on Mutex because of Condvar and \ - RwLock may also with to be used with Condvar \ - one day")] - pub fn map<U: ?Sized, F>(this: Self, cb: F) -> RwLockReadGuard<'rwlock, U> - where F: FnOnce(&T) -> &U - { - let new = RwLockReadGuard { - __lock: this.__lock, - __data: cb(this.__data) - }; - - mem::forget(this); - - new - } } #[allow(deprecated)] @@ -518,57 +482,6 @@ impl<'rwlock, T: ?Sized> RwLockWriteGuard<'rwlock, T> { } }) } - - /// Transform this guard to hold a sub-borrow of the original data. - /// - /// Applies the supplied closure to the data, returning a new lock - /// guard referencing the borrow returned by the closure. - /// - /// # Examples - /// - /// ```rust - /// # #![feature(guard_map)] - /// # use std::sync::{RwLockWriteGuard, RwLock}; - /// let x = RwLock::new(vec![1, 2]); - /// - /// { - /// let mut y = RwLockWriteGuard::map(x.write().unwrap(), |v| &mut v[0]); - /// assert_eq!(*y, 1); - /// - /// *y = 10; - /// } - /// - /// assert_eq!(&**x.read().unwrap(), &[10, 2]); - /// ``` - #[unstable(feature = "guard_map", - reason = "recently added, needs RFC for stabilization, - questionable interaction with Condvar", - issue = "27746")] - #[rustc_deprecated(since = "1.8.0", - reason = "unsound on Mutex because of Condvar and \ - RwLock may also with to be used with Condvar \ - one day")] - pub fn map<U: ?Sized, F>(this: Self, cb: F) -> RwLockWriteGuard<'rwlock, U> - where F: FnOnce(&mut T) -> &mut U - { - // Compute the new data while still owning the original lock - // in order to correctly poison if the callback panics. - let data = unsafe { ptr::read(&this.__data) }; - let new_data = cb(data); - - // We don't want to unlock the lock by running the destructor of the - // original lock, so just read the fields we need and forget it. - let (poison, lock) = unsafe { - (ptr::read(&this.__poison), ptr::read(&this.__lock)) - }; - mem::forget(this); - - RwLockWriteGuard { - __lock: lock, - __data: new_data, - __poison: poison - } - } } #[stable(feature = "rust1", since = "1.0.0")] @@ -619,7 +532,7 @@ mod tests { use rand::{self, Rng}; use sync::mpsc::channel; use thread; - use sync::{Arc, RwLock, StaticRwLock, TryLockError, RwLockWriteGuard}; + use sync::{Arc, RwLock, StaticRwLock, TryLockError}; use sync::atomic::{AtomicUsize, Ordering}; #[derive(Eq, PartialEq, Debug)] @@ -867,20 +780,4 @@ mod tests { Ok(x) => panic!("get_mut of poisoned RwLock is Ok: {:?}", x), } } - - #[test] - fn test_rwlock_write_map_poison() { - let rwlock = Arc::new(RwLock::new(vec![1, 2])); - let rwlock2 = rwlock.clone(); - - thread::spawn(move || { - let _ = RwLockWriteGuard::map::<usize, _>(rwlock2.write().unwrap(), |_| panic!()); - }).join().unwrap_err(); - - match rwlock.read() { - Ok(r) => panic!("Read lock on poisioned RwLock is Ok: {:?}", &*r), - Err(_) => {} - }; - } } - diff --git a/src/libstd/sys/unix/ext/process.rs b/src/libstd/sys/unix/ext/process.rs index b0fed2f4694..430ec5f94a6 100644 --- a/src/libstd/sys/unix/ext/process.rs +++ b/src/libstd/sys/unix/ext/process.rs @@ -34,21 +34,6 @@ pub trait CommandExt { #[stable(feature = "rust1", since = "1.0.0")] fn gid(&mut self, id: u32) -> &mut process::Command; - /// Create a new session (cf. `setsid(2)`) for the child process. This means - /// that the child is the leader of a new process group. The parent process - /// remains the child reaper of the new process. - /// - /// This is not enough to create a daemon process. The *init* process should - /// be the child reaper of a daemon. This can be achieved if the parent - /// process exit. Moreover, a daemon should not have a controlling terminal. - /// To achieve this, a session leader (the child) must spawn another process - /// (the daemon) in the same session. - #[unstable(feature = "process_session_leader", reason = "recently added", - issue = "27811")] - #[rustc_deprecated(reason = "use `before_exec` instead", - since = "1.9.0")] - fn session_leader(&mut self, on: bool) -> &mut process::Command; - /// Schedules a closure to be run just before the `exec` function is /// invoked. /// @@ -112,11 +97,6 @@ impl CommandExt for process::Command { self } - fn session_leader(&mut self, on: bool) -> &mut process::Command { - self.as_inner_mut().session_leader(on); - self - } - fn before_exec<F>(&mut self, f: F) -> &mut process::Command where F: FnMut() -> io::Result<()> + Send + Sync + 'static { diff --git a/src/libstd/sys/unix/process.rs b/src/libstd/sys/unix/process.rs index d5719167542..98cfdcdf110 100644 --- a/src/libstd/sys/unix/process.rs +++ b/src/libstd/sys/unix/process.rs @@ -55,7 +55,6 @@ pub struct Command { cwd: Option<CString>, uid: Option<uid_t>, gid: Option<gid_t>, - session_leader: bool, saw_nul: bool, closures: Vec<Box<FnMut() -> io::Result<()> + Send + Sync>>, stdin: Option<Stdio>, @@ -105,7 +104,6 @@ impl Command { cwd: None, uid: None, gid: None, - session_leader: false, saw_nul: saw_nul, closures: Vec::new(), stdin: None, @@ -197,9 +195,6 @@ impl Command { pub fn gid(&mut self, id: gid_t) { self.gid = Some(id); } - pub fn session_leader(&mut self, session_leader: bool) { - self.session_leader = session_leader; - } pub fn before_exec(&mut self, f: Box<FnMut() -> io::Result<()> + Send + Sync>) { @@ -367,12 +362,6 @@ impl Command { t!(cvt(libc::setuid(u as uid_t))); } - if self.session_leader { - // Don't check the error of setsid because it fails if we're the - // process leader already. We just forked so it shouldn't return - // error, but ignore it anyway. - let _ = libc::setsid(); - } if let Some(ref cwd) = self.cwd { t!(cvt(libc::chdir(cwd.as_ptr()))); } diff --git a/src/libstd/thread/mod.rs b/src/libstd/thread/mod.rs index dc26370590c..c8783a60c41 100644 --- a/src/libstd/thread/mod.rs +++ b/src/libstd/thread/mod.rs @@ -183,25 +183,15 @@ use time::Duration; //////////////////////////////////////////////////////////////////////////////// #[macro_use] mod local; -#[macro_use] mod scoped_tls; #[stable(feature = "rust1", since = "1.0.0")] pub use self::local::{LocalKey, LocalKeyState}; -#[unstable(feature = "scoped_tls", - reason = "scoped TLS has yet to have wide enough use to fully \ - consider stabilizing its interface", - issue = "27715")] -#[allow(deprecated)] -pub use self::scoped_tls::ScopedKey; - #[unstable(feature = "libstd_thread_internals", issue = "0")] #[cfg(target_thread_local)] #[doc(hidden)] pub use self::local::elf::Key as __ElfLocalKeyInner; #[unstable(feature = "libstd_thread_internals", issue = "0")] #[doc(hidden)] pub use self::local::os::Key as __OsLocalKeyInner; -#[unstable(feature = "libstd_thread_internals", issue = "0")] -#[doc(hidden)] pub use self::scoped_tls::__KeyInner as __ScopedKeyInner; //////////////////////////////////////////////////////////////////////////////// // Builder diff --git a/src/libstd/thread/scoped_tls.rs b/src/libstd/thread/scoped_tls.rs deleted file mode 100644 index dea58d016e4..00000000000 --- a/src/libstd/thread/scoped_tls.rs +++ /dev/null @@ -1,298 +0,0 @@ -// Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or -// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license -// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -//! Scoped thread-local storage -//! -//! This module provides the ability to generate *scoped* thread-local -//! variables. In this sense, scoped indicates that thread local storage -//! actually stores a reference to a value, and this reference is only placed -//! in storage for a scoped amount of time. -//! -//! There are no restrictions on what types can be placed into a scoped -//! variable, but all scoped variables are initialized to the equivalent of -//! null. Scoped thread local storage is useful when a value is present for a known -//! period of time and it is not required to relinquish ownership of the -//! contents. -//! -//! # Examples -//! -//! ``` -//! #![feature(scoped_tls)] -//! -//! scoped_thread_local!(static FOO: u32); -//! -//! // Initially each scoped slot is empty. -//! assert!(!FOO.is_set()); -//! -//! // When inserting a value, the value is only in place for the duration -//! // of the closure specified. -//! FOO.set(&1, || { -//! FOO.with(|slot| { -//! assert_eq!(*slot, 1); -//! }); -//! }); -//! ``` - -#![unstable(feature = "thread_local_internals", issue = "0")] -#![allow(deprecated)] - -#[doc(hidden)] -pub use self::imp::KeyInner as __KeyInner; - -/// Type representing a thread local storage key corresponding to a reference -/// to the type parameter `T`. -/// -/// Keys are statically allocated and can contain a reference to an instance of -/// type `T` scoped to a particular lifetime. Keys provides two methods, `set` -/// and `with`, both of which currently use closures to control the scope of -/// their contents. -#[unstable(feature = "scoped_tls", - reason = "scoped TLS has yet to have wide enough use to fully consider \ - stabilizing its interface", - issue = "27715")] -#[rustc_deprecated(since = "1.8.0", - reason = "hasn't proven itself over LocalKey")] -pub struct ScopedKey<T:'static> { inner: fn() -> &'static imp::KeyInner<T> } - -/// Declare a new scoped thread local storage key. -/// -/// This macro declares a `static` item on which methods are used to get and -/// set the value stored within. -/// -/// See [ScopedKey documentation](thread/struct.ScopedKey.html) for more -/// information. -#[unstable(feature = "thread_local_internals", - reason = "should not be necessary", - issue = "0")] -#[rustc_deprecated(since = "1.8.0", - reason = "hasn't proven itself over LocalKey")] -#[macro_export] -#[allow_internal_unstable] -macro_rules! scoped_thread_local { - (static $name:ident: $t:ty) => ( - static $name: $crate::thread::ScopedKey<$t> = - __scoped_thread_local_inner!($t); - ); - (pub static $name:ident: $t:ty) => ( - pub static $name: $crate::thread::ScopedKey<$t> = - __scoped_thread_local_inner!($t); - ); -} - -#[doc(hidden)] -#[unstable(feature = "thread_local_internals", - reason = "should not be necessary", - issue = "0")] -#[rustc_deprecated(since = "1.8.0", - reason = "hasn't proven itself over LocalKey")] -#[macro_export] -#[allow_internal_unstable] -macro_rules! __scoped_thread_local_inner { - ($t:ty) => {{ - #[cfg_attr(target_thread_local, thread_local)] - static _KEY: $crate::thread::__ScopedKeyInner<$t> = - $crate::thread::__ScopedKeyInner::new(); - fn _getit() -> &'static $crate::thread::__ScopedKeyInner<$t> { &_KEY } - $crate::thread::ScopedKey::new(_getit) - }} -} - -#[unstable(feature = "scoped_tls", - reason = "scoped TLS has yet to have wide enough use to fully consider \ - stabilizing its interface", - issue = "27715")] -#[rustc_deprecated(since = "1.8.0", - reason = "hasn't proven itself over LocalKey")] -impl<T> ScopedKey<T> { - #[doc(hidden)] - pub const fn new(inner: fn() -> &'static imp::KeyInner<T>) -> ScopedKey<T> { - ScopedKey { inner: inner } - } - - /// Inserts a value into this scoped thread local storage slot for a - /// duration of a closure. - /// - /// While `cb` is running, the value `t` will be returned by `get` unless - /// this function is called recursively inside of `cb`. - /// - /// Upon return, this function will restore the previous value, if any - /// was available. - /// - /// # Examples - /// - /// ``` - /// #![feature(scoped_tls)] - /// - /// scoped_thread_local!(static FOO: u32); - /// - /// FOO.set(&100, || { - /// let val = FOO.with(|v| *v); - /// assert_eq!(val, 100); - /// - /// // set can be called recursively - /// FOO.set(&101, || { - /// // ... - /// }); - /// - /// // Recursive calls restore the previous value. - /// let val = FOO.with(|v| *v); - /// assert_eq!(val, 100); - /// }); - /// ``` - pub fn set<R, F>(&'static self, t: &T, cb: F) -> R where - F: FnOnce() -> R, - { - struct Reset<'a, T: 'a> { - key: &'a imp::KeyInner<T>, - val: *mut T, - } - impl<'a, T> Drop for Reset<'a, T> { - fn drop(&mut self) { - unsafe { self.key.set(self.val) } - } - } - - let inner = (self.inner)(); - let prev = unsafe { - let prev = inner.get(); - inner.set(t as *const T as *mut T); - prev - }; - - let _reset = Reset { key: inner, val: prev }; - cb() - } - - /// Gets a value out of this scoped variable. - /// - /// This function takes a closure which receives the value of this - /// variable. - /// - /// # Panics - /// - /// This function will panic if `set` has not previously been called. - /// - /// # Examples - /// - /// ```no_run - /// #![feature(scoped_tls)] - /// - /// scoped_thread_local!(static FOO: u32); - /// - /// FOO.with(|slot| { - /// // work with `slot` - /// }); - /// ``` - pub fn with<R, F>(&'static self, cb: F) -> R where - F: FnOnce(&T) -> R - { - unsafe { - let ptr = (self.inner)().get(); - assert!(!ptr.is_null(), "cannot access a scoped thread local \ - variable without calling `set` first"); - cb(&*ptr) - } - } - - /// Test whether this TLS key has been `set` for the current thread. - pub fn is_set(&'static self) -> bool { - unsafe { !(self.inner)().get().is_null() } - } -} - -#[cfg(target_thread_local)] -#[doc(hidden)] -mod imp { - use cell::Cell; - use ptr; - - pub struct KeyInner<T> { inner: Cell<*mut T> } - - unsafe impl<T> ::marker::Sync for KeyInner<T> { } - - impl<T> KeyInner<T> { - pub const fn new() -> KeyInner<T> { - KeyInner { inner: Cell::new(ptr::null_mut()) } - } - pub unsafe fn set(&self, ptr: *mut T) { self.inner.set(ptr); } - pub unsafe fn get(&self) -> *mut T { self.inner.get() } - } -} - -#[cfg(not(target_thread_local))] -#[doc(hidden)] -mod imp { - use cell::Cell; - use marker; - use sys_common::thread_local::StaticKey as OsStaticKey; - - pub struct KeyInner<T> { - pub inner: OsStaticKey, - pub marker: marker::PhantomData<Cell<T>>, - } - - unsafe impl<T> marker::Sync for KeyInner<T> { } - - impl<T> KeyInner<T> { - pub const fn new() -> KeyInner<T> { - KeyInner { - inner: OsStaticKey::new(None), - marker: marker::PhantomData - } - } - pub unsafe fn set(&self, ptr: *mut T) { self.inner.set(ptr as *mut _) } - pub unsafe fn get(&self) -> *mut T { self.inner.get() as *mut _ } - } -} - - -#[cfg(test)] -mod tests { - use cell::Cell; - - scoped_thread_local!(static FOO: u32); - - #[test] - fn smoke() { - scoped_thread_local!(static BAR: u32); - - assert!(!BAR.is_set()); - BAR.set(&1, || { - assert!(BAR.is_set()); - BAR.with(|slot| { - assert_eq!(*slot, 1); - }); - }); - assert!(!BAR.is_set()); - } - - #[test] - fn cell_allowed() { - scoped_thread_local!(static BAR: Cell<u32>); - - BAR.set(&Cell::new(1), || { - BAR.with(|slot| { - assert_eq!(slot.get(), 1); - }); - }); - } - - #[test] - fn scope_item_allowed() { - assert!(!FOO.is_set()); - FOO.set(&1, || { - assert!(FOO.is_set()); - FOO.with(|slot| { - assert_eq!(*slot, 1); - }); - }); - assert!(!FOO.is_set()); - } -} diff --git a/src/libstd/time/mod.rs b/src/libstd/time/mod.rs index 80963a9b735..0e1508a1c4c 100644 --- a/src/libstd/time/mod.rs +++ b/src/libstd/time/mod.rs @@ -143,13 +143,6 @@ impl Instant { self.0.sub_instant(&earlier.0) } - /// Deprecated, renamed to `duration_since` - #[unstable(feature = "time2_old", issue = "29866")] - #[rustc_deprecated(since = "1.8.0", reason = "renamed to duration_since")] - pub fn duration_from_earlier(&self, earlier: Instant) -> Duration { - self.0.sub_instant(&earlier.0) - } - /// Returns the amount of time elapsed since this instant was created. /// /// # Panics @@ -235,14 +228,6 @@ impl SystemTime { self.0.sub_time(&earlier.0).map_err(SystemTimeError) } - /// Deprecated, renamed to `duration_since` - #[unstable(feature = "time2_old", issue = "29866")] - #[rustc_deprecated(since = "1.8.0", reason = "renamed to duration_since")] - pub fn duration_from_earlier(&self, earlier: SystemTime) - -> Result<Duration, SystemTimeError> { - self.0.sub_time(&earlier.0).map_err(SystemTimeError) - } - /// Returns the amount of time elapsed since this system time was created. /// /// This function may fail as the underlying system clock is susceptible to diff --git a/src/test/compile-fail/issue-16338.rs b/src/test/compile-fail/issue-16338.rs index da6d081a7ac..c6ce0c4c95b 100644 --- a/src/test/compile-fail/issue-16338.rs +++ b/src/test/compile-fail/issue-16338.rs @@ -8,12 +8,15 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use std::raw::Slice; +struct Slice<T> { + data: *const T, + len: usize, +} fn main() { let Slice { data: data, len: len } = "foo"; //~^ ERROR mismatched types //~| expected type `&str` - //~| found type `std::raw::Slice<_>` - //~| expected &-ptr, found struct `std::raw::Slice` + //~| found type `Slice<_>` + //~| expected &-ptr, found struct `Slice` } diff --git a/src/test/compile-fail/issue-16401.rs b/src/test/compile-fail/issue-16401.rs index df272a71cee..3060bbea43c 100644 --- a/src/test/compile-fail/issue-16401.rs +++ b/src/test/compile-fail/issue-16401.rs @@ -8,15 +8,18 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use std::raw::Slice; +struct Slice<T> { + data: *const T, + len: usize, +} fn main() { match () { Slice { data: data, len: len } => (), //~^ ERROR mismatched types //~| expected type `()` - //~| found type `std::raw::Slice<_>` - //~| expected (), found struct `std::raw::Slice` + //~| found type `Slice<_>` + //~| expected (), found struct `Slice` _ => unreachable!() } } diff --git a/src/test/compile-fail/not-panic-safe-2.rs b/src/test/compile-fail/not-panic-safe-2.rs index 58c0791b84e..7107211fc91 100644 --- a/src/test/compile-fail/not-panic-safe-2.rs +++ b/src/test/compile-fail/not-panic-safe-2.rs @@ -9,13 +9,12 @@ // except according to those terms. #![allow(dead_code)] -#![feature(recover)] -use std::panic::RecoverSafe; +use std::panic::UnwindSafe; use std::rc::Rc; use std::cell::RefCell; -fn assert<T: RecoverSafe + ?Sized>() {} +fn assert<T: UnwindSafe + ?Sized>() {} fn main() { assert::<Rc<RefCell<i32>>>(); diff --git a/src/test/compile-fail/not-panic-safe-3.rs b/src/test/compile-fail/not-panic-safe-3.rs index 481ffb80281..76c34e4dc0b 100644 --- a/src/test/compile-fail/not-panic-safe-3.rs +++ b/src/test/compile-fail/not-panic-safe-3.rs @@ -9,13 +9,12 @@ // except according to those terms. #![allow(dead_code)] -#![feature(recover)] -use std::panic::RecoverSafe; +use std::panic::UnwindSafe; use std::sync::Arc; use std::cell::RefCell; -fn assert<T: RecoverSafe + ?Sized>() {} +fn assert<T: UnwindSafe + ?Sized>() {} fn main() { assert::<Arc<RefCell<i32>>>(); diff --git a/src/test/compile-fail/not-panic-safe-4.rs b/src/test/compile-fail/not-panic-safe-4.rs index 47302d3af78..177a43e2a7f 100644 --- a/src/test/compile-fail/not-panic-safe-4.rs +++ b/src/test/compile-fail/not-panic-safe-4.rs @@ -9,12 +9,11 @@ // except according to those terms. #![allow(dead_code)] -#![feature(recover)] -use std::panic::RecoverSafe; +use std::panic::UnwindSafe; use std::cell::RefCell; -fn assert<T: RecoverSafe + ?Sized>() {} +fn assert<T: UnwindSafe + ?Sized>() {} fn main() { assert::<&RefCell<i32>>(); diff --git a/src/test/compile-fail/not-panic-safe-5.rs b/src/test/compile-fail/not-panic-safe-5.rs index 0301c8dd935..627a0fe78cf 100644 --- a/src/test/compile-fail/not-panic-safe-5.rs +++ b/src/test/compile-fail/not-panic-safe-5.rs @@ -9,12 +9,11 @@ // except according to those terms. #![allow(dead_code)] -#![feature(recover)] -use std::panic::RecoverSafe; +use std::panic::UnwindSafe; use std::cell::UnsafeCell; -fn assert<T: RecoverSafe + ?Sized>() {} +fn assert<T: UnwindSafe + ?Sized>() {} fn main() { assert::<*const UnsafeCell<i32>>(); //~ ERROR E0277 diff --git a/src/test/compile-fail/not-panic-safe-6.rs b/src/test/compile-fail/not-panic-safe-6.rs index fe13b0a75c9..f03e1d545a8 100644 --- a/src/test/compile-fail/not-panic-safe-6.rs +++ b/src/test/compile-fail/not-panic-safe-6.rs @@ -9,12 +9,11 @@ // except according to those terms. #![allow(dead_code)] -#![feature(recover)] -use std::panic::RecoverSafe; +use std::panic::UnwindSafe; use std::cell::RefCell; -fn assert<T: RecoverSafe + ?Sized>() {} +fn assert<T: UnwindSafe + ?Sized>() {} fn main() { assert::<*mut RefCell<i32>>(); diff --git a/src/test/run-fail/panic-set-handler.rs b/src/test/run-fail/panic-set-handler.rs index bfeb407dd25..b589544ae15 100644 --- a/src/test/run-fail/panic-set-handler.rs +++ b/src/test/run-fail/panic-set-handler.rs @@ -10,13 +10,14 @@ // error-pattern:greetings from the panic handler -#![feature(std_panic, panic_handler)] +#![feature(panic_handler)] + use std::panic; use std::io::{self, Write}; fn main() { - panic::set_handler(|i| { + panic::set_hook(Box::new(|i| { write!(io::stderr(), "greetings from the panic handler"); - }); + })); panic!("foobar"); } diff --git a/src/test/run-fail/panic-set-unset-handler.rs b/src/test/run-fail/panic-set-unset-handler.rs index 6999aa715e7..4c895ea52aa 100644 --- a/src/test/run-fail/panic-set-unset-handler.rs +++ b/src/test/run-fail/panic-set-unset-handler.rs @@ -10,14 +10,15 @@ // error-pattern:thread '<main>' panicked at 'foobar' -#![feature(std_panic, panic_handler)] +#![feature(panic_handler)] + use std::panic; use std::io::{self, Write}; fn main() { - panic::set_handler(|i| { + panic::set_hook(Box::new(|i| { write!(io::stderr(), "greetings from the panic handler"); - }); - panic::take_handler(); + })); + panic::take_hook(); panic!("foobar"); } diff --git a/src/test/run-fail/panic-take-handler-nop.rs b/src/test/run-fail/panic-take-handler-nop.rs index fec1db24adf..58e57528e8a 100644 --- a/src/test/run-fail/panic-take-handler-nop.rs +++ b/src/test/run-fail/panic-take-handler-nop.rs @@ -10,10 +10,11 @@ // error-pattern:thread '<main>' panicked at 'foobar' -#![feature(std_panic, panic_handler)] +#![feature(panic_handler)] + use std::panic; fn main() { - panic::take_handler(); + panic::take_hook(); panic!("foobar"); } diff --git a/src/test/run-pass/binary-heap-panic-safe.rs b/src/test/run-pass/binary-heap-panic-safe.rs index 7fbd8dc4786..93d3345a809 100644 --- a/src/test/run-pass/binary-heap-panic-safe.rs +++ b/src/test/run-pass/binary-heap-panic-safe.rs @@ -8,10 +8,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(recover, rand, std_panic)] +#![feature(rand, std_panic)] use std::__rand::{thread_rng, Rng}; -use std::panic::{self, AssertRecoverSafe}; +use std::panic::{self, AssertUnwindSafe}; use std::collections::BinaryHeap; use std::cmp; @@ -70,8 +70,8 @@ fn test_integrity() { { // push the panicking item to the heap and catch the panic let thread_result = { - let mut heap_ref = AssertRecoverSafe(&mut heap); - panic::recover(move || { + let mut heap_ref = AssertUnwindSafe(&mut heap); + panic::catch_unwind(move || { heap_ref.push(panic_item); }) }; diff --git a/src/test/run-pass/panic-recover-propagate.rs b/src/test/run-pass/panic-recover-propagate.rs index 2c87c6b9268..0210017b47e 100644 --- a/src/test/run-pass/panic-recover-propagate.rs +++ b/src/test/run-pass/panic-recover-propagate.rs @@ -10,25 +10,25 @@ // ignore-emscripten no threads support -#![feature(std_panic, recover, panic_propagate, panic_handler, const_fn)] +#![feature(panic_handler)] -use std::sync::atomic::{AtomicUsize, Ordering}; +use std::sync::atomic::{AtomicUsize, Ordering, ATOMIC_USIZE_INIT}; use std::panic; use std::thread; -static A: AtomicUsize = AtomicUsize::new(0); +static A: AtomicUsize = ATOMIC_USIZE_INIT; fn main() { - panic::set_handler(|_| { + panic::set_hook(Box::new(|_| { A.fetch_add(1, Ordering::SeqCst); - }); + })); let result = thread::spawn(|| { - let result = panic::recover(|| { + let result = panic::catch_unwind(|| { panic!("hi there"); }); - panic::propagate(result.unwrap_err()); + panic::resume_unwind(result.unwrap_err()); }).join(); let msg = *result.unwrap_err().downcast::<&'static str>().unwrap(); diff --git a/src/test/run-pass/reachable-unnameable-items.rs b/src/test/run-pass/reachable-unnameable-items.rs index 8a23403359f..75a2e36ffb7 100644 --- a/src/test/run-pass/reachable-unnameable-items.rs +++ b/src/test/run-pass/reachable-unnameable-items.rs @@ -10,8 +10,6 @@ // aux-build:reachable-unnameable-items.rs -#![feature(recover)] - extern crate reachable_unnameable_items; use reachable_unnameable_items::*; @@ -37,5 +35,5 @@ fn main() { let none = None; function_accepting_unnameable_type(none); - let _guard = std::panic::recover(|| none.unwrap().method_of_unnameable_type3()); + let _guard = std::panic::catch_unwind(|| none.unwrap().method_of_unnameable_type3()); } diff --git a/src/test/run-pass/running-with-no-runtime.rs b/src/test/run-pass/running-with-no-runtime.rs index c67bc8c8368..23d5a08e216 100644 --- a/src/test/run-pass/running-with-no-runtime.rs +++ b/src/test/run-pass/running-with-no-runtime.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(std_panic, recover, start)] +#![feature(start)] use std::ffi::CStr; use std::process::{Command, Output}; @@ -22,8 +22,8 @@ fn start(argc: isize, argv: *const *const u8) -> isize { match **argv.offset(1) as char { '1' => {} '2' => println!("foo"), - '3' => assert!(panic::recover(|| {}).is_ok()), - '4' => assert!(panic::recover(|| panic!()).is_err()), + '3' => assert!(panic::catch_unwind(|| {}).is_ok()), + '4' => assert!(panic::catch_unwind(|| panic!()).is_err()), '5' => assert!(Command::new("test").spawn().is_err()), _ => panic!() } diff --git a/src/test/run-pass/utf8_chars.rs b/src/test/run-pass/utf8_chars.rs index 4d369ba4d87..0f751501293 100644 --- a/src/test/run-pass/utf8_chars.rs +++ b/src/test/run-pass/utf8_chars.rs @@ -23,8 +23,6 @@ pub fn main() { assert_eq!(s.chars().count(), 4); assert_eq!(schs.len(), 4); assert_eq!(schs.iter().cloned().collect::<String>(), s); - assert_eq!(s.char_at(0), 'e'); - assert_eq!(s.char_at(1), 'é'); assert!((str::from_utf8(s.as_bytes()).is_ok())); // invalid prefix |
