Skip to content

Commit 51c7e20

Browse files
committed
auto merge of #16433 : aturon/rust/deprecated-in-crate, r=alexcrichton
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]
2 parents 4bb4a43 + d7484b8 commit 51c7e20

File tree

19 files changed

+78
-68
lines changed

19 files changed

+78
-68
lines changed

src/libcollections/bitv.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ impl Bitv {
264264
assert!(i < self.nbits);
265265
let w = i / uint::BITS;
266266
let b = i % uint::BITS;
267-
let x = self.storage.get(w) & (1 << b);
267+
let x = self.storage[w] & (1 << b);
268268
x != 0
269269
}
270270

@@ -289,8 +289,8 @@ impl Bitv {
289289
let w = i / uint::BITS;
290290
let b = i % uint::BITS;
291291
let flag = 1 << b;
292-
*self.storage.get_mut(w) = if x { *self.storage.get(w) | flag }
293-
else { *self.storage.get(w) & !flag };
292+
*self.storage.get_mut(w) = if x { self.storage[w] | flag }
293+
else { self.storage[w] & !flag };
294294
}
295295

296296
/// Set all bits to 1.
@@ -827,7 +827,7 @@ impl Clone for Bitv {
827827
fn clone_from(&mut self, source: &Bitv) {
828828
self.nbits = source.nbits;
829829
self.storage.reserve(source.storage.len());
830-
for (i, w) in self.storage.mut_iter().enumerate() { *w = *source.storage.get(i); }
830+
for (i, w) in self.storage.mut_iter().enumerate() { *w = source.storage[i]; }
831831
}
832832
}
833833

