Skip to content

Commit ababe17

Browse files
committed
Use is_some_and in librustdoc
1 parent 1329847 commit ababe17

File tree

8 files changed

+12
-12
lines changed

8 files changed

+12
-12
lines changed

src/librustdoc/clean/types.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,7 @@ impl Item {
559559
}
560560

561561
pub(crate) fn is_crate(&self) -> bool {
562-
self.is_mod() && self.item_id.as_def_id().map_or(false, |did| did.is_crate_root())
562+
self.is_mod() && self.item_id.as_def_id().is_some_and(|did| did.is_crate_root())
563563
}
564564
pub(crate) fn is_mod(&self) -> bool {
565565
self.type_() == ItemType::Module
@@ -2359,7 +2359,7 @@ impl ConstantKind {
23592359
pub(crate) fn is_literal(&self, tcx: TyCtxt<'_>) -> bool {
23602360
match *self {
23612361
ConstantKind::TyConst { .. } => false,
2362-
ConstantKind::Extern { def_id } => def_id.as_local().map_or(false, |def_id| {
2362+
ConstantKind::Extern { def_id } => def_id.as_local().is_some_and(|&def_id| {
23632363
is_literal_expr(tcx, tcx.hir().local_def_id_to_hir_id(def_id))
23642364
}),
23652365
ConstantKind::Local { body, .. } | ConstantKind::Anonymous { body } => {

src/librustdoc/clean/utils.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -476,9 +476,8 @@ pub(crate) fn find_nearest_parent_module(tcx: TyCtxt<'_>, def_id: DefId) -> Opti
476476
/// This function exists because it runs on `hir::Attributes` whereas the other is a
477477
/// `clean::Attributes` method.
478478
pub(crate) fn has_doc_flag(tcx: TyCtxt<'_>, did: DefId, flag: Symbol) -> bool {
479-
tcx.get_attrs(did, sym::doc).any(|attr| {
480-
attr.meta_item_list().map_or(false, |l| rustc_attr::list_contains_name(&l, flag))
481-
})
479+
tcx.get_attrs(did, sym::doc)
480+
.any(|attr| attr.meta_item_list().is_some_and(|l| rustc_attr::list_contains_name(&l, flag)))
482481
}
483482

484483
/// A link to `doc.rust-lang.org` that includes the channel name. Use this instead of manual links

src/librustdoc/config.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -746,7 +746,7 @@ impl Options {
746746

747747
/// Returns `true` if the file given as `self.input` is a Markdown file.
748748
pub(crate) fn markdown_input(&self) -> bool {
749-
self.input.extension().map_or(false, |e| e == "md" || e == "markdown")
749+
self.input.extension().is_some_and(|&e| e == "md" || e == "markdown")
750750
}
751751
}
752752

src/librustdoc/formats/cache.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -213,10 +213,10 @@ impl<'a, 'tcx> DocFolder for CacheBuilder<'a, 'tcx> {
213213
if self.cache.masked_crates.contains(&item.item_id.krate())
214214
|| i.trait_
215215
.as_ref()
216-
.map_or(false, |t| self.cache.masked_crates.contains(&t.def_id().krate))
216+
.is_some_and(|t| self.cache.masked_crates.contains(&t.def_id().krate))
217217
|| i.for_
218218
.def_id(self.cache)
219-
.map_or(false, |d| self.cache.masked_crates.contains(&d.krate))
219+
.is_some_and(|d| self.cache.masked_crates.contains(&d.krate))
220220
{
221221
return None;
222222
}
@@ -317,7 +317,7 @@ impl<'a, 'tcx> DocFolder for CacheBuilder<'a, 'tcx> {
317317
// A crate has a module at its root, containing all items,
318318
// which should not be indexed. The crate-item itself is
319319
// inserted later on when serializing the search-index.
320-
if item.item_id.as_def_id().map_or(false, |idx| !idx.is_crate_root()) {
320+
if item.item_id.as_def_id().is_some_and(|idx| !idx.is_crate_root()) {
321321
let desc = item.doc_value().map_or_else(String::new, |x| {
322322
short_markdown_summary(x.as_str(), &item.link_names(self.cache))
323323
});

src/librustdoc/html/render/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1220,7 +1220,7 @@ fn notable_traits_decl(decl: &clean::FnDecl, cx: &Context<'_>) -> String {
12201220
if let Some(trait_) = &impl_.trait_ {
12211221
let trait_did = trait_.def_id();
12221222

1223-
if cx.cache().traits.get(&trait_did).map_or(false, |t| t.is_notable) {
1223+
if cx.cache().traits.get(&trait_did).is_some_and(|t| t.is_notable) {
12241224
if out.is_empty() {
12251225
write!(
12261226
&mut out,

src/librustdoc/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#![feature(control_flow_enum)]
1010
#![feature(box_syntax)]
1111
#![feature(drain_filter)]
12+
#![feature(is_some_with)]
1213
#![feature(let_chains)]
1314
#![feature(let_else)]
1415
#![cfg_attr(bootstrap, feature(nll))]

src/librustdoc/passes/collect_trait_impls.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ pub(crate) fn collect_trait_impls(mut krate: Crate, cx: &mut DocContext<'_>) ->
191191
cleaner.keep_impl(
192192
for_,
193193
trait_.as_ref().map(|t| t.def_id()) == cx.tcx.lang_items().deref_trait(),
194-
) || trait_.as_ref().map_or(false, |t| cleaner.keep_impl_with_def_id(t.def_id().into()))
194+
) || trait_.is_some_and(|t| cleaner.keep_impl_with_def_id(t.def_id().into()))
195195
|| kind.is_blanket()
196196
} else {
197197
true

src/librustdoc/visit_lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ impl<'a, 'tcx> LibEmbargoVisitor<'a, 'tcx> {
5555

5656
for item in self.tcx.module_children(def_id).iter() {
5757
if let Some(def_id) = item.res.opt_def_id() {
58-
if self.tcx.def_key(def_id).parent.map_or(false, |d| d == def_id.index)
58+
if self.tcx.def_key(def_id).parent.is_some_and(|&d| d == def_id.index)
5959
|| item.vis.is_public()
6060
{
6161
self.visit_item(item.res);

0 commit comments

Comments
 (0)