Skip to content

Commit 81d1feb

Browse files
committed
Remove #[allow(deprecated)] from libstd
1 parent 72841b1 commit 81d1feb

File tree

13 files changed

+59
-53
lines changed

13 files changed

+59
-53
lines changed

src/libstd/ascii.rs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ use mem;
2121
use option::{Option, Some, None};
2222
use slice::{ImmutableSlice, MutableSlice, Slice};
2323
use str::{Str, StrSlice};
24-
use str;
25-
use string::String;
24+
use string::{mod, String};
2625
use to_string::IntoStr;
2726
use vec::Vec;
2827

@@ -113,7 +112,7 @@ impl Ascii {
113112
/// Check if the character is a letter or number
114113
#[inline]
115114
pub fn is_alphanumeric(&self) -> bool {
116-
self.is_alpha() || self.is_digit()
115+
self.is_alphabetic() || self.is_digit()
117116
}
118117

119118
/// Check if the character is a space or horizontal tab
@@ -169,7 +168,7 @@ impl Ascii {
169168
/// Checks if the character is punctuation
170169
#[inline]
171170
pub fn is_punctuation(&self) -> bool {
172-
self.is_graph() && !self.is_alnum()
171+
self.is_graph() && !self.is_alphanumeric()
173172
}
174173

175174
/// Checks if the character is a valid hex digit
@@ -338,12 +337,12 @@ impl<'a> AsciiStr for &'a [Ascii] {
338337

339338
#[inline]
340339
fn to_lower(&self) -> Vec<Ascii> {
341-
self.iter().map(|a| a.to_lower()).collect()
340+
self.iter().map(|a| a.to_lowercase()).collect()
342341
}
343342

344343
#[inline]
345344
fn to_upper(&self) -> Vec<Ascii> {
346-
self.iter().map(|a| a.to_upper()).collect()
345+
self.iter().map(|a| a.to_uppercase()).collect()
347346
}
348347

349348
#[inline]
@@ -410,13 +409,13 @@ impl<'a> AsciiExt<String> for &'a str {
410409
#[inline]
411410
fn to_ascii_upper(&self) -> String {
412411
// Vec<u8>::to_ascii_upper() preserves the UTF-8 invariant.
413-
unsafe { str::raw::from_utf8_owned(self.as_bytes().to_ascii_upper()) }
412+
unsafe { string::raw::from_utf8(self.as_bytes().to_ascii_upper()) }
414413
}
415414

416415
#[inline]
417416
fn to_ascii_lower(&self) -> String {
418417
// Vec<u8>::to_ascii_lower() preserves the UTF-8 invariant.
419-
unsafe { str::raw::from_utf8_owned(self.as_bytes().to_ascii_lower()) }
418+
unsafe { string::raw::from_utf8(self.as_bytes().to_ascii_lower()) }
420419
}
421420

422421
#[inline]
@@ -429,13 +428,13 @@ impl OwnedAsciiExt for String {
429428
#[inline]
430429
fn into_ascii_upper(self) -> String {
431430
// Vec<u8>::into_ascii_upper() preserves the UTF-8 invariant.
432-
unsafe { str::raw::from_utf8_owned(self.into_bytes().into_ascii_upper()) }
431+
unsafe { string::raw::from_utf8(self.into_bytes().into_ascii_upper()) }
433432
}
434433

435434
#[inline]
436435
fn into_ascii_lower(self) -> String {
437436
// Vec<u8>::into_ascii_lower() preserves the UTF-8 invariant.
438-
unsafe { str::raw::from_utf8_owned(self.into_bytes().into_ascii_lower()) }
437+
unsafe { string::raw::from_utf8(self.into_bytes().into_ascii_lower()) }
439438
}
440439
}
441440

src/libstd/collections/hashmap/map.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1288,7 +1288,7 @@ impl<K: Eq + Hash<S>, V: Clone, S, H: Hasher<S>> HashMap<K, V, H> {
12881288
/// let s: String = map.get_copy(&1);
12891289
/// ```
12901290
pub fn get_copy(&self, k: &K) -> V {
1291-
(*self.get(k)).clone()
1291+
self[*k].clone()
12921292
}
12931293
}
12941294

@@ -1325,6 +1325,7 @@ impl<K: Eq + Hash<S>, V, S, H: Hasher<S> + Default> Default for HashMap<K, V, H>
13251325

13261326
impl<K: Eq + Hash<S>, V, S, H: Hasher<S>> Index<K, V> for HashMap<K, V, H> {
13271327
#[inline]
1328+
#[allow(deprecated)]
13281329
fn index<'a>(&'a self, index: &K) -> &'a V {
13291330
self.get(index)
13301331
}

src/libstd/collections/hashmap/table.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -846,8 +846,8 @@ impl<K: Clone, V: Clone> Clone for RawTable<K, V> {
846846
(full.hash(), k.clone(), v.clone())
847847
};
848848
*new_buckets.raw.hash = h.inspect();
849-
mem::overwrite(new_buckets.raw.key, k);
850-
mem::overwrite(new_buckets.raw.val, v);
849+
ptr::write(new_buckets.raw.key, k);
850+
ptr::write(new_buckets.raw.val, v);
851851
}
852852
Empty(..) => {
853853
*new_buckets.raw.hash = EMPTY_BUCKET;

src/libstd/failure.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ impl Writer for Stdio {
3838
}
3939

4040
pub fn on_fail(obj: &Any + Send, file: &'static str, line: uint) {
41-
let msg = match obj.as_ref::<&'static str>() {
41+
let msg = match obj.downcast_ref::<&'static str>() {
4242
Some(s) => *s,
43-
None => match obj.as_ref::<String>() {
43+
None => match obj.downcast_ref::<String>() {
4444
Some(s) => s.as_slice(),
4545
None => "Box<Any>",
4646
}

src/libstd/io/buffered.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ impl<W: Writer> BufferedWriter<W> {
162162

163163
fn flush_buf(&mut self) -> IoResult<()> {
164164
if self.pos != 0 {
165-
let ret = self.inner.get_mut_ref().write(self.buf.slice_to(self.pos));
165+
let ret = self.inner.as_mut().unwrap().write(self.buf.slice_to(self.pos));
166166
self.pos = 0;
167167
ret
168168
} else {
@@ -174,7 +174,7 @@ impl<W: Writer> BufferedWriter<W> {
174174
///
175175
/// This type does not expose the ability to get a mutable reference to the
176176
/// underlying reader because that could possibly corrupt the buffer.
177-
pub fn get_ref<'a>(&'a self) -> &'a W { self.inner.get_ref() }
177+
pub fn get_ref<'a>(&'a self) -> &'a W { self.inner.as_ref().unwrap() }
178178

179179
/// Unwraps this `BufferedWriter`, returning the underlying writer.
180180
///
@@ -193,7 +193,7 @@ impl<W: Writer> Writer for BufferedWriter<W> {
193193
}
194194

195195
if buf.len() > self.buf.len() {
196-
self.inner.get_mut_ref().write(buf)
196+
self.inner.as_mut().unwrap().write(buf)
197197
} else {
198198
let dst = self.buf.slice_from_mut(self.pos);
199199
slice::bytes::copy_memory(dst, buf);
@@ -203,7 +203,7 @@ impl<W: Writer> Writer for BufferedWriter<W> {
203203
}
204204

205205
fn flush(&mut self) -> IoResult<()> {
206-
self.flush_buf().and_then(|()| self.inner.get_mut_ref().flush())
206+
self.flush_buf().and_then(|()| self.inner.as_mut().unwrap().flush())
207207
}
208208
}
209209

@@ -273,7 +273,7 @@ impl<W> InternalBufferedWriter<W> {
273273

274274
impl<W: Reader> Reader for InternalBufferedWriter<W> {
275275
fn read(&mut self, buf: &mut [u8]) -> IoResult<uint> {
276-
self.get_mut().inner.get_mut_ref().read(buf)
276+
self.get_mut().inner.as_mut().unwrap().read(buf)
277277
}
278278
}
279279

src/libstd/io/extensions.rs

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,14 @@
1616
// FIXME: Iteration should probably be considered separately
1717

1818
use collections::{Collection, MutableSeq};
19+
use io::{IoError, IoResult, Reader};
20+
use io;
1921
use iter::Iterator;
22+
use num::Int;
2023
use option::{Option, Some, None};
24+
use ptr::RawPtr;
2125
use result::{Ok, Err};
22-
use io;
23-
use io::{IoError, IoResult, Reader};
2426
use slice::{ImmutableSlice, Slice};
25-
use ptr::RawPtr;
2627

2728
/// An iterator that reads a single byte on each iteration,
2829
/// until `.read_byte()` returns `EndOfFile`.
@@ -76,16 +77,15 @@ impl<'r, R: Reader> Iterator<IoResult<u8>> for Bytes<'r, R> {
7677
///
7778
/// This function returns the value returned by the callback, for convenience.
7879
pub fn u64_to_le_bytes<T>(n: u64, size: uint, f: |v: &[u8]| -> T) -> T {
79-
use mem::{to_le16, to_le32, to_le64};
8080
use mem::transmute;
8181

8282
// LLVM fails to properly optimize this when using shifts instead of the to_le* intrinsics
8383
assert!(size <= 8u);
8484
match size {
8585
1u => f(&[n as u8]),
86-
2u => f(unsafe { transmute::<_, [u8, ..2]>(to_le16(n as u16)) }),
87-
4u => f(unsafe { transmute::<_, [u8, ..4]>(to_le32(n as u32)) }),
88-
8u => f(unsafe { transmute::<_, [u8, ..8]>(to_le64(n)) }),
86+
2u => f(unsafe { transmute::<_, [u8, ..2]>((n as u16).to_le()) }),
87+
4u => f(unsafe { transmute::<_, [u8, ..4]>((n as u32).to_le()) }),
88+
8u => f(unsafe { transmute::<_, [u8, ..8]>(n.to_le()) }),
8989
_ => {
9090

9191
let mut bytes = vec!();
@@ -116,16 +116,15 @@ pub fn u64_to_le_bytes<T>(n: u64, size: uint, f: |v: &[u8]| -> T) -> T {
116116
///
117117
/// This function returns the value returned by the callback, for convenience.
118118
pub fn u64_to_be_bytes<T>(n: u64, size: uint, f: |v: &[u8]| -> T) -> T {
119-
use mem::{to_be16, to_be32, to_be64};
120119
use mem::transmute;
121120

122121
// LLVM fails to properly optimize this when using shifts instead of the to_be* intrinsics
123122
assert!(size <= 8u);
124123
match size {
125124
1u => f(&[n as u8]),
126-
2u => f(unsafe { transmute::<_, [u8, ..2]>(to_be16(n as u16)) }),
127-
4u => f(unsafe { transmute::<_, [u8, ..4]>(to_be32(n as u32)) }),
128-
8u => f(unsafe { transmute::<_, [u8, ..8]>(to_be64(n)) }),
125+
2u => f(unsafe { transmute::<_, [u8, ..2]>((n as u16).to_be()) }),
126+
4u => f(unsafe { transmute::<_, [u8, ..4]>((n as u32).to_be()) }),
127+
8u => f(unsafe { transmute::<_, [u8, ..8]>(n.to_be()) }),
129128
_ => {
130129
let mut bytes = vec!();
131130
let mut i = size;
@@ -152,7 +151,6 @@ pub fn u64_to_be_bytes<T>(n: u64, size: uint, f: |v: &[u8]| -> T) -> T {
152151
/// 32-bit value is parsed.
153152
pub fn u64_from_be_bytes(data: &[u8], start: uint, size: uint) -> u64 {
154153
use ptr::{copy_nonoverlapping_memory};
155-
use mem::from_be64;
156154
use slice::MutableSlice;
157155

158156
assert!(size <= 8u);
@@ -166,7 +164,7 @@ pub fn u64_from_be_bytes(data: &[u8], start: uint, size: uint) -> u64 {
166164
let ptr = data.as_ptr().offset(start as int);
167165
let out = buf.as_mut_ptr();
168166
copy_nonoverlapping_memory(out.offset((8 - size) as int), ptr, size);
169-
from_be64(*(out as *const u64))
167+
(*(out as *const u64)).to_be()
170168
}
171169
}
172170

src/libstd/io/net/ip.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,12 @@ impl<'a> Parser<'a> {
103103
// Commit only if parser read till EOF
104104
fn read_till_eof<T>(&mut self, cb: |&mut Parser| -> Option<T>)
105105
-> Option<T> {
106-
self.read_atomically(|p| cb(p).filtered(|_| p.is_eof()))
106+
self.read_atomically(|p| {
107+
match cb(p) {
108+
Some(x) => if p.is_eof() {Some(x)} else {None},
109+
None => None,
110+
}
111+
})
107112
}
108113

109114
// Return result of first successful parser
@@ -152,7 +157,10 @@ impl<'a> Parser<'a> {
152157
// Return char and advance iff next char is equal to requested
153158
fn read_given_char(&mut self, c: char) -> Option<char> {
154159
self.read_atomically(|p| {
155-
p.read_char().filtered(|&next| next == c)
160+
match p.read_char() {
161+
Some(next) if next == c => Some(next),
162+
_ => None,
163+
}
156164
})
157165
}
158166

@@ -232,8 +240,8 @@ impl<'a> Parser<'a> {
232240
fn ipv6_addr_from_head_tail(head: &[u16], tail: &[u16]) -> IpAddr {
233241
assert!(head.len() + tail.len() <= 8);
234242
let mut gs = [0u16, ..8];
235-
gs.copy_from(head);
236-
gs.slice_mut(8 - tail.len(), 8).copy_from(tail);
243+
gs.clone_from_slice(head);
244+
gs.slice_mut(8 - tail.len(), 8).clone_from_slice(tail);
237245
Ipv6Addr(gs[0], gs[1], gs[2], gs[3], gs[4], gs[5], gs[6], gs[7])
238246
}
239247

src/libstd/io/tempfile.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ impl TempDir {
7979

8080
/// Access the wrapped `std::path::Path` to the temporary directory.
8181
pub fn path<'a>(&'a self) -> &'a Path {
82-
self.path.get_ref()
82+
self.path.as_ref().unwrap()
8383
}
8484

8585
/// Close and remove the temporary directory

src/libstd/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@
112112
// Don't link to std. We are std.
113113
#![no_std]
114114

115-
#![allow(deprecated)]
116115
#![deny(missing_doc)]
117116

118117
#![reexport_test_harness_main = "test_main"]

src/libstd/os.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -276,17 +276,18 @@ pub fn env_as_bytes() -> Vec<(Vec<u8>,Vec<u8>)> {
276276
extern {
277277
fn rust_env_pairs() -> *const *const c_char;
278278
}
279-
let environ = rust_env_pairs();
279+
let mut environ = rust_env_pairs();
280280
if environ as uint == 0 {
281281
fail!("os::env() failure getting env string from OS: {}",
282282
os::last_os_error());
283283
}
284284
let mut result = Vec::new();
285-
ptr::array_each(environ, |e| {
285+
while *environ != 0 as *const _ {
286286
let env_pair =
287-
Vec::from_slice(CString::new(e, false).as_bytes_no_nul());
287+
Vec::from_slice(CString::new(*environ, false).as_bytes_no_nul());
288288
result.push(env_pair);
289-
});
289+
environ = environ.offset(1);
290+
}
290291
result
291292
}
292293

src/libstd/path/posix.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ impl GenericPath for Path {
264264

265265
#[inline]
266266
fn is_absolute(&self) -> bool {
267-
*self.repr.get(0) == SEP_BYTE
267+
self.repr[0] == SEP_BYTE
268268
}
269269

270270
fn is_ancestor_of(&self, other: &Path) -> bool {
@@ -409,7 +409,7 @@ impl Path {
409409
/// /a/b/c and a/b/c yield the same set of components.
410410
/// A path of "/" yields no components. A path of "." yields one component.
411411
pub fn components<'a>(&'a self) -> Components<'a> {
412-
let v = if *self.repr.get(0) == SEP_BYTE {
412+
let v = if self.repr[0] == SEP_BYTE {
413413
self.repr.slice_from(1)
414414
} else { self.repr.as_slice() };
415415
let mut ret = v.split(is_sep_byte);

src/libstd/path/windows.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -264,10 +264,10 @@ impl GenericPathUnsafe for Path {
264264
let repr = me.repr.as_slice();
265265
match me.prefix {
266266
Some(DiskPrefix) => {
267-
repr.as_bytes()[0] == path.as_bytes()[0].to_ascii().to_upper().to_byte()
267+
repr.as_bytes()[0] == path.as_bytes()[0].to_ascii().to_uppercase().to_byte()
268268
}
269269
Some(VerbatimDiskPrefix) => {
270-
repr.as_bytes()[4] == path.as_bytes()[0].to_ascii().to_upper().to_byte()
270+
repr.as_bytes()[4] == path.as_bytes()[0].to_ascii().to_uppercase().to_byte()
271271
}
272272
_ => false
273273
}
@@ -776,9 +776,9 @@ impl Path {
776776
let mut s = String::from_str(s.slice_to(len));
777777
unsafe {
778778
let v = s.as_mut_vec();
779-
*v.get_mut(0) = v.get(0)
779+
*v.get_mut(0) = (*v)[0]
780780
.to_ascii()
781-
.to_upper()
781+
.to_uppercase()
782782
.to_byte();
783783
}
784784
if is_abs {
@@ -794,7 +794,7 @@ impl Path {
794794
let mut s = String::from_str(s.slice_to(len));
795795
unsafe {
796796
let v = s.as_mut_vec();
797-
*v.get_mut(4) = v.get(4).to_ascii().to_upper().to_byte();
797+
*v.get_mut(4) = (*v)[4].to_ascii().to_uppercase().to_byte();
798798
}
799799
Some(s)
800800
}
@@ -815,12 +815,12 @@ impl Path {
815815
let mut s = String::with_capacity(n);
816816
match prefix {
817817
Some(DiskPrefix) => {
818-
s.push_char(prefix_.as_bytes()[0].to_ascii().to_upper().to_char());
818+
s.push_char(prefix_.as_bytes()[0].to_ascii().to_uppercase().to_char());
819819
s.push_char(':');
820820
}
821821
Some(VerbatimDiskPrefix) => {
822822
s.push_str(prefix_.slice_to(4));
823-
s.push_char(prefix_.as_bytes()[4].to_ascii().to_upper().to_char());
823+
s.push_char(prefix_.as_bytes()[4].to_ascii().to_uppercase().to_char());
824824
s.push_str(prefix_.slice_from(5));
825825
}
826826
Some(UNCPrefix(a,b)) => {

src/libstd/sync/task_pool.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ impl<T> TaskPool<T> {
7979
/// Executes the function `f` on a task in the pool. The function
8080
/// receives a reference to the local data returned by the `init_fn`.
8181
pub fn execute(&mut self, f: proc(&T):Send) {
82-
self.channels.get(self.next_index).send(Execute(f));
82+
self.channels[self.next_index].send(Execute(f));
8383
self.next_index += 1;
8484
if self.next_index == self.channels.len() { self.next_index = 0; }
8585
}

0 commit comments

Comments
 (0)