1
Fork 0

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

@ -373,7 +373,7 @@ impl<'a, 'tcx> CrateLoader<'a, 'tcx> {
let host_hash = host_lib.as_ref().map(|lib| lib.metadata.get_root().hash());
let private_dep =
self.sess.opts.externs.get(name.as_str()).map_or(false, |e| e.is_private_dep);
self.sess.opts.externs.get(name.as_str()).is_some_and(|e| e.is_private_dep);
// Claim this crate number and cache it
let cnum = self.cstore.intern_stable_crate_id(&crate_root)?;

View file

@ -567,7 +567,7 @@ impl<'a> CrateLocator<'a> {
let mut err_data: Option<Vec<PathBuf>> = None;
for (lib, kind) in m {
info!("{} reading metadata from: {}", flavor, lib.display());
if flavor == CrateFlavor::Rmeta && lib.metadata().map_or(false, |m| m.len() == 0) {
if flavor == CrateFlavor::Rmeta && lib.metadata().is_ok_and(|m| m.len() == 0) {
// Empty files will cause get_metadata_section to fail. Rmeta
// files can be empty, for example with binaries (which can
// often appear with `cargo check` when checking a library as
@ -602,7 +602,7 @@ impl<'a> CrateLocator<'a> {
}
};
// If we see multiple hashes, emit an error about duplicate candidates.
if slot.as_ref().map_or(false, |s| s.0 != hash) {
if slot.as_ref().is_some_and(|s| s.0 != hash) {
if let Some(candidates) = err_data {
return Err(CrateError::MultipleCandidates(
self.crate_name,

View file

@ -1060,7 +1060,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
.expect("argument names not encoded for a function")
.decode((self, sess))
.nth(0)
.map_or(false, |ident| ident.name == kw::SelfLower)
.is_some_and(|ident| ident.name == kw::SelfLower)
}
fn get_associated_item_or_field_def_ids(