-
Notifications
You must be signed in to change notification settings - Fork 13.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
std: Deprecate a number of unstable features #26914
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -772,6 +772,9 @@ impl<T> Vec<T> { | |
/// ``` | ||
#[unstable(feature = "map_in_place", | ||
reason = "API may change to provide stronger guarantees")] | ||
#[deprecated(since = "1.3.0", | ||
reason = "unclear that the API is strong enough and did \ | ||
not proven itself")] | ||
pub fn map_in_place<U, F>(self, mut f: F) -> Vec<U> where F: FnMut(T) -> U { | ||
// FIXME: Assert statically that the types `T` and `U` have the same | ||
// size. | ||
|
@@ -1627,6 +1630,7 @@ impl<T> IntoIter<T> { | |
#[inline] | ||
/// Drops all items that have not yet been moved and returns the empty vector. | ||
#[unstable(feature = "iter_to_vec")] | ||
#[deprecated(since = "1.3.0", reason = "replaced by drain()")] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't see how this is replaced by drain, it may in fact be very useful (I'd use it in itertools if it were stable). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes this isn't replaced by Drain -- in particular IntoIter allows you to return the Vec up and transport it around -- Drain doesn't. Still, this seems fairly marginal for today's std. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. True, but I believe that this was originally added to get back the original allocation, in which case There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not for every use case, for example not for GroupByLazy, which would like to recycle allocations of the IntoIters it uses. |
||
pub fn into_inner(mut self) -> Vec<T> { | ||
unsafe { | ||
for _x in self.by_ref() { } | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -401,6 +401,7 @@ pub fn max<T: Ord>(v1: T, v2: T) -> T { | |
/// ``` | ||
#[inline] | ||
#[unstable(feature = "cmp_partial")] | ||
#[deprecated(since = "1.3.0", reason = "has not proven itself worthwhile")] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This only deprecates There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oops, thanks! |
||
pub fn partial_min<T: PartialOrd>(v1: T, v2: T) -> Option<T> { | ||
match v1.partial_cmp(&v2) { | ||
Some(Less) | Some(Equal) => Some(v1), | ||
|
@@ -434,6 +435,7 @@ pub fn partial_min<T: PartialOrd>(v1: T, v2: T) -> Option<T> { | |
/// ``` | ||
#[inline] | ||
#[unstable(feature = "cmp_partial")] | ||
#[deprecated(since = "1.3.0", reason = "has not proven itself worthwhile")] | ||
pub fn partial_max<T: PartialOrd>(v1: T, v2: T) -> Option<T> { | ||
match v1.partial_cmp(&v2) { | ||
Some(Equal) | Some(Less) => Some(v2), | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -171,6 +171,8 @@ pub trait Hasher { | |
#[unstable(feature = "hash_default", | ||
reason = "not the most ergonomic interface unless `H` is defaulted \ | ||
to SipHasher, but perhaps not ready to commit to that")] | ||
#[deprecated(since = "1.3.0", | ||
reason = "has yet to prove itself useful")] | ||
pub fn hash<T: Hash, H: Hasher + Default>(value: &T) -> u64 { | ||
let mut h: H = Default::default(); | ||
value.hash(&mut h); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fwiw a fair amount of code uses this for testing hashers, but... eh. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I feel like this function doesn't quite deserve to be here without rust-lang/rfcs#1196, because with that RFC you could write (after swapping the type parameter order) hash::<SipHasher>(&foo);
hash::<FnvHasher>(&foo); whereas today you write: hash::<_, SipHasher>(&foo);
hash::<_, FnvHasher>(&foo); There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm pretty sure that RFC is only proposing eliding trailing _'s..? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
:) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. /// hash.rs
trait DefaultHash: Hasher + Default {
fn default_hash<T: Hash>(value: &T) -> u64 {
...
}
}
impl<H: Hasher + Default> DefaultHash for H {} /// test.rs
use std::hash::DefaultHash;
SipHasher::default_hash(&foo);
FnvHasher::default_hash(&foo); |
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,6 +56,7 @@ | |
|
||
#![stable(feature = "rust1", since = "1.0.0")] | ||
|
||
#[allow(deprecated)] | ||
use self::MinMaxResult::*; | ||
|
||
use clone::Clone; | ||
|
@@ -445,6 +446,7 @@ pub trait Iterator { | |
/// ``` | ||
#[inline] | ||
#[stable(feature = "rust1", since = "1.0.0")] | ||
#[allow(deprecated)] | ||
fn scan<St, B, F>(self, initial_state: St, f: F) -> Scan<Self, St, F> | ||
where Self: Sized, F: FnMut(&mut St, Self::Item) -> Option<B>, | ||
{ | ||
|
@@ -840,6 +842,8 @@ pub trait Iterator { | |
#[unstable(feature = "iter_min_max", | ||
reason = "return type may change or may wish to have a closure \ | ||
based version as well")] | ||
#[deprecated(since = "1.3.0", reason = "has not proven itself")] | ||
#[allow(deprecated)] | ||
fn min_max(mut self) -> MinMaxResult<Self::Item> where Self: Sized, Self::Item: Ord | ||
{ | ||
let (mut min, mut max) = match self.next() { | ||
|
@@ -1336,6 +1340,8 @@ impl<I> RandomAccessIterator for Rev<I> | |
#[derive(Clone, PartialEq, Debug)] | ||
#[unstable(feature = "iter_min_max", | ||
reason = "unclear whether such a fine-grained result is widely useful")] | ||
#[deprecated(since = "1.3.0", reason = "has not proven itself")] | ||
#[allow(deprecated)] | ||
pub enum MinMaxResult<T> { | ||
/// Empty iterator | ||
NoElements, | ||
|
@@ -1349,6 +1355,8 @@ pub enum MinMaxResult<T> { | |
} | ||
|
||
#[unstable(feature = "iter_min_max", reason = "type is unstable")] | ||
#[deprecated(since = "1.3.0", reason = "has not proven itself")] | ||
#[allow(deprecated)] | ||
impl<T: Clone> MinMaxResult<T> { | ||
/// `into_option` creates an `Option` of type `(T,T)`. The returned `Option` | ||
/// has variant `None` if and only if the `MinMaxResult` has variant | ||
|
@@ -2249,13 +2257,15 @@ impl<I> ExactSizeIterator for Take<I> where I: ExactSizeIterator {} | |
#[must_use = "iterator adaptors are lazy and do nothing unless consumed"] | ||
#[stable(feature = "rust1", since = "1.0.0")] | ||
#[derive(Clone)] | ||
#[allow(deprecated)] | ||
pub struct Scan<I, St, F> { | ||
iter: I, | ||
f: F, | ||
|
||
/// The current internal state to be passed to the closure next. | ||
#[unstable(feature = "scan_state", | ||
reason = "public fields are otherwise rare in the stdlib")] | ||
#[deprecated(since = "1.3.0", reason = "unclear whether this is necessary")] | ||
pub state: St, | ||
} | ||
|
||
|
@@ -2267,6 +2277,7 @@ impl<B, I, St, F> Iterator for Scan<I, St, F> where | |
type Item = B; | ||
|
||
#[inline] | ||
#[allow(deprecated)] | ||
fn next(&mut self) -> Option<B> { | ||
self.iter.next().and_then(|a| (self.f)(&mut self.state, a)) | ||
} | ||
|
@@ -2448,6 +2459,8 @@ impl<I> Fuse<I> { | |
/// previously returned `None`. | ||
#[inline] | ||
#[unstable(feature = "iter_reset_fuse", reason = "seems marginal")] | ||
#[deprecated(since = "1.3.0", | ||
reason = "unusual for adaptors to have one-off methods")] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is an unusual comment :-) I don't disagree with the deprecation, but I'd like to add a method to fuse, to query its fused/nonfused state, it would be quite useful. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I agree: the problem here isn't the one-off-ness per se, but rather that this method doesn't seem terribly useful in practice. |
||
pub fn reset_fuse(&mut self) { | ||
self.done = false | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -131,6 +131,9 @@ pub unsafe fn read<T>(src: *const T) -> T { | |
#[inline(always)] | ||
#[unstable(feature = "read_and_zero", | ||
reason = "may play a larger role in std::ptr future extensions")] | ||
#[deprecated(since = "1.3.0", | ||
reason = "a \"zero value\" will soon not actually exist for all \ | ||
types once dynamic drop has been implemented")] | ||
pub unsafe fn read_and_zero<T>(dest: *mut T) -> T { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this premature? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No. read_and_zero is stupid; it's just ptr::read and ptr::write_bytes There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah now that nonzeroing drop is implemented there's no real need to actually write a zero value with a convenience function like this (e.g. it's not ubiquitous) |
||
// Copy the data out from `dest`: | ||
let tmp = read(&*dest); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cc @pnkfelix -- can you comment on whether we may still want this constant with the upcoming box/allocator system?