Skip to content

Commit

Permalink
Make clippy happy
Browse files Browse the repository at this point in the history
  • Loading branch information
JustForFun88 committed Feb 10, 2023
1 parent 136fccb commit 8f53eb7
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 20 deletions.
7 changes: 2 additions & 5 deletions src/external_trait_impls/rayon/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -561,10 +561,7 @@ mod test_par_map {
assert_eq!(value.load(Ordering::Relaxed), 100);

// retain only half
let _v: Vec<_> = hm
.into_par_iter()
.filter(|&(ref key, _)| key.k < 50)
.collect();
let _v: Vec<_> = hm.into_par_iter().filter(|(key, _)| key.k < 50).collect();

assert_eq!(key.load(Ordering::Relaxed), 50);
assert_eq!(value.load(Ordering::Relaxed), 50);
Expand Down Expand Up @@ -611,7 +608,7 @@ mod test_par_map {
assert_eq!(value.load(Ordering::Relaxed), 100);

// retain only half
let _v: Vec<_> = hm.drain().filter(|&(ref key, _)| key.k < 50).collect();
let _v: Vec<_> = hm.drain().filter(|(key, _)| key.k < 50).collect();
assert!(hm.is_empty());

assert_eq!(key.load(Ordering::Relaxed), 50);
Expand Down
23 changes: 11 additions & 12 deletions src/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1348,7 +1348,7 @@ where
{
// Avoid `Option::map` because it bloats LLVM IR.
match self.get_inner(k) {
Some(&(_, ref v)) => Some(v),
Some((_, v)) => Some(v),
None => None,
}
}
Expand Down Expand Up @@ -1379,7 +1379,7 @@ where
{
// Avoid `Option::map` because it bloats LLVM IR.
match self.get_inner(k) {
Some(&(ref key, ref value)) => Some((key, value)),
Some((key, value)) => Some((key, value)),
None => None,
}
}
Expand Down Expand Up @@ -3360,7 +3360,7 @@ impl<'a, K, V, S, A: Allocator + Clone> RawEntryBuilder<'a, K, V, S, A> {
F: FnMut(&K) -> bool,
{
match self.map.table.get(hash, |(k, _)| is_match(k)) {
Some(&(ref key, ref value)) => Some((key, value)),
Some((key, value)) => Some((key, value)),
None => None,
}
}
Expand Down Expand Up @@ -3756,7 +3756,7 @@ impl<'a, K, V, S, A: Allocator + Clone> RawOccupiedEntryMut<'a, K, V, S, A> {
#[cfg_attr(feature = "inline-more", inline)]
pub fn get_key_value(&self) -> (&K, &V) {
unsafe {
let &(ref key, ref value) = self.elem.as_ref();
let (key, value) = self.elem.as_ref();
(key, value)
}
}
Expand Down Expand Up @@ -6926,7 +6926,6 @@ mod test_map {
}
});

#[allow(clippy::let_underscore_drop)] // kind-of a false positive
for _ in half.by_ref() {}

DROP_VECTOR.with(|v| {
Expand Down Expand Up @@ -7254,10 +7253,10 @@ mod test_map {
map.insert(1, 2);
map.insert(3, 4);

let map_str = format!("{:?}", map);
let map_str = format!("{map:?}");

assert!(map_str == "{1: 2, 3: 4}" || map_str == "{3: 4, 1: 2}");
assert_eq!(format!("{:?}", empty), "{}");
assert_eq!(format!("{empty:?}"), "{}");
}

#[test]
Expand Down Expand Up @@ -7573,7 +7572,7 @@ mod test_map {
// Test for #19292
fn check(m: &HashMap<i32, ()>) {
for k in m.keys() {
assert!(m.contains_key(k), "{} is in keys() but not in the map?", k);
assert!(m.contains_key(k), "{k} is in keys() but not in the map?");
}
}

Expand Down Expand Up @@ -7609,7 +7608,7 @@ mod test_map {
// Test for #19292
fn check(m: &HashMap<std::string::String, ()>) {
for k in m.keys() {
assert!(m.contains_key(k), "{} is in keys() but not in the map?", k);
assert!(m.contains_key(k), "{k} is in keys() but not in the map?");
}
}

Expand Down Expand Up @@ -8081,7 +8080,7 @@ mod test_map {
// Test for #19292
fn check(m: &HashMap<i32, ()>) {
for k in m.keys() {
assert!(m.contains_key(k), "{} is in keys() but not in the map?", k);
assert!(m.contains_key(k), "{k} is in keys() but not in the map?");
}
}

Expand Down Expand Up @@ -8111,7 +8110,7 @@ mod test_map {
// Test for #19292
fn check(m: &HashMap<std::string::String, ()>) {
for k in m.keys() {
assert!(m.contains_key(k), "{} is in keys() but not in the map?", k);
assert!(m.contains_key(k), "{k} is in keys() but not in the map?");
}
}

Expand Down Expand Up @@ -8381,7 +8380,7 @@ mod test_map {
removed.push(t);
left -= 1;
} else {
assert!(removed.contains(&(i, 2 * i)), "{} not in {:?}", i, removed);
assert!(removed.contains(&(i, 2 * i)), "{i} not in {removed:?}");
let e = map.table.insert(
hash_value,
(i, 2 * i),
Expand Down
4 changes: 2 additions & 2 deletions src/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2712,10 +2712,10 @@ mod test_set {
set.insert(1);
set.insert(2);

let set_str = format!("{:?}", set);
let set_str = format!("{set:?}");

assert!(set_str == "{1, 2}" || set_str == "{2, 1}");
assert_eq!(format!("{:?}", empty), "{}");
assert_eq!(format!("{empty:?}"), "{}");
}

#[test]
Expand Down
2 changes: 1 addition & 1 deletion tests/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ fn test_hashset_insert_remove() {
assert_eq!(m.insert(x.clone()), true);
}
for (i, x) in tx.iter().enumerate() {
println!("removing {} {:?}", i, x);
println!("removing {i} {x:?}");
assert_eq!(m.remove(x), true);
}
}
Expand Down

0 comments on commit 8f53eb7

Please sign in to comment.