diff --git a/src/librustdoc/clean/types.rs b/src/librustdoc/clean/types.rs index ded256fd75c..ddbbce86548 100644 --- a/src/librustdoc/clean/types.rs +++ b/src/librustdoc/clean/types.rs @@ -498,7 +498,7 @@ pub(crate) fn link_names(&self, cache: &Cache) -> Vec { } pub(crate) fn is_crate(&self) -> bool { - self.is_mod() && self.def_id().map_or(false, |did| did.is_crate_root()) + self.is_mod() && self.def_id().is_some_and(|did| did.is_crate_root()) } pub(crate) fn is_mod(&self) -> bool { self.type_() == ItemType::Module @@ -2487,7 +2487,7 @@ pub(crate) fn new_glob(source: ImportSource, should_be_displayed: bool) -> Self } pub(crate) fn imported_item_is_doc_hidden(&self, tcx: TyCtxt<'_>) -> bool { - self.source.did.map_or(false, |did| tcx.is_doc_hidden(did)) + self.source.did.is_some_and(|did| tcx.is_doc_hidden(did)) } } diff --git a/src/librustdoc/clean/utils.rs b/src/librustdoc/clean/utils.rs index eb47ff94d2e..c22ad43e049 100644 --- a/src/librustdoc/clean/utils.rs +++ b/src/librustdoc/clean/utils.rs @@ -573,9 +573,8 @@ pub(crate) fn find_nearest_parent_module(tcx: TyCtxt<'_>, def_id: DefId) -> Opti /// This function exists because it runs on `hir::Attributes` whereas the other is a /// `clean::Attributes` method. pub(crate) fn has_doc_flag(tcx: TyCtxt<'_>, did: DefId, flag: Symbol) -> bool { - tcx.get_attrs(did, sym::doc).any(|attr| { - attr.meta_item_list().map_or(false, |l| rustc_attr::list_contains_name(&l, flag)) - }) + tcx.get_attrs(did, sym::doc) + .any(|attr| attr.meta_item_list().is_some_and(|l| rustc_attr::list_contains_name(&l, flag))) } /// A link to `doc.rust-lang.org` that includes the channel name. Use this instead of manual links diff --git a/src/librustdoc/config.rs b/src/librustdoc/config.rs index 99aa979027f..8e8b7ab346b 100644 --- a/src/librustdoc/config.rs +++ b/src/librustdoc/config.rs @@ -798,7 +798,7 @@ fn println_condition(condition: Condition) { /// Returns `true` if the file given as `self.input` is a Markdown file. pub(crate) fn markdown_input(&self) -> bool { - self.input.extension().map_or(false, |e| e == "md" || e == "markdown") + self.input.extension().is_some_and(|e| e == "md" || e == "markdown") } } diff --git a/src/librustdoc/formats/cache.rs b/src/librustdoc/formats/cache.rs index 9b1b6899751..9802097ea29 100644 --- a/src/librustdoc/formats/cache.rs +++ b/src/librustdoc/formats/cache.rs @@ -234,10 +234,10 @@ fn is_from_private_dep(tcx: TyCtxt<'_>, cache: &Cache, def_id: DefId) -> bool { && (self.cache.masked_crates.contains(&item.item_id.krate()) || i.trait_ .as_ref() - .map_or(false, |t| is_from_private_dep(self.tcx, self.cache, t.def_id())) + .is_some_and(|t| is_from_private_dep(self.tcx, self.cache, t.def_id())) || i.for_ .def_id(self.cache) - .map_or(false, |d| is_from_private_dep(self.tcx, self.cache, d))) + .is_some_and(|d| is_from_private_dep(self.tcx, self.cache, d))) { return None; } @@ -279,7 +279,7 @@ fn is_from_private_dep(tcx: TyCtxt<'_>, cache: &Cache, def_id: DefId) -> bool { .cache .parent_stack .last() - .map_or(false, |parent| parent.is_trait_impl()) => + .is_some_and(|parent| parent.is_trait_impl()) => { // skip associated items in trait impls ((None, None), false) @@ -341,7 +341,7 @@ fn is_from_private_dep(tcx: TyCtxt<'_>, cache: &Cache, def_id: DefId) -> bool { // A crate has a module at its root, containing all items, // which should not be indexed. The crate-item itself is // inserted later on when serializing the search-index. - if item.item_id.as_def_id().map_or(false, |idx| !idx.is_crate_root()) + if item.item_id.as_def_id().is_some_and(|idx| !idx.is_crate_root()) && let ty = item.type_() && (ty != ItemType::StructField || u16::from_str_radix(s.as_str(), 10).is_err()) diff --git a/src/librustdoc/html/render/mod.rs b/src/librustdoc/html/render/mod.rs index 8b3cd9ca6fc..ff5c761208b 100644 --- a/src/librustdoc/html/render/mod.rs +++ b/src/librustdoc/html/render/mod.rs @@ -1381,8 +1381,7 @@ pub(crate) fn notable_traits_button(ty: &clean::Type, cx: &mut Context<'_>) -> O if let Some(trait_) = &impl_.trait_ { let trait_did = trait_.def_id(); - if cx.cache().traits.get(&trait_did).map_or(false, |t| t.is_notable_trait(cx.tcx())) - { + if cx.cache().traits.get(&trait_did).is_some_and(|t| t.is_notable_trait(cx.tcx())) { has_notable_trait = true; } } @@ -1417,7 +1416,7 @@ fn notable_traits_decl(ty: &clean::Type, cx: &Context<'_>) -> (String, String) { if let Some(trait_) = &impl_.trait_ { let trait_did = trait_.def_id(); - if cx.cache().traits.get(&trait_did).map_or(false, |t| t.is_notable_trait(cx.tcx())) { + if cx.cache().traits.get(&trait_did).is_some_and(|t| t.is_notable_trait(cx.tcx())) { if out.is_empty() { write!( &mut out, diff --git a/src/librustdoc/passes/collect_trait_impls.rs b/src/librustdoc/passes/collect_trait_impls.rs index b60d7d4c718..b6f73d3fdcd 100644 --- a/src/librustdoc/passes/collect_trait_impls.rs +++ b/src/librustdoc/passes/collect_trait_impls.rs @@ -198,7 +198,7 @@ fn add_deref_target( cleaner.keep_impl( for_, trait_.as_ref().map(|t| t.def_id()) == tcx.lang_items().deref_trait(), - ) || trait_.as_ref().map_or(false, |t| cleaner.keep_impl_with_def_id(t.def_id().into())) + ) || trait_.as_ref().is_some_and(|t| cleaner.keep_impl_with_def_id(t.def_id().into())) || kind.is_blanket() } else { true