Use Option::is_some_and and Result::is_ok_and in the compiler

This commit is contained in:
Maybe Waffle
2023-05-24 14:19:22 +00:00
parent 70db836922
commit fb0f74a8c9
87 changed files with 148 additions and 158 deletions

View File

@@ -2220,8 +2220,8 @@ impl<'tcx> TyCtxt<'tcx> {
let impl_trait_ref2 = self.impl_trait_ref(def_id2);
// If either trait impl references an error, they're allowed to overlap,
// as one of them essentially doesn't exist.
if impl_trait_ref1.map_or(false, |tr| tr.subst_identity().references_error())
|| impl_trait_ref2.map_or(false, |tr| tr.subst_identity().references_error())
if impl_trait_ref1.is_some_and(|tr| tr.subst_identity().references_error())
|| impl_trait_ref2.is_some_and(|tr| tr.subst_identity().references_error())
{
return Some(ImplOverlapKind::Permitted { marker: false });
}
@@ -2242,7 +2242,7 @@ impl<'tcx> TyCtxt<'tcx> {
let is_marker_overlap = {
let is_marker_impl = |trait_ref: Option<EarlyBinder<TraitRef<'_>>>| -> bool {
trait_ref.map_or(false, |tr| self.trait_def(tr.skip_binder().def_id).is_marker)
trait_ref.is_some_and(|tr| self.trait_def(tr.skip_binder().def_id).is_marker)
};
is_marker_impl(impl_trait_ref1) && is_marker_impl(impl_trait_ref2)
};