Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document bucket #365

Merged
merged 3 commits into from
Feb 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
24 changes: 12 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 @@ -7658,6 +7657,7 @@ mod test_map {
}

#[test]
#[allow(clippy::needless_borrow)]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just because cargo clippy --all --tests --features serde,rayon,bumpalo -- -D clippy::all started returning an error

fn test_extend_ref_kv_tuple() {
use std::ops::AddAssign;
let mut a = HashMap::new();
Expand Down Expand Up @@ -8080,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 @@ -8110,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 @@ -8380,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
Loading