Skip to content

Commit

Permalink
Make use of the return value of HashSet::insert
Browse files Browse the repository at this point in the history
  • Loading branch information
sinkuu committed Oct 16, 2019
1 parent d5ffd36 commit ac2f906
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 16 deletions.
3 changes: 1 addition & 2 deletions src/librustc/middle/stability.rs
Expand Up @@ -905,11 +905,10 @@ pub fn check_unused_or_stable_features(tcx: TyCtxt<'_>) {
// Warn if the user has enabled an already-stable lang feature.
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.
duplicate_feature_err(tcx.sess, span, feature);
}
lang_features.insert(feature);
}

let declared_lib_features = &tcx.features().declared_lib_features;
Expand Down
4 changes: 1 addition & 3 deletions src/librustc_codegen_llvm/debuginfo/metadata.rs
Expand Up @@ -2069,11 +2069,9 @@ fn set_members_of_composite_type(cx: &CodegenCx<'ll, 'tcx>,
{
let mut composite_types_completed =
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() - \
Already completed forward declaration re-encountered.");
} else {
composite_types_completed.insert(composite_type_metadata);
}
}

Expand Down
4 changes: 1 addition & 3 deletions src/librustc_metadata/native_libs.rs
Expand Up @@ -198,12 +198,10 @@ impl Collector<'tcx> {
self.tcx.sess.err(&format!("renaming of the library `{}` was specified, \
however this crate contains no `#[link(...)]` \
attributes referencing this library.", name));
} else if renames.contains(name) {
} else if !renames.insert(name) {
self.tcx.sess.err(&format!("multiple renamings were \
specified for library `{}` .",
name));
} else {
renames.insert(name);
}
}
}
Expand Down
4 changes: 1 addition & 3 deletions src/librustc_mir/borrow_check/conflict_errors.rs
Expand Up @@ -78,16 +78,14 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
.last()
.unwrap();

if self.uninitialized_error_reported.contains(&root_place) {
if !self.uninitialized_error_reported.insert(root_place) {
debug!(
"report_use_of_moved_or_uninitialized place: error about {:?} suppressed",
root_place
);
return;
}

self.uninitialized_error_reported.insert(root_place);

let item_msg = match self.describe_place_with_options(used_place,
IncludingDowncast(true)) {
Some(name) => format!("`{}`", name),
Expand Down
4 changes: 1 addition & 3 deletions src/librustc_mir/lints.rs
Expand Up @@ -72,13 +72,11 @@ fn check_fn_for_unconditional_recursion(
let caller_substs = &InternalSubsts::identity_for_item(tcx, def_id)[..trait_substs_count];

while let Some(bb) = reachable_without_self_call_queue.pop() {
if visited.contains(bb) {
if !visited.insert(bb) {
//already done
continue;
}

visited.insert(bb);

let block = &basic_blocks[bb];

if let Some(ref terminator) = block.terminator {
Expand Down
3 changes: 1 addition & 2 deletions src/librustc_resolve/resolve_imports.rs
Expand Up @@ -670,13 +670,12 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
self.throw_unresolved_import_error(errors, None);
errors = vec![];
}
if !seen_spans.contains(&err.span) {
if seen_spans.insert(err.span) {
let path = import_path_to_string(
&import.module_path.iter().map(|seg| seg.ident).collect::<Vec<_>>(),
&import.subclass,
err.span,
);
seen_spans.insert(err.span);
errors.push((path, err));
prev_root_id = import.root_id;
}
Expand Down

0 comments on commit ac2f906

Please sign in to comment.