@@ -1146,7 +1146,7 @@ impl BitvSet {
11461146
self_bitv.reserve(other_bitv.capacity());
11471147
// Apply values
11481148
for (i, w) in other_bitv.mask_words(0) {
1149-
let old = *self_bitv.storage.get(i);
1149+
let old = self_bitv.storage[i];
11501150
let new = f(old, w);
11511151
*self_bitv.storage.get_mut(i) = new;
11521152
}
@@ -1573,10 +1573,10 @@ impl<'a> Iterator<uint> for TwoBitPositions<'a> {
15731573
// one Bitv might be longer than the other
15741574
let word_idx = self.next_idx / uint::BITS;
15751575
let w1 = if word_idx < s_bitv.storage.len() {
1576-
*s_bitv.storage.get(word_idx)
1576+
s_bitv.storage[word_idx]
15771577
} else { 0 };
15781578
let w2 = if word_idx < o_bitv.storage.len() {
1579-
*o_bitv.storage.get(word_idx)
1579+
o_bitv.storage[word_idx]
15801580
} else { 0 };
15811581
self.current_word = (self.merge)(w1, w2);
15821582
}

src/libcollections/btree.rs

+14-14
Original file line numberDiff line numberDiff line change
@@ -299,14 +299,14 @@ impl<K: Ord, V> Leaf<K, V> {
299299
midpoint = 0;
300300
}
301301
loop {
302-
let order = self.elts.get(midpoint).key.cmp(&k);
302+
let order = self.elts[midpoint].key.cmp(&k);
303303
match order {
304304
Equal => {
305305
return None;
306306
}
307307
Greater => {
308308
if midpoint > 0 {
309-
if self.elts.get(midpoint - 1).key.cmp(&k) == Less {
309+
if self.elts[midpoint - 1].key.cmp(&k) == Less {
310310
return Some(midpoint);
311311
}
312312
else {
@@ -322,7 +322,7 @@ impl<K: Ord, V> Leaf<K, V> {
322322
}
323323
Less => {
324324
if midpoint + 1 < self.elts.len() {
325-
if self.elts.get(midpoint + 1).key.cmp(&k) == Greater {
325+
if self.elts[midpoint + 1].key.cmp(&k) == Greater {
326326
return Some(midpoint);
327327
}
328328
else {
@@ -422,7 +422,7 @@ impl<K: Ord, V: Eq> Ord for Leaf<K, V> {
422422
if self.elts.len() < other.elts.len() {
423423
return Less;
424424
}
425-
self.elts.get(0).cmp(other.elts.get(0))
425+
self.elts[0].cmp(&other.elts[0])
426426
}
427427
}
428428

@@ -457,14 +457,14 @@ impl<K: Ord, V> Branch<K, V> {
457457
midpoint = 0u;
458458
}
459459
loop {
460-
let order = self.elts.get(midpoint).key.cmp(&k);
460+
let order = self.elts[midpoint].key.cmp(&k);
461461
match order {
462462
Equal => {
463463
return None;
464464
}
465465
Greater => {
466466
if midpoint > 0 {
467-
if self.elts.get(midpoint - 1).key.cmp(&k) == Less {
467+
if self.elts[midpoint - 1].key.cmp(&k) == Less {
468468
return Some(midpoint);
469469
}
470470
else {
@@ -480,7 +480,7 @@ impl<K: Ord, V> Branch<K, V> {
480480
}
481481
Less => {
482482
if midpoint + 1 < self.elts.len() {
483-
if self.elts.get(midpoint + 1).key.cmp(&k) == Greater {
483+
if self.elts[midpoint + 1].key.cmp(&k) == Greater {
484484
return Some(midpoint);
485485
}
486486
else {
@@ -529,15 +529,15 @@ impl<K: Clone + Ord, V: Clone> Branch<K, V> {
529529
Some(i) => {
530530
if i == self.elts.len() {
531531
let new_outcome = self.clone().rightmost_child.insert(k.clone(),
532-
v.clone(),
533-
ub.clone());
532+
v.clone(),
533+
ub.clone());
534534
new_branch = new_outcome.clone().val0();
535535
outcome = new_outcome.val1();
536536
}
537537
else {
538-
let new_outcome = self.elts.get(i).left.clone().insert(k.clone(),
539-
v.clone(),
540-
ub.clone());
538+
let new_outcome = self.elts[i].left.clone().insert(k.clone(),
539+
v.clone(),
540+
ub.clone());
541541
new_branch = new_outcome.clone().val0();
542542
outcome = new_outcome.val1();
543543
}
@@ -581,7 +581,7 @@ impl<K: Clone + Ord, V: Clone> Branch<K, V> {
581581
//If we have a new branch node, attempt to insert it into the tree
582582
//as with the key-value pair, then check to see if the node is overfull.
583583
BranchNode(branch) => {
584-
let new_elt = branch.elts.get(0).clone();
584+
let new_elt = branch.elts[0].clone();
585585
let new_elt_index = self.bsearch_branch(new_elt.clone().key);
586586
match new_elt_index {
587587
None => {
@@ -652,7 +652,7 @@ impl<K: Ord, V: Eq> Ord for Branch<K, V> {
652652
if self.elts.len() < other.elts.len() {
653653
return Less;
654654
}
655-
self.elts.get(0).cmp(other.elts.get(0))
655+
self.elts[0].cmp(&other.elts[0])
656656
}
657657
}
658658

src/libcollections/dlist.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -654,7 +654,7 @@ impl<A> Iterator<A> for MoveItems<A> {
654654

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

660660
impl<A> FromIterator<A> for DList<A> {
@@ -667,7 +667,7 @@ impl<A> FromIterator<A> for DList<A> {
667667

668668
impl<A> Extendable<A> for DList<A> {
669669
fn extend<T: Iterator<A>>(&mut self, mut iterator: T) {
670-
for elt in iterator { self.push_back(elt); }
670+
for elt in iterator { self.push(elt); }
671671
}
672672
}
673673

src/libcollections/priority_queue.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ impl<T: Ord> PriorityQueue<T> {
261261
///
262262
/// ```
263263
pub fn top<'a>(&'a self) -> Option<&'a T> {
264-
if self.is_empty() { None } else { Some(self.data.get(0)) }
264+
if self.is_empty() { None } else { Some(&self.data[0]) }
265265
}
266266

267267
#[deprecated="renamed to `top`"]
@@ -473,7 +473,7 @@ impl<T: Ord> PriorityQueue<T> {
473473

474474
while pos > start {
475475
let parent = (pos - 1) >> 1;
476-
if new > *self.data.get(parent) {
476+
if new > self.data[parent] {
477477
let x = replace(self.data.get_mut(parent), zeroed());
478478
ptr::write(self.data.get_mut(pos), x);
479479
pos = parent;
@@ -493,7 +493,7 @@ impl<T: Ord> PriorityQueue<T> {
493493
let mut child = 2 * pos + 1;
494494
while child < end {
495495
let right = child + 1;
496-
if right < end && !(*self.data.get(child) > *self.data.get(right)) {
496+
if right < end && !(self.data[child] > self.data[right]) {
497497
child = right;
498498
}
499499
let x = replace(self.data.get_mut(child), zeroed());

src/libcollections/ringbuf.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ impl<T> Mutable for RingBuf<T> {
5353
impl<T> Deque<T> for RingBuf<T> {
5454
/// Return a reference to the first element in the RingBuf
5555
fn front<'a>(&'a self) -> Option<&'a T> {
56-
if self.nelts > 0 { Some(self.get(0)) } else { None }
56+
if self.nelts > 0 { Some(&self[0]) } else { None }
5757
}
5858

5959
/// Return a mutable reference to the first element in the RingBuf
@@ -63,7 +63,7 @@ impl<T> Deque<T> for RingBuf<T> {
6363

6464
/// Return a reference to the last element in the RingBuf
6565
fn back<'a>(&'a self) -> Option<&'a T> {
66-
if self.nelts > 0 { Some(self.get(self.nelts - 1)) } else { None }
66+
if self.nelts > 0 { Some(&self[self.nelts - 1]) } else { None }
6767
}
6868

6969
/// Return a mutable reference to the last element in the RingBuf
@@ -152,7 +152,7 @@ impl<T> RingBuf<T> {
152152
#[deprecated = "prefer using indexing, e.g., ringbuf[0]"]
153153
pub fn get<'a>(&'a self, i: uint) -> &'a T {
154154
let idx = self.raw_index(i);
155-
match *self.elts.get(idx) {
155+
match self.elts[idx] {
156156
None => fail!(),
157157
Some(ref v) => v
158158
}
@@ -481,6 +481,7 @@ impl<S: Writer, A: Hash<S>> Hash<S> for RingBuf<A> {
481481

482482
impl<A> Index<uint, A> for RingBuf<A> {
483483
#[inline]
484+
#[allow(deprecated)]
484485
fn index<'a>(&'a self, i: &uint) -> &'a A {
485486
self.get(*i)
486487
}
@@ -506,7 +507,7 @@ impl<A> FromIterator<A> for RingBuf<A> {
506507
impl<A> Extendable<A> for RingBuf<A> {
507508
fn extend<T: Iterator<A>>(&mut self, mut iterator: T) {
508509
for elt in iterator {
509-
self.push_back(elt);
510+
self.push(elt);
510511
}
511512
}
512513
}

src/libcollections/slice.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ impl Iterator<(uint, uint)> for ElementSwaps {
190190
let max = self.sdir.iter().map(|&x| x).enumerate()
191191
.filter(|&(i, sd)|
192192
new_pos(i, sd.dir) < self.sdir.len() &&
193-
self.sdir.get(new_pos(i, sd.dir)).size < sd.size)
193+
self.sdir[new_pos(i, sd.dir)].size < sd.size)
194194
.max_by(|&(_, sd)| sd.size);
195195
match max {
196196
Some((i, sd)) => {

src/libcollections/smallintmap.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ impl<V> Map<uint, V> for SmallIntMap<V> {
8686
/// Return a reference to the value corresponding to the key.
8787
fn find<'a>(&'a self, key: &uint) -> Option<&'a V> {
8888
if *key < self.v.len() {
89-
match *self.v.get(*key) {
89+
match self.v[*key] {
9090
Some(ref value) => Some(value),
9191
None => None
9292
}
@@ -421,6 +421,7 @@ impl<V> Extendable<(uint, V)> for SmallIntMap<V> {
421421

422422
impl<V> Index<uint, V> for SmallIntMap<V> {
423423
#[inline]
424+
#[allow(deprecated)]
424425
fn index<'a>(&'a self, i: &uint) -> &'a V {
425426
self.get(i)
426427
}

src/libcollections/str.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -251,11 +251,11 @@ impl<'a> Iterator<char> for Decompositions<'a> {
251251
match self.buffer.as_slice().head() {
252252
Some(&(c, 0)) => {
253253
self.sorted = false;
254-
self.buffer.shift();
254+
self.buffer.remove(0);
255255
return Some(c);
256256
}
257257
Some(&(c, _)) if self.sorted => {
258-
self.buffer.shift();
258+
self.buffer.remove(0);
259259
return Some(c);
260260
}
261261
_ => self.sorted = false
@@ -287,7 +287,7 @@ impl<'a> Iterator<char> for Decompositions<'a> {
287287
self.sorted = true;
288288
}
289289

290-
match self.buffer.shift() {
290+
match self.buffer.remove(0) {
291291
Some((c, 0)) => {
292292
self.sorted = false;
293293
Some(c)
@@ -805,21 +805,21 @@ pub trait StrAllocating: Str {
805805

806806
for (j, tc) in t.chars().enumerate() {
807807

808-
let next = *dcol.get(j + 1);
808+
let next = dcol[j + 1];
809809

810810
if sc == tc {
811811
*dcol.get_mut(j + 1) = current;
812812
} else {
813813
*dcol.get_mut(j + 1) = cmp::min(current, next);
814-
*dcol.get_mut(j + 1) = cmp::min(*dcol.get(j + 1),
815-
*dcol.get(j)) + 1;
814+
*dcol.get_mut(j + 1) = cmp::min(dcol[j + 1],
815+
dcol[j]) + 1;
816816
}
817817

818818
current = next;
819819
}
820820
}
821821

822-
return *dcol.get(tlen);
822+
return dcol[tlen];
823823
}
824824

825825
/// An Iterator over the string in Unicode Normalization Form D

src/libcollections/string.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,7 @@ impl String {
669669
/// }
670670
/// ```
671671
pub unsafe fn shift_byte(&mut self) -> Option<u8> {
672-
self.vec.shift()
672+
self.vec.remove(0)
673673
}
674674

675675
/// Removes the first character from the string buffer and returns it.

src/libcollections/vec.rs

+1
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,7 @@ impl<T:Clone> Clone for Vec<T> {
453453

454454
impl<T> Index<uint,T> for Vec<T> {
455455
#[inline]
456+
#[allow(deprecated)] // allow use of get
456457
fn index<'a>(&'a self, index: &uint) -> &'a T {
457458
self.get(*index)
458459
}

src/libfourcc/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ fn main() {
4242
#![crate_name = "fourcc"]
4343
#![deprecated = "This is now a cargo package located at: \
4444
https://github.com/rust-lang/fourcc"]
45+
#![allow(deprecated)]
4546
#![crate_type = "rlib"]
4647
#![crate_type = "dylib"]
4748
#![license = "MIT/ASL2"]

src/libhexfloat/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ fn main() {
3939
#![crate_name = "hexfloat"]
4040
#![deprecated = "This is now a cargo package located at: \
4141
https://github.com/rust-lang/hexfloat"]
42+
#![allow(deprecated)]
4243
#![crate_type = "rlib"]
4344
#![crate_type = "dylib"]
4445
#![license = "MIT/ASL2"]

src/librustc/lint/builtin.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -1479,20 +1479,20 @@ impl LintPass for Stability {
14791479
_ => return
14801480
};
14811481

1482-
// stability attributes are promises made across crates; do not
1483-
// check anything for crate-local usage.
1484-
if ast_util::is_local(id) { return }
1485-
14861482
let stability = stability::lookup(cx.tcx, id);
1483+
let cross_crate = !ast_util::is_local(id);
1484+
1485+
// stability attributes are promises made across crates; only
1486+
// check DEPRECATED for crate-local usage.
14871487
let (lint, label) = match stability {
14881488
// no stability attributes == Unstable
1489-
None => (UNSTABLE, "unmarked"),
1490-
Some(attr::Stability { level: attr::Unstable, .. }) =>
1491-
(UNSTABLE, "unstable"),
1492-
Some(attr::Stability { level: attr::Experimental, .. }) =>
1493-
(EXPERIMENTAL, "experimental"),
1489+
None if cross_crate => (UNSTABLE, "unmarked"),
1490+
Some(attr::Stability { level: attr::Unstable, .. }) if cross_crate =>
1491+
(UNSTABLE, "unstable"),
1492+
Some(attr::Stability { level: attr::Experimental, .. }) if cross_crate =>
1493+
(EXPERIMENTAL, "experimental"),
14941494
Some(attr::Stability { level: attr::Deprecated, .. }) =>
1495-
(DEPRECATED, "deprecated"),
1495+
(DEPRECATED, "deprecated"),
14961496
_ => return
14971497
};
14981498

src/libsemver/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#![crate_name = "semver"]
3232
#![deprecated = "This is now a cargo package located at: \
3333
https://github.com/rust-lang/semver"]
34+
#![allow(deprecated)]
3435
#![crate_type = "rlib"]
3536
#![crate_type = "dylib"]
3637
#![license = "MIT/ASL2"]

src/libsync/atomic.rs

+2
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@
101101
//! }
102102
//! ```
103103
104+
#![allow(deprecated)]
105+
104106
use core::prelude::*;
105107

106108
use alloc::boxed::Box;

0 commit comments

Comments
 (0)