update uses of extract_if in the compiler
This commit is contained in:
parent
03f1b73339
commit
fe521506a6
7 changed files with 13 additions and 13 deletions
|
@ -1569,18 +1569,18 @@ impl DiagCtxtInner {
|
|||
debug!(?diagnostic);
|
||||
debug!(?self.emitted_diagnostics);
|
||||
|
||||
let already_emitted_sub = |sub: &mut Subdiag| {
|
||||
let not_yet_emitted = |sub: &mut Subdiag| {
|
||||
debug!(?sub);
|
||||
if sub.level != OnceNote && sub.level != OnceHelp {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
let mut hasher = StableHasher::new();
|
||||
sub.hash(&mut hasher);
|
||||
let diagnostic_hash = hasher.finish();
|
||||
debug!(?diagnostic_hash);
|
||||
!self.emitted_diagnostics.insert(diagnostic_hash)
|
||||
self.emitted_diagnostics.insert(diagnostic_hash)
|
||||
};
|
||||
diagnostic.children.extract_if(already_emitted_sub).for_each(|_| {});
|
||||
diagnostic.children.retain_mut(not_yet_emitted);
|
||||
if already_emitted {
|
||||
let msg = "duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`";
|
||||
diagnostic.sub(Note, msg, MultiSpan::new());
|
||||
|
|
|
@ -205,7 +205,7 @@ impl EarlyLintPass for NonAsciiIdents {
|
|||
(IdentifierType::Not_NFKC, "Not_NFKC"),
|
||||
] {
|
||||
let codepoints: Vec<_> =
|
||||
chars.extract_if(|(_, ty)| *ty == Some(id_ty)).collect();
|
||||
chars.extract_if(.., |(_, ty)| *ty == Some(id_ty)).collect();
|
||||
if codepoints.is_empty() {
|
||||
continue;
|
||||
}
|
||||
|
@ -217,7 +217,7 @@ impl EarlyLintPass for NonAsciiIdents {
|
|||
}
|
||||
|
||||
let remaining = chars
|
||||
.extract_if(|(c, _)| !GeneralSecurityProfile::identifier_allowed(*c))
|
||||
.extract_if(.., |(c, _)| !GeneralSecurityProfile::identifier_allowed(*c))
|
||||
.collect::<Vec<_>>();
|
||||
if !remaining.is_empty() {
|
||||
cx.emit_span_lint(UNCOMMON_CODEPOINTS, sp, IdentifierUncommonCodepoints {
|
||||
|
|
|
@ -544,7 +544,7 @@ impl<'tcx> Collector<'tcx> {
|
|||
// can move them to the end of the list below.
|
||||
let mut existing = self
|
||||
.libs
|
||||
.extract_if(|lib| {
|
||||
.extract_if(.., |lib| {
|
||||
if lib.name.as_str() == passed_lib.name {
|
||||
// FIXME: This whole logic is questionable, whether modifiers are
|
||||
// involved or not, library reordering and kind overriding without
|
||||
|
|
|
@ -309,7 +309,7 @@ pub fn suggest_constraining_type_params<'a>(
|
|||
let Some(param) = param else { return false };
|
||||
|
||||
{
|
||||
let mut sized_constraints = constraints.extract_if(|(_, def_id, _)| {
|
||||
let mut sized_constraints = constraints.extract_if(.., |(_, def_id, _)| {
|
||||
def_id.is_some_and(|def_id| tcx.is_lang_item(def_id, LangItem::Sized))
|
||||
});
|
||||
if let Some((_, def_id, _)) = sized_constraints.next() {
|
||||
|
|
|
@ -2817,11 +2817,11 @@ fn show_candidates(
|
|||
path_strings.sort_by(|a, b| a.0.cmp(&b.0));
|
||||
path_strings.dedup_by(|a, b| a.0 == b.0);
|
||||
let core_path_strings =
|
||||
path_strings.extract_if(|p| p.0.starts_with("core::")).collect::<Vec<_>>();
|
||||
path_strings.extract_if(.., |p| p.0.starts_with("core::")).collect::<Vec<_>>();
|
||||
let std_path_strings =
|
||||
path_strings.extract_if(|p| p.0.starts_with("std::")).collect::<Vec<_>>();
|
||||
path_strings.extract_if(.., |p| p.0.starts_with("std::")).collect::<Vec<_>>();
|
||||
let foreign_crate_path_strings =
|
||||
path_strings.extract_if(|p| !p.0.starts_with("crate::")).collect::<Vec<_>>();
|
||||
path_strings.extract_if(.., |p| !p.0.starts_with("crate::")).collect::<Vec<_>>();
|
||||
|
||||
// We list the `crate` local paths first.
|
||||
// Then we list the `std`/`core` paths.
|
||||
|
|
|
@ -628,7 +628,7 @@ impl<'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> {
|
|||
// Try to filter out intrinsics candidates, as long as we have
|
||||
// some other candidates to suggest.
|
||||
let intrinsic_candidates: Vec<_> = candidates
|
||||
.extract_if(|sugg| {
|
||||
.extract_if(.., |sugg| {
|
||||
let path = path_names_to_string(&sugg.path);
|
||||
path.starts_with("core::intrinsics::") || path.starts_with("std::intrinsics::")
|
||||
})
|
||||
|
|
|
@ -447,7 +447,7 @@ pub fn normalize_param_env_or_error<'tcx>(
|
|||
// This works fairly well because trait matching does not actually care about param-env
|
||||
// TypeOutlives predicates - these are normally used by regionck.
|
||||
let outlives_predicates: Vec<_> = predicates
|
||||
.extract_if(|predicate| {
|
||||
.extract_if(.., |predicate| {
|
||||
matches!(predicate.kind().skip_binder(), ty::ClauseKind::TypeOutlives(..))
|
||||
})
|
||||
.collect();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue