Remove #[allow(deprecated)] from libstd
This commit is contained in:
parent
72841b128d
commit
81d1feb980
@ -21,8 +21,7 @@ use mem;
|
||||
use option::{Option, Some, None};
|
||||
use slice::{ImmutableSlice, MutableSlice, Slice};
|
||||
use str::{Str, StrSlice};
|
||||
use str;
|
||||
use string::String;
|
||||
use string::{mod, String};
|
||||
use to_string::IntoStr;
|
||||
use vec::Vec;
|
||||
|
||||
@ -113,7 +112,7 @@ impl Ascii {
|
||||
/// Check if the character is a letter or number
|
||||
#[inline]
|
||||
pub fn is_alphanumeric(&self) -> bool {
|
||||
self.is_alpha() || self.is_digit()
|
||||
self.is_alphabetic() || self.is_digit()
|
||||
}
|
||||
|
||||
/// Check if the character is a space or horizontal tab
|
||||
@ -169,7 +168,7 @@ impl Ascii {
|
||||
/// Checks if the character is punctuation
|
||||
#[inline]
|
||||
pub fn is_punctuation(&self) -> bool {
|
||||
self.is_graph() && !self.is_alnum()
|
||||
self.is_graph() && !self.is_alphanumeric()
|
||||
}
|
||||
|
||||
/// Checks if the character is a valid hex digit
|
||||
@ -338,12 +337,12 @@ impl<'a> AsciiStr for &'a [Ascii] {
|
||||
|
||||
#[inline]
|
||||
fn to_lower(&self) -> Vec<Ascii> {
|
||||
self.iter().map(|a| a.to_lower()).collect()
|
||||
self.iter().map(|a| a.to_lowercase()).collect()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn to_upper(&self) -> Vec<Ascii> {
|
||||
self.iter().map(|a| a.to_upper()).collect()
|
||||
self.iter().map(|a| a.to_uppercase()).collect()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
@ -410,13 +409,13 @@ impl<'a> AsciiExt<String> for &'a str {
|
||||
#[inline]
|
||||
fn to_ascii_upper(&self) -> String {
|
||||
// Vec<u8>::to_ascii_upper() preserves the UTF-8 invariant.
|
||||
unsafe { str::raw::from_utf8_owned(self.as_bytes().to_ascii_upper()) }
|
||||
unsafe { string::raw::from_utf8(self.as_bytes().to_ascii_upper()) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn to_ascii_lower(&self) -> String {
|
||||
// Vec<u8>::to_ascii_lower() preserves the UTF-8 invariant.
|
||||
unsafe { str::raw::from_utf8_owned(self.as_bytes().to_ascii_lower()) }
|
||||
unsafe { string::raw::from_utf8(self.as_bytes().to_ascii_lower()) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
@ -429,13 +428,13 @@ impl OwnedAsciiExt for String {
|
||||
#[inline]
|
||||
fn into_ascii_upper(self) -> String {
|
||||
// Vec<u8>::into_ascii_upper() preserves the UTF-8 invariant.
|
||||
unsafe { str::raw::from_utf8_owned(self.into_bytes().into_ascii_upper()) }
|
||||
unsafe { string::raw::from_utf8(self.into_bytes().into_ascii_upper()) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn into_ascii_lower(self) -> String {
|
||||
// Vec<u8>::into_ascii_lower() preserves the UTF-8 invariant.
|
||||
unsafe { str::raw::from_utf8_owned(self.into_bytes().into_ascii_lower()) }
|
||||
unsafe { string::raw::from_utf8(self.into_bytes().into_ascii_lower()) }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1288,7 +1288,7 @@ impl<K: Eq + Hash<S>, V: Clone, S, H: Hasher<S>> HashMap<K, V, H> {
|
||||
/// let s: String = map.get_copy(&1);
|
||||
/// ```
|
||||
pub fn get_copy(&self, k: &K) -> V {
|
||||
(*self.get(k)).clone()
|
||||
self[*k].clone()
|
||||
}
|
||||
}
|
||||
|
||||
@ -1325,6 +1325,7 @@ impl<K: Eq + Hash<S>, V, S, H: Hasher<S> + Default> Default for HashMap<K, V, H>
|
||||
|
||||
impl<K: Eq + Hash<S>, V, S, H: Hasher<S>> Index<K, V> for HashMap<K, V, H> {
|
||||
#[inline]
|
||||
#[allow(deprecated)]
|
||||
fn index<'a>(&'a self, index: &K) -> &'a V {
|
||||
self.get(index)
|
||||
}
|
||||
|
@ -846,8 +846,8 @@ impl<K: Clone, V: Clone> Clone for RawTable<K, V> {
|
||||
(full.hash(), k.clone(), v.clone())
|
||||
};
|
||||
*new_buckets.raw.hash = h.inspect();
|
||||
mem::overwrite(new_buckets.raw.key, k);
|
||||
mem::overwrite(new_buckets.raw.val, v);
|
||||
ptr::write(new_buckets.raw.key, k);
|
||||
ptr::write(new_buckets.raw.val, v);
|
||||
}
|
||||
Empty(..) => {
|
||||
*new_buckets.raw.hash = EMPTY_BUCKET;
|
||||
|
@ -38,9 +38,9 @@ impl Writer for Stdio {
|
||||
}
|
||||
|
||||
pub fn on_fail(obj: &Any + Send, file: &'static str, line: uint) {
|
||||
let msg = match obj.as_ref::<&'static str>() {
|
||||
let msg = match obj.downcast_ref::<&'static str>() {
|
||||
Some(s) => *s,
|
||||
None => match obj.as_ref::<String>() {
|
||||
None => match obj.downcast_ref::<String>() {
|
||||
Some(s) => s.as_slice(),
|
||||
None => "Box<Any>",
|
||||
}
|
||||
|
@ -162,7 +162,7 @@ impl<W: Writer> BufferedWriter<W> {
|
||||
|
||||
fn flush_buf(&mut self) -> IoResult<()> {
|
||||
if self.pos != 0 {
|
||||
let ret = self.inner.get_mut_ref().write(self.buf.slice_to(self.pos));
|
||||
let ret = self.inner.as_mut().unwrap().write(self.buf.slice_to(self.pos));
|
||||
self.pos = 0;
|
||||
ret
|
||||
} else {
|
||||
@ -174,7 +174,7 @@ impl<W: Writer> BufferedWriter<W> {
|
||||
///
|
||||
/// This type does not expose the ability to get a mutable reference to the
|
||||
/// underlying reader because that could possibly corrupt the buffer.
|
||||
pub fn get_ref<'a>(&'a self) -> &'a W { self.inner.get_ref() }
|
||||
pub fn get_ref<'a>(&'a self) -> &'a W { self.inner.as_ref().unwrap() }
|
||||
|
||||
/// Unwraps this `BufferedWriter`, returning the underlying writer.
|
||||
///
|
||||
@ -193,7 +193,7 @@ impl<W: Writer> Writer for BufferedWriter<W> {
|
||||
}
|
||||
|
||||
if buf.len() > self.buf.len() {
|
||||
self.inner.get_mut_ref().write(buf)
|
||||
self.inner.as_mut().unwrap().write(buf)
|
||||
} else {
|
||||
let dst = self.buf.slice_from_mut(self.pos);
|
||||
slice::bytes::copy_memory(dst, buf);
|
||||
@ -203,7 +203,7 @@ impl<W: Writer> Writer for BufferedWriter<W> {
|
||||
}
|
||||
|
||||
fn flush(&mut self) -> IoResult<()> {
|
||||
self.flush_buf().and_then(|()| self.inner.get_mut_ref().flush())
|
||||
self.flush_buf().and_then(|()| self.inner.as_mut().unwrap().flush())
|
||||
}
|
||||
}
|
||||
|
||||
@ -273,7 +273,7 @@ impl<W> InternalBufferedWriter<W> {
|
||||
|
||||
impl<W: Reader> Reader for InternalBufferedWriter<W> {
|
||||
fn read(&mut self, buf: &mut [u8]) -> IoResult<uint> {
|
||||
self.get_mut().inner.get_mut_ref().read(buf)
|
||||
self.get_mut().inner.as_mut().unwrap().read(buf)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -16,13 +16,14 @@
|
||||
// FIXME: Iteration should probably be considered separately
|
||||
|
||||
use collections::{Collection, MutableSeq};
|
||||
use iter::Iterator;
|
||||
use option::{Option, Some, None};
|
||||
use result::{Ok, Err};
|
||||
use io;
|
||||
use io::{IoError, IoResult, Reader};
|
||||
use slice::{ImmutableSlice, Slice};
|
||||
use io;
|
||||
use iter::Iterator;
|
||||
use num::Int;
|
||||
use option::{Option, Some, None};
|
||||
use ptr::RawPtr;
|
||||
use result::{Ok, Err};
|
||||
use slice::{ImmutableSlice, Slice};
|
||||
|
||||
/// An iterator that reads a single byte on each iteration,
|
||||
/// until `.read_byte()` returns `EndOfFile`.
|
||||
@ -76,16 +77,15 @@ impl<'r, R: Reader> Iterator<IoResult<u8>> for Bytes<'r, R> {
|
||||
///
|
||||
/// This function returns the value returned by the callback, for convenience.
|
||||
pub fn u64_to_le_bytes<T>(n: u64, size: uint, f: |v: &[u8]| -> T) -> T {
|
||||
use mem::{to_le16, to_le32, to_le64};
|
||||
use mem::transmute;
|
||||
|
||||
// LLVM fails to properly optimize this when using shifts instead of the to_le* intrinsics
|
||||
assert!(size <= 8u);
|
||||
match size {
|
||||
1u => f(&[n as u8]),
|
||||
2u => f(unsafe { transmute::<_, [u8, ..2]>(to_le16(n as u16)) }),
|
||||
4u => f(unsafe { transmute::<_, [u8, ..4]>(to_le32(n as u32)) }),
|
||||
8u => f(unsafe { transmute::<_, [u8, ..8]>(to_le64(n)) }),
|
||||
2u => f(unsafe { transmute::<_, [u8, ..2]>((n as u16).to_le()) }),
|
||||
4u => f(unsafe { transmute::<_, [u8, ..4]>((n as u32).to_le()) }),
|
||||
8u => f(unsafe { transmute::<_, [u8, ..8]>(n.to_le()) }),
|
||||
_ => {
|
||||
|
||||
let mut bytes = vec!();
|
||||
@ -116,16 +116,15 @@ pub fn u64_to_le_bytes<T>(n: u64, size: uint, f: |v: &[u8]| -> T) -> T {
|
||||
///
|
||||
/// This function returns the value returned by the callback, for convenience.
|
||||
pub fn u64_to_be_bytes<T>(n: u64, size: uint, f: |v: &[u8]| -> T) -> T {
|
||||
use mem::{to_be16, to_be32, to_be64};
|
||||
use mem::transmute;
|
||||
|
||||
// LLVM fails to properly optimize this when using shifts instead of the to_be* intrinsics
|
||||
assert!(size <= 8u);
|
||||
match size {
|
||||
1u => f(&[n as u8]),
|
||||
2u => f(unsafe { transmute::<_, [u8, ..2]>(to_be16(n as u16)) }),
|
||||
4u => f(unsafe { transmute::<_, [u8, ..4]>(to_be32(n as u32)) }),
|
||||
8u => f(unsafe { transmute::<_, [u8, ..8]>(to_be64(n)) }),
|
||||
2u => f(unsafe { transmute::<_, [u8, ..2]>((n as u16).to_be()) }),
|
||||
4u => f(unsafe { transmute::<_, [u8, ..4]>((n as u32).to_be()) }),
|
||||
8u => f(unsafe { transmute::<_, [u8, ..8]>(n.to_be()) }),
|
||||
_ => {
|
||||
let mut bytes = vec!();
|
||||
let mut i = size;
|
||||
@ -152,7 +151,6 @@ pub fn u64_to_be_bytes<T>(n: u64, size: uint, f: |v: &[u8]| -> T) -> T {
|
||||
/// 32-bit value is parsed.
|
||||
pub fn u64_from_be_bytes(data: &[u8], start: uint, size: uint) -> u64 {
|
||||
use ptr::{copy_nonoverlapping_memory};
|
||||
use mem::from_be64;
|
||||
use slice::MutableSlice;
|
||||
|
||||
assert!(size <= 8u);
|
||||
@ -166,7 +164,7 @@ pub fn u64_from_be_bytes(data: &[u8], start: uint, size: uint) -> u64 {
|
||||
let ptr = data.as_ptr().offset(start as int);
|
||||
let out = buf.as_mut_ptr();
|
||||
copy_nonoverlapping_memory(out.offset((8 - size) as int), ptr, size);
|
||||
from_be64(*(out as *const u64))
|
||||
(*(out as *const u64)).to_be()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -103,7 +103,12 @@ impl<'a> Parser<'a> {
|
||||
// Commit only if parser read till EOF
|
||||
fn read_till_eof<T>(&mut self, cb: |&mut Parser| -> Option<T>)
|
||||
-> Option<T> {
|
||||
self.read_atomically(|p| cb(p).filtered(|_| p.is_eof()))
|
||||
self.read_atomically(|p| {
|
||||
match cb(p) {
|
||||
Some(x) => if p.is_eof() {Some(x)} else {None},
|
||||
None => None,
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// Return result of first successful parser
|
||||
@ -152,7 +157,10 @@ impl<'a> Parser<'a> {
|
||||
// Return char and advance iff next char is equal to requested
|
||||
fn read_given_char(&mut self, c: char) -> Option<char> {
|
||||
self.read_atomically(|p| {
|
||||
p.read_char().filtered(|&next| next == c)
|
||||
match p.read_char() {
|
||||
Some(next) if next == c => Some(next),
|
||||
_ => None,
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@ -232,8 +240,8 @@ impl<'a> Parser<'a> {
|
||||
fn ipv6_addr_from_head_tail(head: &[u16], tail: &[u16]) -> IpAddr {
|
||||
assert!(head.len() + tail.len() <= 8);
|
||||
let mut gs = [0u16, ..8];
|
||||
gs.copy_from(head);
|
||||
gs.slice_mut(8 - tail.len(), 8).copy_from(tail);
|
||||
gs.clone_from_slice(head);
|
||||
gs.slice_mut(8 - tail.len(), 8).clone_from_slice(tail);
|
||||
Ipv6Addr(gs[0], gs[1], gs[2], gs[3], gs[4], gs[5], gs[6], gs[7])
|
||||
}
|
||||
|
||||
|
@ -79,7 +79,7 @@ impl TempDir {
|
||||
|
||||
/// Access the wrapped `std::path::Path` to the temporary directory.
|
||||
pub fn path<'a>(&'a self) -> &'a Path {
|
||||
self.path.get_ref()
|
||||
self.path.as_ref().unwrap()
|
||||
}
|
||||
|
||||
/// Close and remove the temporary directory
|
||||
|
@ -112,7 +112,6 @@
|
||||
// Don't link to std. We are std.
|
||||
#![no_std]
|
||||
|
||||
#![allow(deprecated)]
|
||||
#![deny(missing_doc)]
|
||||
|
||||
#![reexport_test_harness_main = "test_main"]
|
||||
|
@ -276,17 +276,18 @@ pub fn env_as_bytes() -> Vec<(Vec<u8>,Vec<u8>)> {
|
||||
extern {
|
||||
fn rust_env_pairs() -> *const *const c_char;
|
||||
}
|
||||
let environ = rust_env_pairs();
|
||||
let mut environ = rust_env_pairs();
|
||||
if environ as uint == 0 {
|
||||
fail!("os::env() failure getting env string from OS: {}",
|
||||
os::last_os_error());
|
||||
}
|
||||
let mut result = Vec::new();
|
||||
ptr::array_each(environ, |e| {
|
||||
while *environ != 0 as *const _ {
|
||||
let env_pair =
|
||||
Vec::from_slice(CString::new(e, false).as_bytes_no_nul());
|
||||
Vec::from_slice(CString::new(*environ, false).as_bytes_no_nul());
|
||||
result.push(env_pair);
|
||||
});
|
||||
environ = environ.offset(1);
|
||||
}
|
||||
result
|
||||
}
|
||||
|
||||
|
@ -264,7 +264,7 @@ impl GenericPath for Path {
|
||||
|
||||
#[inline]
|
||||
fn is_absolute(&self) -> bool {
|
||||
*self.repr.get(0) == SEP_BYTE
|
||||
self.repr[0] == SEP_BYTE
|
||||
}
|
||||
|
||||
fn is_ancestor_of(&self, other: &Path) -> bool {
|
||||
@ -409,7 +409,7 @@ impl Path {
|
||||
/// /a/b/c and a/b/c yield the same set of components.
|
||||
/// A path of "/" yields no components. A path of "." yields one component.
|
||||
pub fn components<'a>(&'a self) -> Components<'a> {
|
||||
let v = if *self.repr.get(0) == SEP_BYTE {
|
||||
let v = if self.repr[0] == SEP_BYTE {
|
||||
self.repr.slice_from(1)
|
||||
} else { self.repr.as_slice() };
|
||||
let mut ret = v.split(is_sep_byte);
|
||||
|
@ -264,10 +264,10 @@ impl GenericPathUnsafe for Path {
|
||||
let repr = me.repr.as_slice();
|
||||
match me.prefix {
|
||||
Some(DiskPrefix) => {
|
||||
repr.as_bytes()[0] == path.as_bytes()[0].to_ascii().to_upper().to_byte()
|
||||
repr.as_bytes()[0] == path.as_bytes()[0].to_ascii().to_uppercase().to_byte()
|
||||
}
|
||||
Some(VerbatimDiskPrefix) => {
|
||||
repr.as_bytes()[4] == path.as_bytes()[0].to_ascii().to_upper().to_byte()
|
||||
repr.as_bytes()[4] == path.as_bytes()[0].to_ascii().to_uppercase().to_byte()
|
||||
}
|
||||
_ => false
|
||||
}
|
||||
@ -776,9 +776,9 @@ impl Path {
|
||||
let mut s = String::from_str(s.slice_to(len));
|
||||
unsafe {
|
||||
let v = s.as_mut_vec();
|
||||
*v.get_mut(0) = v.get(0)
|
||||
*v.get_mut(0) = (*v)[0]
|
||||
.to_ascii()
|
||||
.to_upper()
|
||||
.to_uppercase()
|
||||
.to_byte();
|
||||
}
|
||||
if is_abs {
|
||||
@ -794,7 +794,7 @@ impl Path {
|
||||
let mut s = String::from_str(s.slice_to(len));
|
||||
unsafe {
|
||||
let v = s.as_mut_vec();
|
||||
*v.get_mut(4) = v.get(4).to_ascii().to_upper().to_byte();
|
||||
*v.get_mut(4) = (*v)[4].to_ascii().to_uppercase().to_byte();
|
||||
}
|
||||
Some(s)
|
||||
}
|
||||
@ -815,12 +815,12 @@ impl Path {
|
||||
let mut s = String::with_capacity(n);
|
||||
match prefix {
|
||||
Some(DiskPrefix) => {
|
||||
s.push_char(prefix_.as_bytes()[0].to_ascii().to_upper().to_char());
|
||||
s.push_char(prefix_.as_bytes()[0].to_ascii().to_uppercase().to_char());
|
||||
s.push_char(':');
|
||||
}
|
||||
Some(VerbatimDiskPrefix) => {
|
||||
s.push_str(prefix_.slice_to(4));
|
||||
s.push_char(prefix_.as_bytes()[4].to_ascii().to_upper().to_char());
|
||||
s.push_char(prefix_.as_bytes()[4].to_ascii().to_uppercase().to_char());
|
||||
s.push_str(prefix_.slice_from(5));
|
||||
}
|
||||
Some(UNCPrefix(a,b)) => {
|
||||
|
@ -79,7 +79,7 @@ impl<T> TaskPool<T> {
|
||||
/// Executes the function `f` on a task in the pool. The function
|
||||
/// receives a reference to the local data returned by the `init_fn`.
|
||||
pub fn execute(&mut self, f: proc(&T):Send) {
|
||||
self.channels.get(self.next_index).send(Execute(f));
|
||||
self.channels[self.next_index].send(Execute(f));
|
||||
self.next_index += 1;
|
||||
if self.next_index == self.channels.len() { self.next_index = 0; }
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user