Skip to content

Commit fe52150

Browse files
committed
update uses of extract_if in the compiler
1 parent 03f1b73 commit fe52150

File tree

7 files changed

+13
-13
lines changed

7 files changed

+13
-13
lines changed

compiler/rustc_errors/src/lib.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1569,18 +1569,18 @@ impl DiagCtxtInner {
15691569
debug!(?diagnostic);
15701570
debug!(?self.emitted_diagnostics);
15711571

1572-
let already_emitted_sub = |sub: &mut Subdiag| {
1572+
let not_yet_emitted = |sub: &mut Subdiag| {
15731573
debug!(?sub);
15741574
if sub.level != OnceNote && sub.level != OnceHelp {
1575-
return false;
1575+
return true;
15761576
}
15771577
let mut hasher = StableHasher::new();
15781578
sub.hash(&mut hasher);
15791579
let diagnostic_hash = hasher.finish();
15801580
debug!(?diagnostic_hash);
1581-
!self.emitted_diagnostics.insert(diagnostic_hash)
1581+
self.emitted_diagnostics.insert(diagnostic_hash)
15821582
};
1583-
diagnostic.children.extract_if(already_emitted_sub).for_each(|_| {});
1583+
diagnostic.children.retain_mut(not_yet_emitted);
15841584
if already_emitted {
15851585
let msg = "duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`";
15861586
diagnostic.sub(Note, msg, MultiSpan::new());

compiler/rustc_lint/src/non_ascii_idents.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ impl EarlyLintPass for NonAsciiIdents {
205205
(IdentifierType::Not_NFKC, "Not_NFKC"),
206206
] {
207207
let codepoints: Vec<_> =
208-
chars.extract_if(|(_, ty)| *ty == Some(id_ty)).collect();
208+
chars.extract_if(.., |(_, ty)| *ty == Some(id_ty)).collect();
209209
if codepoints.is_empty() {
210210
continue;
211211
}
@@ -217,7 +217,7 @@ impl EarlyLintPass for NonAsciiIdents {
217217
}
218218

219219
let remaining = chars
220-
.extract_if(|(c, _)| !GeneralSecurityProfile::identifier_allowed(*c))
220+
.extract_if(.., |(c, _)| !GeneralSecurityProfile::identifier_allowed(*c))
221221
.collect::<Vec<_>>();
222222
if !remaining.is_empty() {
223223
cx.emit_span_lint(UNCOMMON_CODEPOINTS, sp, IdentifierUncommonCodepoints {

compiler/rustc_metadata/src/native_libs.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,7 @@ impl<'tcx> Collector<'tcx> {
544544
// can move them to the end of the list below.
545545
let mut existing = self
546546
.libs
547-
.extract_if(|lib| {
547+
.extract_if(.., |lib| {
548548
if lib.name.as_str() == passed_lib.name {
549549
// FIXME: This whole logic is questionable, whether modifiers are
550550
// involved or not, library reordering and kind overriding without

compiler/rustc_middle/src/ty/diagnostics.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ pub fn suggest_constraining_type_params<'a>(
309309
let Some(param) = param else { return false };
310310

311311
{
312-
let mut sized_constraints = constraints.extract_if(|(_, def_id, _)| {
312+
let mut sized_constraints = constraints.extract_if(.., |(_, def_id, _)| {
313313
def_id.is_some_and(|def_id| tcx.is_lang_item(def_id, LangItem::Sized))
314314
});
315315
if let Some((_, def_id, _)) = sized_constraints.next() {

compiler/rustc_resolve/src/diagnostics.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -2817,11 +2817,11 @@ fn show_candidates(
28172817
path_strings.sort_by(|a, b| a.0.cmp(&b.0));
28182818
path_strings.dedup_by(|a, b| a.0 == b.0);
28192819
let core_path_strings =
2820-
path_strings.extract_if(|p| p.0.starts_with("core::")).collect::<Vec<_>>();
2820+
path_strings.extract_if(.., |p| p.0.starts_with("core::")).collect::<Vec<_>>();
28212821
let std_path_strings =
2822-
path_strings.extract_if(|p| p.0.starts_with("std::")).collect::<Vec<_>>();
2822+
path_strings.extract_if(.., |p| p.0.starts_with("std::")).collect::<Vec<_>>();
28232823
let foreign_crate_path_strings =
2824-
path_strings.extract_if(|p| !p.0.starts_with("crate::")).collect::<Vec<_>>();
2824+
path_strings.extract_if(.., |p| !p.0.starts_with("crate::")).collect::<Vec<_>>();
28252825

28262826
// We list the `crate` local paths first.
28272827
// Then we list the `std`/`core` paths.

compiler/rustc_resolve/src/late/diagnostics.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -628,7 +628,7 @@ impl<'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> {
628628
// Try to filter out intrinsics candidates, as long as we have
629629
// some other candidates to suggest.
630630
let intrinsic_candidates: Vec<_> = candidates
631-
.extract_if(|sugg| {
631+
.extract_if(.., |sugg| {
632632
let path = path_names_to_string(&sugg.path);
633633
path.starts_with("core::intrinsics::") || path.starts_with("std::intrinsics::")
634634
})

compiler/rustc_trait_selection/src/traits/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ pub fn normalize_param_env_or_error<'tcx>(
447447
// This works fairly well because trait matching does not actually care about param-env
448448
// TypeOutlives predicates - these are normally used by regionck.
449449
let outlives_predicates: Vec<_> = predicates
450-
.extract_if(|predicate| {
450+
.extract_if(.., |predicate| {
451451
matches!(predicate.kind().skip_binder(), ty::ClauseKind::TypeOutlives(..))
452452
})
453453
.collect();

0 commit comments

Comments
 (0)