mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 14:55:26 +00:00
is_{some,ok}_and for rustdoc
This commit is contained in:
parent
fe3038f263
commit
63b2f55e83
@ -498,7 +498,7 @@ impl Item {
|
||||
}
|
||||
|
||||
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 @@ impl Import {
|
||||
}
|
||||
|
||||
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))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -798,7 +798,7 @@ impl Options {
|
||||
|
||||
/// 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")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -234,10 +234,10 @@ impl<'a, 'tcx> DocFolder for CacheBuilder<'a, 'tcx> {
|
||||
&& (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 @@ impl<'a, 'tcx> DocFolder for CacheBuilder<'a, 'tcx> {
|
||||
.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 @@ impl<'a, 'tcx> DocFolder for CacheBuilder<'a, 'tcx> {
|
||||
// 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())
|
||||
|
@ -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,
|
||||
|
@ -198,7 +198,7 @@ pub(crate) fn collect_trait_impls(mut krate: Crate, cx: &mut DocContext<'_>) ->
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user