Skip to content

Commit

Permalink
auto merge of #16433 : aturon/rust/deprecated-in-crate, r=alexcrichton
Browse files Browse the repository at this point in the history
Previously the stability lint considered cross-crate items only. That's appropriate for unstable and experimental levels, but not for deprecation.

In addition to changing the lint, this PR takes care of the fallout: a number of deprecated items that were being used throughout libstd.

Closes #16409

Due to deny(deprecated), this is a:

[breaking-change]
  • Loading branch information
bors committed Aug 12, 2014
2 parents 4bb4a43 + d7484b8 commit 51c7e20
Show file tree
Hide file tree
Showing 19 changed files with 78 additions and 68 deletions.
14 changes: 7 additions & 7 deletions src/libcollections/bitv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -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.
Expand Down Expand Up @@ -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]; }
}
}

Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -1573,10 +1573,10 @@ impl<'a> Iterator<uint> 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);
}
Expand Down
28 changes: 14 additions & 14 deletions src/libcollections/btree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -299,14 +299,14 @@ impl<K: Ord, V> Leaf<K, V> {
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 {
Expand All @@ -322,7 +322,7 @@ impl<K: Ord, V> Leaf<K, V> {
}
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 {
Expand Down Expand Up @@ -422,7 +422,7 @@ impl<K: Ord, V: Eq> Ord for Leaf<K, V> {
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])
}
}

Expand Down Expand Up @@ -457,14 +457,14 @@ impl<K: Ord, V> Branch<K, V> {
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 {
Expand All @@ -480,7 +480,7 @@ impl<K: Ord, V> Branch<K, V> {
}
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 {
Expand Down Expand Up @@ -529,15 +529,15 @@ impl<K: Clone + Ord, V: Clone> Branch<K, V> {
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();
}
Expand Down Expand Up @@ -581,7 +581,7 @@ impl<K: Clone + Ord, V: Clone> Branch<K, V> {
//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 => {
Expand Down Expand Up @@ -652,7 +652,7 @@ impl<K: Ord, V: Eq> Ord for Branch<K, V> {
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])
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/libcollections/dlist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,7 @@ impl<A> Iterator<A> for MoveItems<A> {

impl<A> DoubleEndedIterator<A> for MoveItems<A> {
#[inline]
fn next_back(&mut self) -> Option<A> { self.list.pop_back() }
fn next_back(&mut self) -> Option<A> { self.list.pop() }
}

impl<A> FromIterator<A> for DList<A> {
Expand All @@ -667,7 +667,7 @@ impl<A> FromIterator<A> for DList<A> {

impl<A> Extendable<A> for DList<A> {
fn extend<T: Iterator<A>>(&mut self, mut iterator: T) {
for elt in iterator { self.push_back(elt); }
for elt in iterator { self.push(elt); }
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/libcollections/priority_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ impl<T: Ord> PriorityQueue<T> {
///
/// ```
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`"]
Expand Down Expand Up @@ -473,7 +473,7 @@ impl<T: Ord> PriorityQueue<T> {

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;
Expand All @@ -493,7 +493,7 @@ impl<T: Ord> PriorityQueue<T> {
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());
Expand Down
9 changes: 5 additions & 4 deletions src/libcollections/ringbuf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ impl<T> Mutable for RingBuf<T> {
impl<T> Deque<T> for RingBuf<T> {
/// 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
Expand All @@ -63,7 +63,7 @@ impl<T> Deque<T> for RingBuf<T> {

/// 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
Expand Down Expand Up @@ -152,7 +152,7 @@ impl<T> RingBuf<T> {
#[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
}
Expand Down Expand Up @@ -481,6 +481,7 @@ impl<S: Writer, A: Hash<S>> Hash<S> for RingBuf<A> {

impl<A> Index<uint, A> for RingBuf<A> {
#[inline]
#[allow(deprecated)]
fn index<'a>(&'a self, i: &uint) -> &'a A {
self.get(*i)
}
Expand All @@ -506,7 +507,7 @@ impl<A> FromIterator<A> for RingBuf<A> {
impl<A> Extendable<A> for RingBuf<A> {
fn extend<T: Iterator<A>>(&mut self, mut iterator: T) {
for elt in iterator {
self.push_back(elt);
self.push(elt);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/libcollections/slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)) => {
Expand Down
3 changes: 2 additions & 1 deletion src/libcollections/smallintmap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ impl<V> Map<uint, V> for SmallIntMap<V> {
/// 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
}
Expand Down Expand Up @@ -421,6 +421,7 @@ impl<V> Extendable<(uint, V)> for SmallIntMap<V> {

impl<V> Index<uint, V> for SmallIntMap<V> {
#[inline]
#[allow(deprecated)]
fn index<'a>(&'a self, i: &uint) -> &'a V {
self.get(i)
}
Expand Down
14 changes: 7 additions & 7 deletions src/libcollections/str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,11 +251,11 @@ impl<'a> Iterator<char> 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
Expand Down Expand Up @@ -287,7 +287,7 @@ impl<'a> Iterator<char> for Decompositions<'a> {
self.sorted = true;
}

match self.buffer.shift() {
match self.buffer.remove(0) {
Some((c, 0)) => {
self.sorted = false;
Some(c)
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/libcollections/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,7 @@ impl String {
/// }
/// ```
pub unsafe fn shift_byte(&mut self) -> Option<u8> {
self.vec.shift()
self.vec.remove(0)
}

/// Removes the first character from the string buffer and returns it.
Expand Down
1 change: 1 addition & 0 deletions src/libcollections/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,7 @@ impl<T:Clone> Clone for Vec<T> {

impl<T> Index<uint,T> for Vec<T> {
#[inline]
#[allow(deprecated)] // allow use of get
fn index<'a>(&'a self, index: &uint) -> &'a T {
self.get(*index)
}
Expand Down
1 change: 1 addition & 0 deletions src/libfourcc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
1 change: 1 addition & 0 deletions src/libhexfloat/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
20 changes: 10 additions & 10 deletions src/librustc/lint/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
};

Expand Down
1 change: 1 addition & 0 deletions src/libsemver/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
2 changes: 2 additions & 0 deletions src/libsync/atomic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@
//! }
//! ```
#![allow(deprecated)]

use core::prelude::*;

use alloc::boxed::Box;
Expand Down
Loading

0 comments on commit 51c7e20

Please sign in to comment.