Skip to content

Commit ac2f906

Browse files
committed
Make use of the return value of HashSet::insert
1 parent d5ffd36 commit ac2f906

File tree

6 files changed

+6
-16
lines changed

6 files changed

+6
-16
lines changed

src/librustc/middle/stability.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -905,11 +905,10 @@ pub fn check_unused_or_stable_features(tcx: TyCtxt<'_>) {
905905
// Warn if the user has enabled an already-stable lang feature.
906906
unnecessary_stable_feature_lint(tcx, span, feature, since);
907907
}
908-
if lang_features.contains(&feature) {
908+
if !lang_features.insert(feature) {
909909
// Warn if the user enables a lang feature multiple times.
910910
duplicate_feature_err(tcx.sess, span, feature);
911911
}
912-
lang_features.insert(feature);
913912
}
914913

915914
let declared_lib_features = &tcx.features().declared_lib_features;

src/librustc_codegen_llvm/debuginfo/metadata.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -2069,11 +2069,9 @@ fn set_members_of_composite_type(cx: &CodegenCx<'ll, 'tcx>,
20692069
{
20702070
let mut composite_types_completed =
20712071
debug_context(cx).composite_types_completed.borrow_mut();
2072-
if composite_types_completed.contains(&composite_type_metadata) {
2072+
if !composite_types_completed.insert(&composite_type_metadata) {
20732073
bug!("debuginfo::set_members_of_composite_type() - \
20742074
Already completed forward declaration re-encountered.");
2075-
} else {
2076-
composite_types_completed.insert(composite_type_metadata);
20772075
}
20782076
}
20792077

src/librustc_metadata/native_libs.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -198,12 +198,10 @@ impl Collector<'tcx> {
198198
self.tcx.sess.err(&format!("renaming of the library `{}` was specified, \
199199
however this crate contains no `#[link(...)]` \
200200
attributes referencing this library.", name));
201-
} else if renames.contains(name) {
201+
} else if !renames.insert(name) {
202202
self.tcx.sess.err(&format!("multiple renamings were \
203203
specified for library `{}` .",
204204
name));
205-
} else {
206-
renames.insert(name);
207205
}
208206
}
209207
}

src/librustc_mir/borrow_check/conflict_errors.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -78,16 +78,14 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
7878
.last()
7979
.unwrap();
8080

81-
if self.uninitialized_error_reported.contains(&root_place) {
81+
if !self.uninitialized_error_reported.insert(root_place) {
8282
debug!(
8383
"report_use_of_moved_or_uninitialized place: error about {:?} suppressed",
8484
root_place
8585
);
8686
return;
8787
}
8888

89-
self.uninitialized_error_reported.insert(root_place);
90-
9189
let item_msg = match self.describe_place_with_options(used_place,
9290
IncludingDowncast(true)) {
9391
Some(name) => format!("`{}`", name),

src/librustc_mir/lints.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,11 @@ fn check_fn_for_unconditional_recursion(
7272
let caller_substs = &InternalSubsts::identity_for_item(tcx, def_id)[..trait_substs_count];
7373

7474
while let Some(bb) = reachable_without_self_call_queue.pop() {
75-
if visited.contains(bb) {
75+
if !visited.insert(bb) {
7676
//already done
7777
continue;
7878
}
7979

80-
visited.insert(bb);
81-
8280
let block = &basic_blocks[bb];
8381

8482
if let Some(ref terminator) = block.terminator {

src/librustc_resolve/resolve_imports.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -670,13 +670,12 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
670670
self.throw_unresolved_import_error(errors, None);
671671
errors = vec![];
672672
}
673-
if !seen_spans.contains(&err.span) {
673+
if seen_spans.insert(err.span) {
674674
let path = import_path_to_string(
675675
&import.module_path.iter().map(|seg| seg.ident).collect::<Vec<_>>(),
676676
&import.subclass,
677677
err.span,
678678
);
679-
seen_spans.insert(err.span);
680679
errors.push((path, err));
681680
prev_root_id = import.root_id;
682681
}

0 commit comments

Comments
 (0)