Skip to content

Commit b3aa1a6

Browse files
committed
std: Deprecate a number of unstable features
Many of these have long since reached their stage of being obsolete, so this commit starts the removal process for all of them. The unstable features that were deprecated are: * cmp_partial * fs_time * hash_default * int_slice * iter_min_max * iter_reset_fuse * iter_to_vec * map_in_place * move_from * owned_ascii_ext * page_size * read_and_zero * scan_state * slice_chars * slice_position_elem * subslice_offset
1 parent a5c12f4 commit b3aa1a6

File tree

27 files changed

+80
-33
lines changed

27 files changed

+80
-33
lines changed

src/liballoc/boxed.rs

+3
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,13 @@ use core::raw::{TraitObject};
8686
#[lang = "exchange_heap"]
8787
#[unstable(feature = "box_heap",
8888
reason = "may be renamed; uncertain about custom allocator design")]
89+
#[allow(deprecated)]
8990
pub const HEAP: ExchangeHeapSingleton =
9091
ExchangeHeapSingleton { _force_singleton: () };
9192

9293
/// This the singleton type used solely for `boxed::HEAP`.
94+
#[unstable(feature = "box_heap",
95+
reason = "may be renamed; uncertain about custom allocator design")]
9396
#[derive(Copy, Clone)]
9497
pub struct ExchangeHeapSingleton { _force_singleton: () }
9598

src/libcollections/slice.rs

+6
Original file line numberDiff line numberDiff line change
@@ -762,12 +762,16 @@ impl<T> [T] {
762762

763763
/// Find the first index containing a matching value.
764764
#[unstable(feature = "slice_position_elem")]
765+
#[deprecated(since = "1.3.0",
766+
reason = "less idiomatic than .iter().position()")]
765767
pub fn position_elem(&self, t: &T) -> Option<usize> where T: PartialEq {
766768
core_slice::SliceExt::position_elem(self, t)
767769
}
768770

769771
/// Find the last index containing a matching value.
770772
#[unstable(feature = "slice_position_elem")]
773+
#[deprecated(since = "1.3.0",
774+
reason = "less idiomatic than .iter().rev().position()")]
771775
pub fn rposition_elem(&self, t: &T) -> Option<usize> where T: PartialEq {
772776
core_slice::SliceExt::rposition_elem(self, t)
773777
}
@@ -1009,6 +1013,8 @@ impl<T> [T] {
10091013
/// ```
10101014
#[unstable(feature = "move_from",
10111015
reason = "uncertain about this API approach")]
1016+
#[deprecated(since = "1.3.0",
1017+
reason = "unclear that it must belong in the standard library")]
10121018
#[inline]
10131019
pub fn move_from(&mut self, mut src: Vec<T>, start: usize, end: usize) -> usize {
10141020
for (a, b) in self.iter_mut().zip(&mut src[start .. end]) {

src/libcollections/str.rs

+5
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,9 @@ impl str {
552552
/// ```
553553
#[unstable(feature = "slice_chars",
554554
reason = "may have yet to prove its worth")]
555+
#[deprecated(since = "1.3.0",
556+
reason = "can be implemented with char_indices and \
557+
hasn't seen enough use to justify inclusion")]
555558
pub fn slice_chars(&self, begin: usize, end: usize) -> &str {
556559
core_str::StrExt::slice_chars(self, begin, end)
557560
}
@@ -1642,6 +1645,8 @@ impl str {
16421645
/// ```
16431646
#[unstable(feature = "subslice_offset",
16441647
reason = "awaiting convention about comparability of arbitrary slices")]
1648+
#[deprecated(since = "1.3.0",
1649+
reason = "replaced with other pattern-related methods")]
16451650
pub fn subslice_offset(&self, inner: &str) -> usize {
16461651
core_str::StrExt::subslice_offset(self, inner)
16471652
}

src/libcollections/vec.rs

