Skip to content

Commit b5ad69b

Browse files
authored
Rollup merge of #139057 - yotamofek:pr/slice-contains, r=wesleywiser
use `slice::contains` where applicable Applies the [`manual_contains`](https://rust-lang.github.io/rust-clippy/master/index.html#manual_contains) clippy lint, plus some small drive-bys.
2 parents 0e722cc + 9ef35dd commit b5ad69b

File tree

7 files changed

+16
-15
lines changed

7 files changed

+16
-15
lines changed

Diff for: compiler/rustc_builtin_macros/src/edition_panic.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,11 @@ pub(crate) fn use_panic_2021(mut span: Span) -> bool {
7474
// (To avoid using the edition of e.g. the assert!() or debug_assert!() definition.)
7575
loop {
7676
let expn = span.ctxt().outer_expn_data();
77-
if let Some(features) = expn.allow_internal_unstable {
78-
if features.iter().any(|&f| f == sym::edition_panic) {
79-
span = expn.call_site;
80-
continue;
81-
}
77+
if let Some(features) = expn.allow_internal_unstable
78+
&& features.contains(&sym::edition_panic)
79+
{
80+
span = expn.call_site;
81+
continue;
8282
}
8383
break expn.edition >= Edition::Edition2021;
8484
}

Diff for: compiler/rustc_codegen_ssa/src/back/write.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2186,7 +2186,7 @@ fn msvc_imps_needed(tcx: TyCtxt<'_>) -> bool {
21862186
// indirectly from ThinLTO. In theory these are not needed as ThinLTO could resolve
21872187
// these, but it currently does not do so.
21882188
let can_have_static_objects =
2189-
tcx.sess.lto() == Lto::Thin || tcx.crate_types().iter().any(|ct| *ct == CrateType::Rlib);
2189+
tcx.sess.lto() == Lto::Thin || tcx.crate_types().contains(&CrateType::Rlib);
21902190

21912191
tcx.sess.target.is_like_windows &&
21922192
can_have_static_objects &&

Diff for: compiler/rustc_codegen_ssa/src/codegen_attrs.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
604604
if let Some((name, _)) = lang_items::extract(attrs)
605605
&& let Some(lang_item) = LangItem::from_name(name)
606606
{
607-
if WEAK_LANG_ITEMS.iter().any(|&l| l == lang_item) {
607+
if WEAK_LANG_ITEMS.contains(&lang_item) {
608608
codegen_fn_attrs.flags |= CodegenFnAttrFlags::RUSTC_STD_INTERNAL_SYMBOL;
609609
}
610610
if let Some(link_name) = lang_item.link_name() {

Diff for: compiler/rustc_mir_build/src/builder/scope.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1496,7 +1496,7 @@ fn build_scope_drops<'tcx>(
14961496
// path, then don't generate the drop. (We only take this into
14971497
// account for non-unwind paths so as not to disturb the
14981498
// caching mechanism.)
1499-
if scope.moved_locals.iter().any(|&o| o == local) {
1499+
if scope.moved_locals.contains(&local) {
15001500
continue;
15011501
}
15021502

Diff for: compiler/rustc_passes/src/entry.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ struct EntryContext<'tcx> {
2424
}
2525

2626
fn entry_fn(tcx: TyCtxt<'_>, (): ()) -> Option<(DefId, EntryFnType)> {
27-
let any_exe = tcx.crate_types().iter().any(|ty| *ty == CrateType::Executable);
27+
let any_exe = tcx.crate_types().contains(&CrateType::Executable);
2828
if !any_exe {
2929
// No need to find a main function.
3030
return None;

Diff for: compiler/rustc_session/src/utils.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -149,14 +149,15 @@ pub fn extra_compiler_flags() -> Option<(Vec<String>, bool)> {
149149
arg[a.len()..].to_string()
150150
};
151151
let option = content.split_once('=').map(|s| s.0).unwrap_or(&content);
152-
if ICE_REPORT_COMPILER_FLAGS_EXCLUDE.iter().any(|exc| option == *exc) {
152+
if ICE_REPORT_COMPILER_FLAGS_EXCLUDE.contains(&option) {
153153
excluded_cargo_defaults = true;
154154
} else {
155155
result.push(a.to_string());
156-
match ICE_REPORT_COMPILER_FLAGS_STRIP_VALUE.iter().find(|s| option == **s) {
157-
Some(s) => result.push(format!("{s}=[REDACTED]")),
158-
None => result.push(content),
159-
}
156+
result.push(if ICE_REPORT_COMPILER_FLAGS_STRIP_VALUE.contains(&option) {
157+
format!("{option}=[REDACTED]")
158+
} else {
159+
content
160+
});
160161
}
161162
}
162163
}

Diff for: compiler/rustc_span/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -876,7 +876,7 @@ impl Span {
876876
self.ctxt()
877877
.outer_expn_data()
878878
.allow_internal_unstable
879-
.is_some_and(|features| features.iter().any(|&f| f == feature))
879+
.is_some_and(|features| features.contains(&feature))
880880
}
881881

882882
/// Checks if this span arises from a compiler desugaring of kind `kind`.

0 commit comments

Comments
 (0)