Skip to content

Commit d8ce784

Browse files
committed
update uses of extract_if in the compiler
1 parent f1e2d70 commit d8ce784

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
@@ -1558,18 +1558,18 @@ impl DiagCtxtInner {
15581558
debug!(?diagnostic);
15591559
debug!(?self.emitted_diagnostics);
15601560

1561-
let already_emitted_sub = |sub: &mut Subdiag| {
1561+
let not_yet_emitted = |sub: &mut Subdiag| {
15621562
debug!(?sub);
15631563
if sub.level != OnceNote && sub.level != OnceHelp {
1564-
return false;
1564+
return true;
15651565
}
15661566
let mut hasher = StableHasher::new();
15671567
sub.hash(&mut hasher);
15681568
let diagnostic_hash = hasher.finish();
15691569
debug!(?diagnostic_hash);
1570-
!self.emitted_diagnostics.insert(diagnostic_hash)
1570+
self.emitted_diagnostics.insert(diagnostic_hash)
15711571
};
1572-
diagnostic.children.extract_if(already_emitted_sub).for_each(|_| {});
1572+
diagnostic.children.retain_mut(not_yet_emitted);
15731573
if already_emitted {
15741574
let msg = "duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`";
15751575
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
@@ -540,7 +540,7 @@ impl<'tcx> Collector<'tcx> {
540540
// can move them to the end of the list below.
541541
let mut existing = self
542542
.libs
543-
.extract_if(|lib| {
543+
.extract_if(.., |lib| {
544544
if lib.name.as_str() == passed_lib.name {
545545
// FIXME: This whole logic is questionable, whether modifiers are
546546
// 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
@@ -290,7 +290,7 @@ pub fn suggest_constraining_type_params<'a>(
290290
let Some(param) = param else { return false };
291291

292292
{
293-
let mut sized_constraints = constraints.extract_if(|(_, def_id)| {
293+
let mut sized_constraints = constraints.extract_if(.., |(_, def_id)| {
294294
def_id.is_some_and(|def_id| tcx.is_lang_item(def_id, LangItem::Sized))
295295
});
296296
if let Some((_, def_id)) = sized_constraints.next() {

compiler/rustc_resolve/src/diagnostics.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -2805,11 +2805,11 @@ fn show_candidates(
28052805
path_strings.sort_by(|a, b| a.0.cmp(&b.0));
28062806
path_strings.dedup_by(|a, b| a.0 == b.0);
28072807
let core_path_strings =
2808-
path_strings.extract_if(|p| p.0.starts_with("core::")).collect::<Vec<_>>();
2808+
path_strings.extract_if(.., |p| p.0.starts_with("core::")).collect::<Vec<_>>();
28092809
let std_path_strings =
2810-
path_strings.extract_if(|p| p.0.starts_with("std::")).collect::<Vec<_>>();
2810+
path_strings.extract_if(.., |p| p.0.starts_with("std::")).collect::<Vec<_>>();
28112811
let foreign_crate_path_strings =
2812-
path_strings.extract_if(|p| !p.0.starts_with("crate::")).collect::<Vec<_>>();
2812+
path_strings.extract_if(.., |p| !p.0.starts_with("crate::")).collect::<Vec<_>>();
28132813

28142814
// We list the `crate` local paths first.
28152815
// 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)