Skip to content

Commit fc6cda8

Browse files
committed
rustc_data_structures: remove ref patterns and other artifacts of the past
1 parent 3dca58e commit fc6cda8

File tree

6 files changed

+22
-24
lines changed

6 files changed

+22
-24
lines changed

compiler/rustc_data_structures/src/graph/implementation/tests.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ fn test_adjacent_edges<N: PartialEq + Debug, E: PartialEq + Debug>(
7070
"counter={:?} expected={:?} edge_index={:?} edge={:?}",
7171
counter, expected_incoming[counter], edge_index, edge
7272
);
73-
match expected_incoming[counter] {
74-
(ref e, ref n) => {
73+
match &expected_incoming[counter] {
74+
(e, n) => {
7575
assert!(e == &edge.data);
7676
assert!(n == graph.node_data(edge.source()));
7777
assert!(start_index == edge.target);
@@ -88,8 +88,8 @@ fn test_adjacent_edges<N: PartialEq + Debug, E: PartialEq + Debug>(
8888
"counter={:?} expected={:?} edge_index={:?} edge={:?}",
8989
counter, expected_outgoing[counter], edge_index, edge
9090
);
91-
match expected_outgoing[counter] {
92-
(ref e, ref n) => {
91+
match &expected_outgoing[counter] {
92+
(e, n) => {
9393
assert!(e == &edge.data);
9494
assert!(start_index == edge.source);
9595
assert!(n == graph.node_data(edge.target));

compiler/rustc_data_structures/src/sorted_map.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use crate::stable_hasher::{HashStable, StableHasher, StableOrd};
22
use std::borrow::Borrow;
3-
use std::cmp::Ordering;
43
use std::fmt::Debug;
54
use std::mem;
65
use std::ops::{Bound, Index, IndexMut, RangeBounds};
@@ -171,7 +170,7 @@ impl<K: Ord, V> SortedMap<K, V> {
171170
where
172171
F: Fn(&mut K),
173172
{
174-
self.data.iter_mut().map(|&mut (ref mut k, _)| k).for_each(f);
173+
self.data.iter_mut().map(|(k, _)| k).for_each(f);
175174
}
176175

177176
/// Inserts a presorted range of elements into the map. If the range can be
@@ -232,22 +231,22 @@ impl<K: Ord, V> SortedMap<K, V> {
232231
R: RangeBounds<K>,
233232
{
234233
let start = match range.start_bound() {
235-
Bound::Included(ref k) => match self.lookup_index_for(k) {
234+
Bound::Included(k) => match self.lookup_index_for(k) {
236235
Ok(index) | Err(index) => index,
237236
},
238-
Bound::Excluded(ref k) => match self.lookup_index_for(k) {
237+
Bound::Excluded(k) => match self.lookup_index_for(k) {
239238
Ok(index) => index + 1,
240239
Err(index) => index,
241240
},
242241
Bound::Unbounded => 0,
243242
};
244243

245244
let end = match range.end_bound() {
246-
Bound::Included(ref k) => match self.lookup_index_for(k) {
245+
Bound::Included(k) => match self.lookup_index_for(k) {
247246
Ok(index) => index + 1,
248247
Err(index) => index,
249248
},
250-
Bound::Excluded(ref k) => match self.lookup_index_for(k) {
249+
Bound::Excluded(k) => match self.lookup_index_for(k) {
251250
Ok(index) | Err(index) => index,
252251
},
253252
Bound::Unbounded => self.data.len(),
@@ -302,7 +301,7 @@ impl<K: Ord, V> FromIterator<(K, V)> for SortedMap<K, V> {
302301
let mut data: Vec<(K, V)> = iter.into_iter().collect();
303302

304303
data.sort_unstable_by(|(k1, _), (k2, _)| k1.cmp(k2));
305-
data.dedup_by(|&mut (ref k1, _), &mut (ref k2, _)| k1.cmp(k2) == Ordering::Equal);
304+
data.dedup_by(|(k1, _), (k2, _)| k1 == k2);
306305

307306
SortedMap { data }
308307
}

compiler/rustc_data_structures/src/sorted_map/index_map.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,13 @@ impl<I: Idx, K: Ord, V> SortedIndexMultiMap<I, K, V> {
6363
/// Returns an iterator over the items in the map in insertion order.
6464
#[inline]
6565
pub fn iter(&self) -> impl '_ + DoubleEndedIterator<Item = (&K, &V)> {
66-
self.items.iter().map(|(ref k, ref v)| (k, v))
66+
self.items.iter().map(|(k, v)| (k, v))
6767
}
6868

6969
/// Returns an iterator over the items in the map in insertion order along with their indices.
7070
#[inline]
7171
pub fn iter_enumerated(&self) -> impl '_ + DoubleEndedIterator<Item = (I, (&K, &V))> {
72-
self.items.iter_enumerated().map(|(i, (ref k, ref v))| (i, (k, v)))
72+
self.items.iter_enumerated().map(|(i, (k, v))| (i, (k, v)))
7373
}
7474

7575
/// Returns the item in the map with the given index.

compiler/rustc_data_structures/src/sorted_map/tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ fn test_sorted_index_multi_map() {
66
let set: SortedIndexMultiMap<usize, _, _> = entries.iter().copied().collect();
77

88
// Insertion order is preserved.
9-
assert!(entries.iter().map(|(ref k, ref v)| (k, v)).eq(set.iter()));
9+
assert!(entries.iter().map(|(k, v)| (k, v)).eq(set.iter()));
1010

1111
// Indexing
1212
for (i, expect) in entries.iter().enumerate() {

compiler/rustc_data_structures/src/tiny_list.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ impl<T: PartialEq> TinyList<T> {
3737

3838
#[inline]
3939
pub fn remove(&mut self, data: &T) -> bool {
40-
self.head = match self.head {
41-
Some(ref mut head) if head.data == *data => head.next.take().map(|x| *x),
42-
Some(ref mut head) => return head.remove_next(data),
40+
self.head = match &mut self.head {
41+
Some(head) if head.data == *data => head.next.take().map(|x| *x),
42+
Some(head) => return head.remove_next(data),
4343
None => return false,
4444
};
4545
true
@@ -48,7 +48,7 @@ impl<T: PartialEq> TinyList<T> {
4848
#[inline]
4949
pub fn contains(&self, data: &T) -> bool {
5050
let mut elem = self.head.as_ref();
51-
while let Some(ref e) = elem {
51+
while let Some(e) = elem {
5252
if &e.data == data {
5353
return true;
5454
}
@@ -65,15 +65,14 @@ struct Element<T> {
6565
}
6666

6767
impl<T: PartialEq> Element<T> {
68-
fn remove_next(&mut self, data: &T) -> bool {
69-
let mut n = self;
68+
fn remove_next(mut self: &mut Self, data: &T) -> bool {
7069
loop {
71-
match n.next {
70+
match self.next {
7271
Some(ref mut next) if next.data == *data => {
73-
n.next = next.next.take();
72+
self.next = next.next.take();
7473
return true;
7574
}
76-
Some(ref mut next) => n = next,
75+
Some(ref mut next) => self = next,
7776
None => return false,
7877
}
7978
}

compiler/rustc_data_structures/src/tiny_list/tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use test::{black_box, Bencher};
66
impl<T> TinyList<T> {
77
fn len(&self) -> usize {
88
let (mut elem, mut count) = (self.head.as_ref(), 0);
9-
while let Some(ref e) = elem {
9+
while let Some(e) = elem {
1010
count += 1;
1111
elem = e.next.as_deref();
1212
}

0 commit comments

Comments
 (0)