Update calls of deprecated functions in macros.

Fallout of #17185.
This commit is contained in:
Victor Berger
2014-09-22 19:30:06 +02:00
parent eb58ac126e
commit 52ea83dddc
10 changed files with 38 additions and 30 deletions
+3 -3
View File
@@ -311,13 +311,13 @@ fn manually_share_arc() {
task::spawn(proc() {
let arc_v: Arc<Vec<int>> = rx.recv();
assert_eq!(*arc_v.get(3), 4);
assert_eq!((*arc_v)[3], 4);
});
tx.send(arc_v.clone());
assert_eq!(*arc_v.get(2), 3);
assert_eq!(*arc_v.get(4), 5);
assert_eq!((*arc_v)[2], 3);
assert_eq!((*arc_v)[4], 5);
info!("{:?}", arc_v);
}
+2
View File
@@ -542,6 +542,7 @@ mod tests {
use vec::Vec;
#[test]
#[allow(deprecated)]
fn test_simple() {
let mut d = RingBuf::new();
assert_eq!(d.len(), 0u);
@@ -587,6 +588,7 @@ fn test_simple() {
}
#[test]
#[allow(deprecated)]
fn test_boxes() {
let a: Gc<int> = box(GC) 5;
let b: Gc<int> = box(GC) 72;
+8 -4
View File
@@ -904,6 +904,7 @@ fn test_init_empty() {
}
#[test]
#[allow(deprecated)]
fn test_initn() {
let mut a = vec![11i, 12, 13];
let b: &[int] = &[11, 12, 13];
@@ -1303,6 +1304,7 @@ fn test_position_elem() {
}
#[test]
#[allow(deprecated)]
fn test_bsearch_elem() {
assert_eq!([1i,2,3,4,5].bsearch_elem(&5), Some(4));
assert_eq!([1i,2,3,4,5].bsearch_elem(&4), Some(3));
@@ -1350,11 +1352,11 @@ fn test_bsearch_elem() {
#[test]
fn test_reverse() {
let mut v: Vec<int> = vec![10i, 20];
assert_eq!(*v.get(0), 10);
assert_eq!(*v.get(1), 20);
assert_eq!(v[0], 10);
assert_eq!(v[1], 20);
v.reverse();
assert_eq!(*v.get(0), 20);
assert_eq!(*v.get(1), 10);
assert_eq!(v[0], 20);
assert_eq!(v[1], 10);
let mut v3: Vec<int> = vec![];
v3.reverse();
@@ -1462,6 +1464,7 @@ fn test_connect() {
}
#[test]
#[allow(deprecated)]
fn test_shift() {
let mut x = vec![1i, 2, 3];
assert_eq!(x.shift(), Some(1));
@@ -1901,6 +1904,7 @@ fn test_move_from() {
}
#[test]
#[allow(deprecated)]
fn test_copy_from() {
let mut a = [1i,2,3,4,5];
let b = [6i,7,8];
+8 -8
View File
@@ -452,7 +452,7 @@ fn index_mut<'a>(&'a mut self, i: &uint) -> &'a mut V {
}*/
macro_rules! iterator {
(impl $name:ident -> $elem:ty, $getter:ident) => {
(impl $name:ident -> $elem:ty, $($getter:ident),+) => {
impl<'a, T> Iterator<$elem> for $name<'a, T> {
#[inline]
fn next(&mut self) -> Option<$elem> {
@@ -462,7 +462,7 @@ fn next(&mut self) -> Option<$elem> {
if elem.is_some() {
let index = self.front;
self.front += 1;
return Some((index, elem. $getter ()));
return Some((index, elem $(. $getter ())+));
}
}
_ => ()
@@ -481,7 +481,7 @@ fn size_hint(&self) -> (uint, Option<uint>) {
}
macro_rules! double_ended_iterator {
(impl $name:ident -> $elem:ty, $getter:ident) => {
(impl $name:ident -> $elem:ty, $($getter:ident),+) => {
impl<'a, T> DoubleEndedIterator<$elem> for $name<'a, T> {
#[inline]
fn next_back(&mut self) -> Option<$elem> {
@@ -490,7 +490,7 @@ fn next_back(&mut self) -> Option<$elem> {
Some(elem) => {
if elem.is_some() {
self.back -= 1;
return Some((self.back, elem. $getter ()));
return Some((self.back, elem$(. $getter ())+));
}
}
_ => ()
@@ -510,8 +510,8 @@ pub struct Entries<'a, T:'a> {
iter: slice::Items<'a, Option<T>>
}
iterator!(impl Entries -> (uint, &'a T), get_ref)
double_ended_iterator!(impl Entries -> (uint, &'a T), get_ref)
iterator!(impl Entries -> (uint, &'a T), as_ref, unwrap)
double_ended_iterator!(impl Entries -> (uint, &'a T), as_ref, unwrap)
/// Forward iterator over the key-value pairs of a map, with the
/// values being mutable.
@@ -521,8 +521,8 @@ pub struct MutEntries<'a, T:'a> {
iter: slice::MutItems<'a, Option<T>>
}
iterator!(impl MutEntries -> (uint, &'a mut T), get_mut_ref)
double_ended_iterator!(impl MutEntries -> (uint, &'a mut T), get_mut_ref)
iterator!(impl MutEntries -> (uint, &'a mut T), as_mut, unwrap)
double_ended_iterator!(impl MutEntries -> (uint, &'a mut T), as_mut, unwrap)
/// Forward iterator over the keys of a map
pub type Keys<'a, T> =
+2 -2
View File
@@ -434,7 +434,7 @@ pub fn upper_bound<'a>(&'a self, key: uint) -> Entries<'a, T> {
fn bound_mut<'a>(&'a mut self, key: uint, upper: bool) -> MutEntries<'a, T> {
bound!(MutEntries, self = self,
key = key, is_upper = upper,
slice_from = mut_slice_from, iter = mut_iter,
slice_from = slice_from_mut, iter = iter_mut,
mutability = mut)
}
@@ -1020,7 +1020,7 @@ fn size_hint(&self) -> (uint, Option<uint>) {
}
iterator_impl! { Entries, iter = iter, mutability = }
iterator_impl! { MutEntries, iter = mut_iter, mutability = mut }
iterator_impl! { MutEntries, iter = iter_mut, mutability = mut }
/// A forward iterator over a set.
pub struct SetItems<'a> {
+1
View File
@@ -42,6 +42,7 @@ fn test_ordering_order() {
}
#[test]
#[allow(deprecated)]
fn test_lexical_ordering() {
fn t(o1: Ordering, o2: Ordering, e: Ordering) {
assert_eq!(lexical_ordering(o1, o2), e);
+1
View File
@@ -244,6 +244,7 @@ fn test_ord() {
}
#[test]
#[allow(deprecated)]
fn test_mutate() {
let mut x = Some(3i);
assert!(x.mutate(|i| i+1));
+10 -10
View File
@@ -1142,7 +1142,7 @@ fn test_optflag_short_arg() {
Ok(ref m) => {
// The next variable after the flag is just a free argument
assert!(*m.free.get(0) == "20".to_string());
assert!(m.free[0] == "20".to_string());
}
_ => fail!()
}
@@ -1298,8 +1298,8 @@ fn test_optmulti_multi() {
assert!(m.opt_present("t"));
assert_eq!(m.opt_str("t").unwrap(), "20".to_string());
let pair = m.opt_strs("test");
assert!(*pair.get(0) == "20".to_string());
assert!(*pair.get(1) == "30".to_string());
assert!(pair[0] == "20".to_string());
assert!(pair[1] == "30".to_string());
}
_ => fail!()
}
@@ -1351,19 +1351,19 @@ fn test_combined() {
let rs = getopts(args.as_slice(), opts.as_slice());
match rs {
Ok(ref m) => {
assert!(*m.free.get(0) == "prog".to_string());
assert!(*m.free.get(1) == "free1".to_string());
assert!(m.free[0] == "prog".to_string());
assert!(m.free[1] == "free1".to_string());
assert_eq!(m.opt_str("s").unwrap(), "20".to_string());
assert!(*m.free.get(2) == "free2".to_string());
assert!(m.free[2] == "free2".to_string());
assert!((m.opt_present("flag")));
assert_eq!(m.opt_str("long").unwrap(), "30".to_string());
assert!((m.opt_present("f")));
let pair = m.opt_strs("m");
assert!(*pair.get(0) == "40".to_string());
assert!(*pair.get(1) == "50".to_string());
assert!(pair[0] == "40".to_string());
assert!(pair[1] == "50".to_string());
let pair = m.opt_strs("n");
assert!(*pair.get(0) == "-A B".to_string());
assert!(*pair.get(1) == "-60 70".to_string());
assert!(pair[0] == "-A B".to_string());
assert!(pair[1] == "-60 70".to_string());
assert!((!m.opt_present("notpresent")));
}
_ => fail!()
+1 -1
View File
@@ -423,7 +423,7 @@ fn test_tls_multitask() {
// TLD shouldn't carry over.
assert!(my_key.get().is_none());
my_key.replace(Some("child data".to_string()));
assert!(my_key.get().get_ref().as_slice() == "child data");
assert!(my_key.get().as_ref().unwrap().as_slice() == "child data");
// should be cleaned up for us
});
+2 -2
View File
@@ -1519,9 +1519,9 @@ pub fn filter_for_ignored_option() {
let filtered = filter_tests(&opts, tests);
assert_eq!(filtered.len(), 1);
assert_eq!(filtered.get(0).desc.name.to_string(),
assert_eq!(filtered[0].desc.name.to_string(),
"1".to_string());
assert!(filtered.get(0).desc.ignore == false);
assert!(filtered[0].desc.ignore == false);
}
#[test]