diff --git a/src/libcollections/bitv.rs b/src/libcollections/bitv.rs index 14d4f90a077cf..7745a0d887ee8 100644 --- a/src/libcollections/bitv.rs +++ b/src/libcollections/bitv.rs @@ -264,7 +264,7 @@ impl Bitv { assert!(i < self.nbits); let w = i / uint::BITS; let b = i % uint::BITS; - let x = self.storage.get(w) & (1 << b); + let x = self.storage[w] & (1 << b); x != 0 } @@ -289,8 +289,8 @@ impl Bitv { let w = i / uint::BITS; let b = i % uint::BITS; let flag = 1 << b; - *self.storage.get_mut(w) = if x { *self.storage.get(w) | flag } - else { *self.storage.get(w) & !flag }; + *self.storage.get_mut(w) = if x { self.storage[w] | flag } + else { self.storage[w] & !flag }; } /// Set all bits to 1. @@ -827,7 +827,7 @@ impl Clone for Bitv { fn clone_from(&mut self, source: &Bitv) { self.nbits = source.nbits; self.storage.reserve(source.storage.len()); - for (i, w) in self.storage.mut_iter().enumerate() { *w = *source.storage.get(i); } + for (i, w) in self.storage.mut_iter().enumerate() { *w = source.storage[i]; } } } @@ -1146,7 +1146,7 @@ impl BitvSet { self_bitv.reserve(other_bitv.capacity()); // Apply values for (i, w) in other_bitv.mask_words(0) { - let old = *self_bitv.storage.get(i); + let old = self_bitv.storage[i]; let new = f(old, w); *self_bitv.storage.get_mut(i) = new; } @@ -1573,10 +1573,10 @@ impl<'a> Iterator for TwoBitPositions<'a> { // one Bitv might be longer than the other let word_idx = self.next_idx / uint::BITS; let w1 = if word_idx < s_bitv.storage.len() { - *s_bitv.storage.get(word_idx) + s_bitv.storage[word_idx] } else { 0 }; let w2 = if word_idx < o_bitv.storage.len() { - *o_bitv.storage.get(word_idx) + o_bitv.storage[word_idx] } else { 0 }; self.current_word = (self.merge)(w1, w2); } diff --git a/src/libcollections/btree.rs b/src/libcollections/btree.rs index 947c87daa8460..4c5f8ef09879e 100644 --- a/src/libcollections/btree.rs +++ b/src/libcollections/btree.rs @@ -299,14 +299,14 @@ impl Leaf { midpoint = 0; } loop { - let order = self.elts.get(midpoint).key.cmp(&k); + let order = self.elts[midpoint].key.cmp(&k); match order { Equal => { return None; } Greater => { if midpoint > 0 { - if self.elts.get(midpoint - 1).key.cmp(&k) == Less { + if self.elts[midpoint - 1].key.cmp(&k) == Less { return Some(midpoint); } else { @@ -322,7 +322,7 @@ impl Leaf { } Less => { if midpoint + 1 < self.elts.len() { - if self.elts.get(midpoint + 1).key.cmp(&k) == Greater { + if self.elts[midpoint + 1].key.cmp(&k) == Greater { return Some(midpoint); } else { @@ -422,7 +422,7 @@ impl Ord for Leaf { if self.elts.len() < other.elts.len() { return Less; } - self.elts.get(0).cmp(other.elts.get(0)) + self.elts[0].cmp(&other.elts[0]) } } @@ -457,14 +457,14 @@ impl Branch { midpoint = 0u; } loop { - let order = self.elts.get(midpoint).key.cmp(&k); + let order = self.elts[midpoint].key.cmp(&k); match order { Equal => { return None; } Greater => { if midpoint > 0 { - if self.elts.get(midpoint - 1).key.cmp(&k) == Less { + if self.elts[midpoint - 1].key.cmp(&k) == Less { return Some(midpoint); } else { @@ -480,7 +480,7 @@ impl Branch { } Less => { if midpoint + 1 < self.elts.len() { - if self.elts.get(midpoint + 1).key.cmp(&k) == Greater { + if self.elts[midpoint + 1].key.cmp(&k) == Greater { return Some(midpoint); } else { @@ -529,15 +529,15 @@ impl Branch { Some(i) => { if i == self.elts.len() { let new_outcome = self.clone().rightmost_child.insert(k.clone(), - v.clone(), - ub.clone()); + v.clone(), + ub.clone()); new_branch = new_outcome.clone().val0(); outcome = new_outcome.val1(); } else { - let new_outcome = self.elts.get(i).left.clone().insert(k.clone(), - v.clone(), - ub.clone()); + let new_outcome = self.elts[i].left.clone().insert(k.clone(), + v.clone(), + ub.clone()); new_branch = new_outcome.clone().val0(); outcome = new_outcome.val1(); } @@ -581,7 +581,7 @@ impl Branch { //If we have a new branch node, attempt to insert it into the tree //as with the key-value pair, then check to see if the node is overfull. BranchNode(branch) => { - let new_elt = branch.elts.get(0).clone(); + let new_elt = branch.elts[0].clone(); let new_elt_index = self.bsearch_branch(new_elt.clone().key); match new_elt_index { None => { @@ -652,7 +652,7 @@ impl Ord for Branch { if self.elts.len() < other.elts.len() { return Less; } - self.elts.get(0).cmp(other.elts.get(0)) + self.elts[0].cmp(&other.elts[0]) } } diff --git a/src/libcollections/dlist.rs b/src/libcollections/dlist.rs index 3d322729aab43..8344ad7c79d7b 100644 --- a/src/libcollections/dlist.rs +++ b/src/libcollections/dlist.rs @@ -654,7 +654,7 @@ impl Iterator for MoveItems { impl DoubleEndedIterator for MoveItems { #[inline] - fn next_back(&mut self) -> Option { self.list.pop_back() } + fn next_back(&mut self) -> Option { self.list.pop() } } impl FromIterator for DList { @@ -667,7 +667,7 @@ impl FromIterator for DList { impl Extendable for DList { fn extend>(&mut self, mut iterator: T) { - for elt in iterator { self.push_back(elt); } + for elt in iterator { self.push(elt); } } } diff --git a/src/libcollections/priority_queue.rs b/src/libcollections/priority_queue.rs index bf2c8c83d87b6..a88a833c9edca 100644 --- a/src/libcollections/priority_queue.rs +++ b/src/libcollections/priority_queue.rs @@ -261,7 +261,7 @@ impl PriorityQueue { /// /// ``` pub fn top<'a>(&'a self) -> Option<&'a T> { - if self.is_empty() { None } else { Some(self.data.get(0)) } + if self.is_empty() { None } else { Some(&self.data[0]) } } #[deprecated="renamed to `top`"] @@ -473,7 +473,7 @@ impl PriorityQueue { while pos > start { let parent = (pos - 1) >> 1; - if new > *self.data.get(parent) { + if new > self.data[parent] { let x = replace(self.data.get_mut(parent), zeroed()); ptr::write(self.data.get_mut(pos), x); pos = parent; @@ -493,7 +493,7 @@ impl PriorityQueue { let mut child = 2 * pos + 1; while child < end { let right = child + 1; - if right < end && !(*self.data.get(child) > *self.data.get(right)) { + if right < end && !(self.data[child] > self.data[right]) { child = right; } let x = replace(self.data.get_mut(child), zeroed()); diff --git a/src/libcollections/ringbuf.rs b/src/libcollections/ringbuf.rs index 736861a54a434..ce08f169366da 100644 --- a/src/libcollections/ringbuf.rs +++ b/src/libcollections/ringbuf.rs @@ -53,7 +53,7 @@ impl Mutable for RingBuf { impl Deque for RingBuf { /// Return a reference to the first element in the RingBuf fn front<'a>(&'a self) -> Option<&'a T> { - if self.nelts > 0 { Some(self.get(0)) } else { None } + if self.nelts > 0 { Some(&self[0]) } else { None } } /// Return a mutable reference to the first element in the RingBuf @@ -63,7 +63,7 @@ impl Deque for RingBuf { /// Return a reference to the last element in the RingBuf fn back<'a>(&'a self) -> Option<&'a T> { - if self.nelts > 0 { Some(self.get(self.nelts - 1)) } else { None } + if self.nelts > 0 { Some(&self[self.nelts - 1]) } else { None } } /// Return a mutable reference to the last element in the RingBuf @@ -152,7 +152,7 @@ impl RingBuf { #[deprecated = "prefer using indexing, e.g., ringbuf[0]"] pub fn get<'a>(&'a self, i: uint) -> &'a T { let idx = self.raw_index(i); - match *self.elts.get(idx) { + match self.elts[idx] { None => fail!(), Some(ref v) => v } @@ -481,6 +481,7 @@ impl> Hash for RingBuf { impl Index for RingBuf { #[inline] + #[allow(deprecated)] fn index<'a>(&'a self, i: &uint) -> &'a A { self.get(*i) } @@ -506,7 +507,7 @@ impl FromIterator for RingBuf { impl Extendable for RingBuf { fn extend>(&mut self, mut iterator: T) { for elt in iterator { - self.push_back(elt); + self.push(elt); } } } diff --git a/src/libcollections/slice.rs b/src/libcollections/slice.rs index f6aaea79bbd31..4c7c7e3ea74bb 100644 --- a/src/libcollections/slice.rs +++ b/src/libcollections/slice.rs @@ -190,7 +190,7 @@ impl Iterator<(uint, uint)> for ElementSwaps { let max = self.sdir.iter().map(|&x| x).enumerate() .filter(|&(i, sd)| new_pos(i, sd.dir) < self.sdir.len() && - self.sdir.get(new_pos(i, sd.dir)).size < sd.size) + self.sdir[new_pos(i, sd.dir)].size < sd.size) .max_by(|&(_, sd)| sd.size); match max { Some((i, sd)) => { diff --git a/src/libcollections/smallintmap.rs b/src/libcollections/smallintmap.rs index 39244c7cd5fa6..4529c8782a194 100644 --- a/src/libcollections/smallintmap.rs +++ b/src/libcollections/smallintmap.rs @@ -86,7 +86,7 @@ impl Map for SmallIntMap { /// Return a reference to the value corresponding to the key. fn find<'a>(&'a self, key: &uint) -> Option<&'a V> { if *key < self.v.len() { - match *self.v.get(*key) { + match self.v[*key] { Some(ref value) => Some(value), None => None } @@ -421,6 +421,7 @@ impl Extendable<(uint, V)> for SmallIntMap { impl Index for SmallIntMap { #[inline] + #[allow(deprecated)] fn index<'a>(&'a self, i: &uint) -> &'a V { self.get(i) } diff --git a/src/libcollections/str.rs b/src/libcollections/str.rs index 270b76fd57fc9..d911ca6bb14f9 100644 --- a/src/libcollections/str.rs +++ b/src/libcollections/str.rs @@ -251,11 +251,11 @@ impl<'a> Iterator for Decompositions<'a> { match self.buffer.as_slice().head() { Some(&(c, 0)) => { self.sorted = false; - self.buffer.shift(); + self.buffer.remove(0); return Some(c); } Some(&(c, _)) if self.sorted => { - self.buffer.shift(); + self.buffer.remove(0); return Some(c); } _ => self.sorted = false @@ -287,7 +287,7 @@ impl<'a> Iterator for Decompositions<'a> { self.sorted = true; } - match self.buffer.shift() { + match self.buffer.remove(0) { Some((c, 0)) => { self.sorted = false; Some(c) @@ -805,21 +805,21 @@ pub trait StrAllocating: Str { for (j, tc) in t.chars().enumerate() { - let next = *dcol.get(j + 1); + let next = dcol[j + 1]; if sc == tc { *dcol.get_mut(j + 1) = current; } else { *dcol.get_mut(j + 1) = cmp::min(current, next); - *dcol.get_mut(j + 1) = cmp::min(*dcol.get(j + 1), - *dcol.get(j)) + 1; + *dcol.get_mut(j + 1) = cmp::min(dcol[j + 1], + dcol[j]) + 1; } current = next; } } - return *dcol.get(tlen); + return dcol[tlen]; } /// An Iterator over the string in Unicode Normalization Form D diff --git a/src/libcollections/string.rs b/src/libcollections/string.rs index 9465fea6dcbee..952f28da2af89 100644 --- a/src/libcollections/string.rs +++ b/src/libcollections/string.rs @@ -669,7 +669,7 @@ impl String { /// } /// ``` pub unsafe fn shift_byte(&mut self) -> Option { - self.vec.shift() + self.vec.remove(0) } /// Removes the first character from the string buffer and returns it. diff --git a/src/libcollections/vec.rs b/src/libcollections/vec.rs index 39fe57038b0b2..6bda0eed66dd9 100644 --- a/src/libcollections/vec.rs +++ b/src/libcollections/vec.rs @@ -453,6 +453,7 @@ impl Clone for Vec { impl Index for Vec { #[inline] + #[allow(deprecated)] // allow use of get fn index<'a>(&'a self, index: &uint) -> &'a T { self.get(*index) } diff --git a/src/libfourcc/lib.rs b/src/libfourcc/lib.rs index bac5b6e10135c..e4d61c47cc20c 100644 --- a/src/libfourcc/lib.rs +++ b/src/libfourcc/lib.rs @@ -42,6 +42,7 @@ fn main() { #![crate_name = "fourcc"] #![deprecated = "This is now a cargo package located at: \ https://github.com/rust-lang/fourcc"] +#![allow(deprecated)] #![crate_type = "rlib"] #![crate_type = "dylib"] #![license = "MIT/ASL2"] diff --git a/src/libhexfloat/lib.rs b/src/libhexfloat/lib.rs index 9adeeb2e4c924..936e7cb4403d4 100644 --- a/src/libhexfloat/lib.rs +++ b/src/libhexfloat/lib.rs @@ -39,6 +39,7 @@ fn main() { #![crate_name = "hexfloat"] #![deprecated = "This is now a cargo package located at: \ https://github.com/rust-lang/hexfloat"] +#![allow(deprecated)] #![crate_type = "rlib"] #![crate_type = "dylib"] #![license = "MIT/ASL2"] diff --git a/src/librustc/lint/builtin.rs b/src/librustc/lint/builtin.rs index bde0992dabeef..f929860c6864b 100644 --- a/src/librustc/lint/builtin.rs +++ b/src/librustc/lint/builtin.rs @@ -1479,20 +1479,20 @@ impl LintPass for Stability { _ => return }; - // stability attributes are promises made across crates; do not - // check anything for crate-local usage. - if ast_util::is_local(id) { return } - let stability = stability::lookup(cx.tcx, id); + let cross_crate = !ast_util::is_local(id); + + // stability attributes are promises made across crates; only + // check DEPRECATED for crate-local usage. let (lint, label) = match stability { // no stability attributes == Unstable - None => (UNSTABLE, "unmarked"), - Some(attr::Stability { level: attr::Unstable, .. }) => - (UNSTABLE, "unstable"), - Some(attr::Stability { level: attr::Experimental, .. }) => - (EXPERIMENTAL, "experimental"), + None if cross_crate => (UNSTABLE, "unmarked"), + Some(attr::Stability { level: attr::Unstable, .. }) if cross_crate => + (UNSTABLE, "unstable"), + Some(attr::Stability { level: attr::Experimental, .. }) if cross_crate => + (EXPERIMENTAL, "experimental"), Some(attr::Stability { level: attr::Deprecated, .. }) => - (DEPRECATED, "deprecated"), + (DEPRECATED, "deprecated"), _ => return }; diff --git a/src/libsemver/lib.rs b/src/libsemver/lib.rs index 3cc5189c024db..56c0f24509b8e 100644 --- a/src/libsemver/lib.rs +++ b/src/libsemver/lib.rs @@ -31,6 +31,7 @@ #![crate_name = "semver"] #![deprecated = "This is now a cargo package located at: \ https://github.com/rust-lang/semver"] +#![allow(deprecated)] #![crate_type = "rlib"] #![crate_type = "dylib"] #![license = "MIT/ASL2"] diff --git a/src/libsync/atomic.rs b/src/libsync/atomic.rs index 31b993d8bab46..301d444b1b15b 100644 --- a/src/libsync/atomic.rs +++ b/src/libsync/atomic.rs @@ -101,6 +101,8 @@ //! } //! ``` +#![allow(deprecated)] + use core::prelude::*; use alloc::boxed::Box; diff --git a/src/libsync/comm/duplex.rs b/src/libsync/comm/duplex.rs index 44dd63cbf6c01..587827d2bc576 100644 --- a/src/libsync/comm/duplex.rs +++ b/src/libsync/comm/duplex.rs @@ -15,6 +15,7 @@ Higher level communication abstractions. */ #![allow(missing_doc)] +#![allow(deprecated)] #![deprecated = "This type is replaced by having a pair of channels. This type \ is not fully composable with other channels in terms of \ or possible semantics on a duplex stream. It will be removed \ diff --git a/src/liburl/lib.rs b/src/liburl/lib.rs index 0221b95b40434..8c35424d394f4 100644 --- a/src/liburl/lib.rs +++ b/src/liburl/lib.rs @@ -12,6 +12,7 @@ #![crate_name = "url"] #![deprecated="This is being removed. Use rust-url instead. http://servo.github.io/rust-url/"] +#![allow(deprecated)] #![crate_type = "rlib"] #![crate_type = "dylib"] #![license = "MIT/ASL2"] diff --git a/src/libuuid/lib.rs b/src/libuuid/lib.rs index d922dde6f8537..78c8fbad959ee 100644 --- a/src/libuuid/lib.rs +++ b/src/libuuid/lib.rs @@ -59,6 +59,7 @@ Examples of string representations: #![crate_name = "uuid"] #![deprecated = "This is now a cargo package located at: \ https://github.com/rust-lang/uuid"] +#![allow(deprecated)] #![crate_type = "rlib"] #![crate_type = "dylib"] #![license = "MIT/ASL2"] diff --git a/src/test/compile-fail/lint-stability.rs b/src/test/compile-fail/lint-stability.rs index 3a9380befbcb4..f5cee22ac2c05 100644 --- a/src/test/compile-fail/lint-stability.rs +++ b/src/test/compile-fail/lint-stability.rs @@ -329,19 +329,19 @@ mod this_crate { pub struct LockedTupleStruct(int); fn test() { - // None of the following should generate errors, because - // stability attributes now have meaning only *across* crates, - // not within a single crate. + // Only the deprecated cases of the following should generate + // errors, because other stability attributes now have meaning + // only *across* crates, not within a single crate. let foo = MethodTester; - deprecated(); - foo.method_deprecated(); - foo.trait_deprecated(); + deprecated(); //~ ERROR use of deprecated item + foo.method_deprecated(); //~ ERROR use of deprecated item + foo.trait_deprecated(); //~ ERROR use of deprecated item - deprecated_text(); - foo.method_deprecated_text(); - foo.trait_deprecated_text(); + deprecated_text(); //~ ERROR use of deprecated item: text + foo.method_deprecated_text(); //~ ERROR use of deprecated item: text + foo.trait_deprecated_text(); //~ ERROR use of deprecated item: text experimental(); foo.method_experimental(); @@ -387,8 +387,7 @@ mod this_crate { foo.method_locked_text(); foo.trait_locked_text(); - - let _ = DeprecatedStruct { i: 0 }; + let _ = DeprecatedStruct { i: 0 }; //~ ERROR use of deprecated item let _ = ExperimentalStruct { i: 0 }; let _ = UnstableStruct { i: 0 }; let _ = UnmarkedStruct { i: 0 }; @@ -396,7 +395,7 @@ mod this_crate { let _ = FrozenStruct { i: 0 }; let _ = LockedStruct { i: 0 }; - let _ = DeprecatedUnitStruct; + let _ = DeprecatedUnitStruct; //~ ERROR use of deprecated item let _ = ExperimentalUnitStruct; let _ = UnstableUnitStruct; let _ = UnmarkedUnitStruct; @@ -404,7 +403,7 @@ mod this_crate { let _ = FrozenUnitStruct; let _ = LockedUnitStruct; - let _ = DeprecatedVariant; + let _ = DeprecatedVariant; //~ ERROR use of deprecated item let _ = ExperimentalVariant; let _ = UnstableVariant; let _ = UnmarkedVariant; @@ -412,7 +411,7 @@ mod this_crate { let _ = FrozenVariant; let _ = LockedVariant; - let _ = DeprecatedTupleStruct (1); + let _ = DeprecatedTupleStruct (1); //~ ERROR use of deprecated item let _ = ExperimentalTupleStruct (1); let _ = UnstableTupleStruct (1); let _ = UnmarkedTupleStruct (1); @@ -422,8 +421,8 @@ mod this_crate { } fn test_method_param(foo: F) { - foo.trait_deprecated(); - foo.trait_deprecated_text(); + foo.trait_deprecated(); //~ ERROR use of deprecated item + foo.trait_deprecated_text(); //~ ERROR use of deprecated item: text foo.trait_experimental(); foo.trait_experimental_text(); foo.trait_unstable(); @@ -433,8 +432,8 @@ mod this_crate { } fn test_method_object(foo: &Trait) { - foo.trait_deprecated(); - foo.trait_deprecated_text(); + foo.trait_deprecated(); //~ ERROR use of deprecated item + foo.trait_deprecated_text(); //~ ERROR use of deprecated item: text foo.trait_experimental(); foo.trait_experimental_text(); foo.trait_unstable();