+4
Original file line numberDiff line numberDiff line change
@@ -772,6 +772,9 @@ impl<T> Vec<T> {
772772
/// ```
773773
#[unstable(feature = "map_in_place",
774774
reason = "API may change to provide stronger guarantees")]
775+
#[deprecated(since = "1.3.0",
776+
reason = "unclear that the API is strong enough and did \
777+
not proven itself")]
775778
pub fn map_in_place<U, F>(self, mut f: F) -> Vec<U> where F: FnMut(T) -> U {
776779
// FIXME: Assert statically that the types `T` and `U` have the same
777780
// size.
@@ -1627,6 +1630,7 @@ impl<T> IntoIter<T> {
16271630
#[inline]
16281631
/// Drops all items that have not yet been moved and returns the empty vector.
16291632
#[unstable(feature = "iter_to_vec")]
1633+
#[deprecated(since = "1.3.0", reason = "replaced by drain()")]
16301634
pub fn into_inner(mut self) -> Vec<T> {
16311635
unsafe {
16321636
for _x in self.by_ref() { }

src/libcore/cmp.rs

+2
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,7 @@ pub fn max<T: Ord>(v1: T, v2: T) -> T {
401401
/// ```
402402
#[inline]
403403
#[unstable(feature = "cmp_partial")]
404+
#[deprecated(since = "1.3.0", reason = "has not proven itself worthwhile")]
404405
pub fn partial_min<T: PartialOrd>(v1: T, v2: T) -> Option<T> {
405406
match v1.partial_cmp(&v2) {
406407
Some(Less) | Some(Equal) => Some(v1),
@@ -434,6 +435,7 @@ pub fn partial_min<T: PartialOrd>(v1: T, v2: T) -> Option<T> {
434435
/// ```
435436
#[inline]
436437
#[unstable(feature = "cmp_partial")]
438+
#[deprecated(since = "1.3.0", reason = "has not proven itself worthwhile")]
437439
pub fn partial_max<T: PartialOrd>(v1: T, v2: T) -> Option<T> {
438440
match v1.partial_cmp(&v2) {
439441
Some(Equal) | Some(Less) => Some(v2),

src/libcore/hash/mod.rs

+2
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,8 @@ pub trait Hasher {
171171
#[unstable(feature = "hash_default",
172172
reason = "not the most ergonomic interface unless `H` is defaulted \
173173
to SipHasher, but perhaps not ready to commit to that")]
174+
#[deprecated(since = "1.3.0",
175+
reason = "has yet to prove itself useful")]
174176
pub fn hash<T: Hash, H: Hasher + Default>(value: &T) -> u64 {
175177
let mut h: H = Default::default();
176178
value.hash(&mut h);

src/libcore/iter.rs

+13
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
5757
#![stable(feature = "rust1", since = "1.0.0")]
5858

59+
#[allow(deprecated)]
5960
use self::MinMaxResult::*;
6061

6162
use clone::Clone;
@@ -445,6 +446,7 @@ pub trait Iterator {
445446
/// ```
446447
#[inline]
447448
#[stable(feature = "rust1", since = "1.0.0")]
449+
#[allow(deprecated)]
448450
fn scan<St, B, F>(self, initial_state: St, f: F) -> Scan<Self, St, F>
449451
where Self: Sized, F: FnMut(&mut St, Self::Item) -> Option<B>,
450452
{
@@ -840,6 +842,8 @@ pub trait Iterator {
840842
#[unstable(feature = "iter_min_max",
841843
reason = "return type may change or may wish to have a closure \
842844
based version as well")]
845+
#[deprecated(since = "1.3.0", reason = "has not proven itself")]
846+
#[allow(deprecated)]
843847
fn min_max(mut self) -> MinMaxResult<Self::Item> where Self: Sized, Self::Item: Ord
844848
{
845849
let (mut min, mut max) = match self.next() {
@@ -1336,6 +1340,8 @@ impl<I> RandomAccessIterator for Rev<I>
13361340
#[derive(Clone, PartialEq, Debug)]
13371341
#[unstable(feature = "iter_min_max",
13381342
reason = "unclear whether such a fine-grained result is widely useful")]
1343+
#[deprecated(since = "1.3.0", reason = "has not proven itself")]
1344+
#[allow(deprecated)]
13391345
pub enum MinMaxResult<T> {
13401346
/// Empty iterator
13411347
NoElements,
@@ -1349,6 +1355,8 @@ pub enum MinMaxResult<T> {
13491355
}
13501356

13511357
#[unstable(feature = "iter_min_max", reason = "type is unstable")]
1358+
#[deprecated(since = "1.3.0", reason = "has not proven itself")]
1359+
#[allow(deprecated)]
13521360
impl<T: Clone> MinMaxResult<T> {
13531361
/// `into_option` creates an `Option` of type `(T,T)`. The returned `Option`
13541362
/// has variant `None` if and only if the `MinMaxResult` has variant
@@ -2249,13 +2257,15 @@ impl<I> ExactSizeIterator for Take<I> where I: ExactSizeIterator {}
22492257
#[must_use = "iterator adaptors are lazy and do nothing unless consumed"]
22502258
#[stable(feature = "rust1", since = "1.0.0")]
22512259
#[derive(Clone)]
2260+
#[allow(deprecated)]
22522261
pub struct Scan<I, St, F> {
22532262
iter: I,
22542263
f: F,
22552264

22562265
/// The current internal state to be passed to the closure next.
22572266
#[unstable(feature = "scan_state",
22582267
reason = "public fields are otherwise rare in the stdlib")]
2268+
#[deprecated(since = "1.3.0", reason = "unclear whether this is necessary")]
22592269
pub state: St,
22602270
}
22612271

@@ -2267,6 +2277,7 @@ impl<B, I, St, F> Iterator for Scan<I, St, F> where
22672277
type Item = B;
22682278

22692279
#[inline]
2280+
#[allow(deprecated)]
22702281
fn next(&mut self) -> Option<B> {
22712282
self.iter.next().and_then(|a| (self.f)(&mut self.state, a))
22722283
}
@@ -2448,6 +2459,8 @@ impl<I> Fuse<I> {
24482459
/// previously returned `None`.
24492460
#[inline]
24502461
#[unstable(feature = "iter_reset_fuse", reason = "seems marginal")]
2462+
#[deprecated(since = "1.3.0",
2463+
reason = "unusual for adaptors to have one-off methods")]
24512464
pub fn reset_fuse(&mut self) {
24522465
self.done = false
24532466
}

src/libcore/ptr.rs

+3
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,9 @@ pub unsafe fn read<T>(src: *const T) -> T {
131131
#[inline(always)]
132132
#[unstable(feature = "read_and_zero",
133133
reason = "may play a larger role in std::ptr future extensions")]
134+
#[deprecated(since = "1.3.0",
135+
reason = "a \"zero value\" will soon not actually exist for all \
136+
types once dynamic drop has been implemented")]
134137
pub unsafe fn read_and_zero<T>(dest: *mut T) -> T {
135138
// Copy the data out from `dest`:
136139
let tmp = read(&*dest);

src/librustc/lib.rs

-4
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,11 @@
3737
#![feature(dynamic_lib)]
3838
#![feature(enumset)]
3939
#![feature(fs_canonicalize)]
40-
#![feature(hash_default)]
4140
#![feature(hashmap_hasher)]
4241
#![feature(into_cow)]
4342
#![feature(iter_cmp)]
4443
#![feature(iter_arith)]
4544
#![feature(libc)]
46-
#![feature(map_in_place)]
4745
#![feature(num_bits_bytes)]
4846
#![feature(path_ext)]
4947
#![feature(quote)]
@@ -55,8 +53,6 @@
5553
#![feature(slice_bytes)]
5654
#![feature(slice_splits)]
5755
#![feature(slice_patterns)]
58-
#![feature(slice_position_elem)]
59-
#![feature(slice_concat_ext)]
6056
#![feature(staged_api)]
6157
#![feature(str_char)]
6258
#![feature(str_match_indices)]

src/librustc/metadata/creader.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -660,14 +660,14 @@ pub fn import_codemap(local_codemap: &codemap::CodeMap,
660660
// `CodeMap::new_imported_filemap()` will then translate those
661661
// coordinates to their new global frame of reference when the
662662
// offset of the FileMap is known.
663-
let lines = lines.into_inner().map_in_place(|pos| pos - start_pos);
664-
let multibyte_chars = multibyte_chars
665-
.into_inner()
666-
.map_in_place(|mbc|
667-
codemap::MultiByteChar {
668-
pos: mbc.pos - start_pos,
669-
bytes: mbc.bytes
670-
});
663+
let mut lines = lines.into_inner();
664+
for pos in &mut lines {
665+
*pos = *pos - start_pos;
666+
}
667+
let mut multibyte_chars = multibyte_chars.into_inner();
668+
for mbc in &mut multibyte_chars {
669+
mbc.pos = mbc.pos - start_pos;
670+
}
671671

672672
let local_version = local_codemap.new_imported_filemap(name,
673673
source_length,

src/librustc/metadata/cstore.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,9 @@ impl CStore {
197197
}))
198198
.collect::<Vec<_>>();
199199
libs.sort_by(|&(a, _), &(b, _)| {
200-
ordering.position_elem(&a).cmp(&ordering.position_elem(&b))
200+
let a = ordering.iter().position(|x| *x == a);
201+
let b = ordering.iter().position(|x| *x == b);
202+
a.cmp(&b)
201203
});
202204
libs
203205
}

src/librustc/metadata/decoder.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ use util::nodemap::FnvHashMap;
3535

3636
use std::cell::{Cell, RefCell};
3737
use std::collections::HashMap;
38-
use std::hash::{self, Hash, SipHasher};
38+
use std::hash::{Hash, SipHasher, Hasher};
3939
use std::io::prelude::*;
4040
use std::io;
4141
use std::rc::Rc;
@@ -89,9 +89,9 @@ pub fn maybe_find_item<'a>(item_id: ast::NodeId,
8989
fn eq_item(bytes: &[u8], item_id: ast::NodeId) -> bool {
9090
u32_from_be_bytes(bytes) == item_id
9191
}
92-
lookup_hash(items,
93-
|a| eq_item(a, item_id),
94-
hash::hash::<i64, SipHasher>(&(item_id as i64)))
92+
let mut s = SipHasher::new_with_keys(0, 0);
93+
(item_id as i64).hash(&mut s);
94+
lookup_hash(items, |a| eq_item(a, item_id), s.finish())
9595
}
9696

9797
fn find_item<'a>(item_id: ast::NodeId, items: rbml::Doc<'a>) -> rbml::Doc<'a> {

src/librustc/middle/ty.rs

-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ use std::ops;
7979
use std::rc::Rc;
8080
use std::vec::IntoIter;
8181
use collections::enum_set::{self, EnumSet, CLike};
82-
use collections::slice::SliceConcatExt;
8382
use std::collections::{HashMap, HashSet};
8483
use syntax::abi;
8584
use syntax::ast::{CrateNum, DefId, ItemImpl, ItemTrait, LOCAL_CRATE};

src/librustc/util/common.rs

+1
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ fn get_working_set_size() -> Option<usize> {
124124
}
125125

126126
#[cfg_attr(windows, allow(dead_code))]
127+
#[allow(deprecated)]
127128
fn get_proc_self_statm_field(field: usize) -> Option<usize> {
128129
use std::fs::File;
129130
use std::io::Read;

src/librustc/util/ppaux.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ impl<'tcx> fmt::Display for ty::TraitTy<'tcx> {
279279
.expect("could not lift TraitRef for printing");
280280
let projections = tcx.lift(&bounds.projection_bounds[..])
281281
.expect("could not lift projections for printing");
282-
let projections = projections.map_in_place(|p| p.0);
282+
let projections = projections.into_iter().map(|p| p.0).collect();
283283

284284
let tap = ty::Binder(TraitAndProjections(principal, projections));
285285
in_binder(f, tcx, &ty::Binder(""), Some(tap))

src/librustdoc/html/render.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
//! both occur before the crate is rendered.
3535
pub use self::ExternalLocation::*;
3636

37-
use std::ascii::OwnedAsciiExt;
37+
use std::ascii::AsciiExt;
3838
use std::cell::RefCell;
3939
use std::cmp::Ordering;
4040
use std::collections::{BTreeMap, HashMap, HashSet};
@@ -2547,7 +2547,7 @@ fn get_index_search_type(item: &clean::Item,
25472547

25482548
// Consider `self` an argument as well.
25492549
if let Some(name) = parent {
2550-
inputs.push(Type { name: Some(name.into_ascii_lowercase()) });
2550+
inputs.push(Type { name: Some(name.to_ascii_lowercase()) });
25512551
}
25522552

25532553
inputs.extend(&mut decl.inputs.values.iter().map(|arg| {
@@ -2563,7 +2563,7 @@ fn get_index_search_type(item: &clean::Item,
25632563
}
25642564

25652565
fn get_index_type(clean_type: &clean::Type) -> Type {
2566-
Type { name: get_index_type_name(clean_type).map(|s| s.into_ascii_lowercase()) }
2566+
Type { name: get_index_type_name(clean_type).map(|s| s.to_ascii_lowercase()) }
25672567
}
25682568

25692569
fn get_index_type_name(clean_type: &clean::Type) -> Option<String> {

src/librustdoc/lib.rs

-2
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,12 @@
2424
#![feature(box_syntax)]
2525
#![feature(dynamic_lib)]
2626
#![feature(libc)]
27-
#![feature(owned_ascii_ext)]
2827
#![feature(path_ext)]
2928
#![feature(path_relative_from)]
3029
#![feature(rustc_private)]
3130
#![feature(set_stdio)]
3231
#![feature(slice_patterns)]
3332
#![feature(staged_api)]
34-
#![feature(subslice_offset)]
3533
#![feature(test)]
3634
#![feature(unicode)]
3735
#![feature(vec_push_all)]

src/librustdoc/markdown.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ fn extract_leading_metadata<'a>(s: &'a str) -> (Vec<&'a str>, &'a str) {
3434
// remove %<whitespace>
3535
metadata.push(line[1..].trim_left())
3636
} else {
37-
let line_start_byte = s.subslice_offset(line);
37+
let line_start_byte = s.find(line).unwrap();
3838
return (metadata, &s[line_start_byte..]);
3939
}
4040
}

src/libstd/ascii.rs

+9
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ use mem;
2020
/// Extension methods for ASCII-subset only operations on owned strings
2121
#[unstable(feature = "owned_ascii_ext",
2222
reason = "would prefer to do this in a more general way")]
23+
#[deprecated(since = "1.3.0",
24+
reason = "hasn't yet proved essential to be in the standard library")]
25+
#[allow(deprecated)]
2326
pub trait OwnedAsciiExt {
2427
/// Converts the string to ASCII upper case:
2528
/// ASCII letters 'a' to 'z' are mapped to 'A' to 'Z',
@@ -164,11 +167,13 @@ impl AsciiExt for str {
164167
}
165168

166169
#[inline]
170+
#[allow(deprecated)]
167171
fn to_ascii_uppercase(&self) -> String {
168172
self.to_string().into_ascii_uppercase()
169173
}
170174

171175
#[inline]
176+
#[allow(deprecated)]
172177
fn to_ascii_lowercase(&self) -> String {
173178
self.to_string().into_ascii_lowercase()
174179
}
@@ -189,6 +194,7 @@ impl AsciiExt for str {
189194
}
190195
}
191196

197+
#[allow(deprecated)]
192198
impl OwnedAsciiExt for String {
193199
#[inline]
194200
fn into_ascii_uppercase(self) -> String {
@@ -212,11 +218,13 @@ impl AsciiExt for [u8] {
212218
}
213219

214220
#[inline]
221+
#[allow(deprecated)]
215222
fn to_ascii_uppercase(&self) -> Vec<u8> {
216223
self.to_vec().into_ascii_uppercase()
217224
}
218225

219226
#[inline]
227+
#[allow(deprecated)]
220228
fn to_ascii_lowercase(&self) -> Vec<u8> {
221229
self.to_vec().into_ascii_lowercase()
222230
}
@@ -242,6 +250,7 @@ impl AsciiExt for [u8] {
242250
}
243251
}
244252

253+
#[allow(deprecated)]
245254
impl OwnedAsciiExt for Vec<u8> {
246255
#[inline]
247256
fn into_ascii_uppercase(mut self) -> Vec<u8> {

0 commit comments

Comments
 (0)