Rollup merge of #65460 - sinkuu:contains_insert, r=varkor
Clean up `contains()` `insert()` chains on HashSet They can be merged to a single `insert()` call, which may avoid double-hashing/lookup of the value.
This commit is contained in:
commit
2518bbd5a3
7 changed files with 8 additions and 20 deletions
|
@ -905,11 +905,10 @@ pub fn check_unused_or_stable_features(tcx: TyCtxt<'_>) {
|
||||||
// Warn if the user has enabled an already-stable lang feature.
|
// Warn if the user has enabled an already-stable lang feature.
|
||||||
unnecessary_stable_feature_lint(tcx, span, feature, since);
|
unnecessary_stable_feature_lint(tcx, span, feature, since);
|
||||||
}
|
}
|
||||||
if lang_features.contains(&feature) {
|
if !lang_features.insert(feature) {
|
||||||
// Warn if the user enables a lang feature multiple times.
|
// Warn if the user enables a lang feature multiple times.
|
||||||
duplicate_feature_err(tcx.sess, span, feature);
|
duplicate_feature_err(tcx.sess, span, feature);
|
||||||
}
|
}
|
||||||
lang_features.insert(feature);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let declared_lib_features = &tcx.features().declared_lib_features;
|
let declared_lib_features = &tcx.features().declared_lib_features;
|
||||||
|
|
|
@ -2069,11 +2069,9 @@ fn set_members_of_composite_type(cx: &CodegenCx<'ll, 'tcx>,
|
||||||
{
|
{
|
||||||
let mut composite_types_completed =
|
let mut composite_types_completed =
|
||||||
debug_context(cx).composite_types_completed.borrow_mut();
|
debug_context(cx).composite_types_completed.borrow_mut();
|
||||||
if composite_types_completed.contains(&composite_type_metadata) {
|
if !composite_types_completed.insert(&composite_type_metadata) {
|
||||||
bug!("debuginfo::set_members_of_composite_type() - \
|
bug!("debuginfo::set_members_of_composite_type() - \
|
||||||
Already completed forward declaration re-encountered.");
|
Already completed forward declaration re-encountered.");
|
||||||
} else {
|
|
||||||
composite_types_completed.insert(composite_type_metadata);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -198,12 +198,10 @@ impl Collector<'tcx> {
|
||||||
self.tcx.sess.err(&format!("renaming of the library `{}` was specified, \
|
self.tcx.sess.err(&format!("renaming of the library `{}` was specified, \
|
||||||
however this crate contains no `#[link(...)]` \
|
however this crate contains no `#[link(...)]` \
|
||||||
attributes referencing this library.", name));
|
attributes referencing this library.", name));
|
||||||
} else if renames.contains(name) {
|
} else if !renames.insert(name) {
|
||||||
self.tcx.sess.err(&format!("multiple renamings were \
|
self.tcx.sess.err(&format!("multiple renamings were \
|
||||||
specified for library `{}` .",
|
specified for library `{}` .",
|
||||||
name));
|
name));
|
||||||
} else {
|
|
||||||
renames.insert(name);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,7 +78,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
||||||
.last()
|
.last()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
if self.uninitialized_error_reported.contains(&root_place) {
|
if !self.uninitialized_error_reported.insert(root_place) {
|
||||||
debug!(
|
debug!(
|
||||||
"report_use_of_moved_or_uninitialized place: error about {:?} suppressed",
|
"report_use_of_moved_or_uninitialized place: error about {:?} suppressed",
|
||||||
root_place
|
root_place
|
||||||
|
@ -86,8 +86,6 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
self.uninitialized_error_reported.insert(root_place);
|
|
||||||
|
|
||||||
let item_msg = match self.describe_place_with_options(used_place,
|
let item_msg = match self.describe_place_with_options(used_place,
|
||||||
IncludingDowncast(true)) {
|
IncludingDowncast(true)) {
|
||||||
Some(name) => format!("`{}`", name),
|
Some(name) => format!("`{}`", name),
|
||||||
|
|
|
@ -1214,7 +1214,7 @@ fn search_for_adt_without_structural_match<'tcx>(tcx: TyCtxt<'tcx>,
|
||||||
|
|
||||||
// tracks ADT's previously encountered during search, so that
|
// tracks ADT's previously encountered during search, so that
|
||||||
// we will not recur on them again.
|
// we will not recur on them again.
|
||||||
seen: FxHashSet<&'tcx AdtDef>,
|
seen: FxHashSet<hir::def_id::DefId>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> TypeVisitor<'tcx> for Search<'tcx> {
|
impl<'tcx> TypeVisitor<'tcx> for Search<'tcx> {
|
||||||
|
@ -1254,14 +1254,12 @@ fn search_for_adt_without_structural_match<'tcx>(tcx: TyCtxt<'tcx>,
|
||||||
return true // Halt visiting!
|
return true // Halt visiting!
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.seen.contains(adt_def) {
|
if !self.seen.insert(adt_def.did) {
|
||||||
debug!("Search already seen adt_def: {:?}", adt_def);
|
debug!("Search already seen adt_def: {:?}", adt_def);
|
||||||
// let caller continue its search
|
// let caller continue its search
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
self.seen.insert(adt_def);
|
|
||||||
|
|
||||||
// `#[structural_match]` does not care about the
|
// `#[structural_match]` does not care about the
|
||||||
// instantiation of the generics in an ADT (it
|
// instantiation of the generics in an ADT (it
|
||||||
// instead looks directly at its fields outside
|
// instead looks directly at its fields outside
|
||||||
|
|
|
@ -72,13 +72,11 @@ fn check_fn_for_unconditional_recursion(
|
||||||
let caller_substs = &InternalSubsts::identity_for_item(tcx, def_id)[..trait_substs_count];
|
let caller_substs = &InternalSubsts::identity_for_item(tcx, def_id)[..trait_substs_count];
|
||||||
|
|
||||||
while let Some(bb) = reachable_without_self_call_queue.pop() {
|
while let Some(bb) = reachable_without_self_call_queue.pop() {
|
||||||
if visited.contains(bb) {
|
if !visited.insert(bb) {
|
||||||
//already done
|
//already done
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
visited.insert(bb);
|
|
||||||
|
|
||||||
let block = &basic_blocks[bb];
|
let block = &basic_blocks[bb];
|
||||||
|
|
||||||
if let Some(ref terminator) = block.terminator {
|
if let Some(ref terminator) = block.terminator {
|
||||||
|
|
|
@ -673,13 +673,12 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
|
||||||
self.throw_unresolved_import_error(errors, None);
|
self.throw_unresolved_import_error(errors, None);
|
||||||
errors = vec![];
|
errors = vec![];
|
||||||
}
|
}
|
||||||
if !seen_spans.contains(&err.span) {
|
if seen_spans.insert(err.span) {
|
||||||
let path = import_path_to_string(
|
let path = import_path_to_string(
|
||||||
&import.module_path.iter().map(|seg| seg.ident).collect::<Vec<_>>(),
|
&import.module_path.iter().map(|seg| seg.ident).collect::<Vec<_>>(),
|
||||||
&import.subclass,
|
&import.subclass,
|
||||||
err.span,
|
err.span,
|
||||||
);
|
);
|
||||||
seen_spans.insert(err.span);
|
|
||||||
errors.push((path, err));
|
errors.push((path, err));
|
||||||
prev_root_id = import.root_id;
|
prev_root_id = import.root_id;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue