Skip to content

Commit 54e1309

Browse files
committed
Use HashMap entry APIs more
1 parent f058d05 commit 54e1309

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

compiler/rustc_hir_typeck/src/generator_interior/drop_ranges/cfg_build.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -526,8 +526,9 @@ impl DropRangesBuilder {
526526
let mut next = <_>::from(0u32);
527527
for value in tracked_values {
528528
for_each_consumable(hir, value, |value| {
529-
if !tracked_value_map.contains_key(&value) {
530-
tracked_value_map.insert(value, next);
529+
if let std::collections::hash_map::Entry::Vacant(e) = tracked_value_map.entry(value)
530+
{
531+
e.insert(next);
531532
next = next + 1;
532533
}
533534
});

compiler/rustc_lint/src/levels.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -266,12 +266,12 @@ impl LintLevelsProvider for QueryMapExpectationsWrapper<'_> {
266266
let LintExpectationId::Stable { attr_id: Some(attr_id), hir_id, attr_index, .. } = id else { bug!("unstable expectation id should already be mapped") };
267267
let key = LintExpectationId::Unstable { attr_id, lint_index: None };
268268

269-
if !self.unstable_to_stable_ids.contains_key(&key) {
270-
self.unstable_to_stable_ids.insert(
271-
key,
272-
LintExpectationId::Stable { hir_id, attr_index, lint_index: None, attr_id: None },
273-
);
274-
}
269+
self.unstable_to_stable_ids.entry(key).or_insert(LintExpectationId::Stable {
270+
hir_id,
271+
attr_index,
272+
lint_index: None,
273+
attr_id: None,
274+
});
275275

276276
self.expectations.push((id.normalize(), expectation));
277277
}

0 commit comments

Comments
 (0)