Run clippy --fix
for unnecessary_map_or
lint
This commit is contained in:
parent
39dc268459
commit
264fa0fc54
39 changed files with 61 additions and 67 deletions
|
@ -397,7 +397,7 @@ impl Resolver<'_, '_> {
|
|||
}
|
||||
ImportKind::ExternCrate { id, .. } => {
|
||||
let def_id = self.local_def_id(id);
|
||||
if self.extern_crate_map.get(&def_id).map_or(true, |&cnum| {
|
||||
if self.extern_crate_map.get(&def_id).is_none_or(|&cnum| {
|
||||
!tcx.is_compiler_builtins(cnum)
|
||||
&& !tcx.is_panic_runtime(cnum)
|
||||
&& !tcx.has_global_allocator(cnum)
|
||||
|
|
|
@ -322,7 +322,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
|
|||
let duplicate = new_binding.res().opt_def_id() == old_binding.res().opt_def_id();
|
||||
let has_dummy_span = new_binding.span.is_dummy() || old_binding.span.is_dummy();
|
||||
let from_item =
|
||||
self.extern_prelude.get(&ident).map_or(true, |entry| entry.introduced_by_item);
|
||||
self.extern_prelude.get(&ident).is_none_or(|entry| entry.introduced_by_item);
|
||||
// Only suggest removing an import if both bindings are to the same def, if both spans
|
||||
// aren't dummy spans. Further, if both bindings are imports, then the ident must have
|
||||
// been introduced by an item.
|
||||
|
@ -537,7 +537,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
|
|||
) {
|
||||
module.for_each_child(self, |_this, ident, _ns, binding| {
|
||||
let res = binding.res();
|
||||
if filter_fn(res) && ctxt.map_or(true, |ctxt| ctxt == ident.span.ctxt()) {
|
||||
if filter_fn(res) && ctxt.is_none_or(|ctxt| ctxt == ident.span.ctxt()) {
|
||||
names.push(TypoSuggestion::typo_from_ident(ident, res));
|
||||
}
|
||||
});
|
||||
|
@ -1229,7 +1229,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
|
|||
_ => res.opt_def_id(),
|
||||
};
|
||||
let child_doc_visible = doc_visible
|
||||
&& (did.map_or(true, |did| did.is_local() || !this.tcx.is_doc_hidden(did)));
|
||||
&& did.is_none_or(|did| did.is_local() || !this.tcx.is_doc_hidden(did));
|
||||
|
||||
// collect results based on the filter function
|
||||
// avoid suggesting anything from the same module in which we are resolving
|
||||
|
|
|
@ -289,7 +289,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
|
|||
|
||||
if let ImportKind::Glob { ref max_vis, .. } = import.kind {
|
||||
if vis == import_vis
|
||||
|| max_vis.get().map_or(true, |max_vis| vis.is_at_least(max_vis, self.tcx))
|
||||
|| max_vis.get().is_none_or(|max_vis| vis.is_at_least(max_vis, self.tcx))
|
||||
{
|
||||
max_vis.set(Some(vis.expect_local()))
|
||||
}
|
||||
|
|
|
@ -612,7 +612,7 @@ impl MaybeExported<'_> {
|
|||
return vis.kind.is_pub();
|
||||
}
|
||||
};
|
||||
def_id.map_or(true, |def_id| r.effective_visibilities.is_exported(def_id))
|
||||
def_id.is_none_or(|def_id| r.effective_visibilities.is_exported(def_id))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5104,7 +5104,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
|
|||
fn def_id_matches_path(tcx: TyCtxt<'_>, mut def_id: DefId, expected_path: &[&str]) -> bool {
|
||||
let mut path = expected_path.iter().rev();
|
||||
while let (Some(parent), Some(next_step)) = (tcx.opt_parent(def_id), path.next()) {
|
||||
if !tcx.opt_item_name(def_id).map_or(false, |n| n.as_str() == *next_step) {
|
||||
if !tcx.opt_item_name(def_id).is_some_and(|n| n.as_str() == *next_step) {
|
||||
return false;
|
||||
}
|
||||
def_id = parent;
|
||||
|
|
|
@ -1696,7 +1696,7 @@ impl<'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> {
|
|||
) => {
|
||||
// Don't suggest macro if it's unstable.
|
||||
let suggestable = def_id.is_local()
|
||||
|| self.r.tcx.lookup_stability(def_id).map_or(true, |s| s.is_stable());
|
||||
|| self.r.tcx.lookup_stability(def_id).is_none_or(|s| s.is_stable());
|
||||
|
||||
err.span_label(span, fallback_label.to_string());
|
||||
|
||||
|
@ -2135,7 +2135,7 @@ impl<'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> {
|
|||
.r
|
||||
.delegation_fn_sigs
|
||||
.get(&self.r.local_def_id(assoc_item.id))
|
||||
.map_or(false, |sig| sig.has_self) =>
|
||||
.is_some_and(|sig| sig.has_self) =>
|
||||
{
|
||||
AssocSuggestion::MethodWithSelf { called }
|
||||
}
|
||||
|
@ -2166,7 +2166,7 @@ impl<'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> {
|
|||
.r
|
||||
.delegation_fn_sigs
|
||||
.get(&def_id)
|
||||
.map_or(false, |sig| sig.has_self),
|
||||
.is_some_and(|sig| sig.has_self),
|
||||
None => self
|
||||
.r
|
||||
.tcx
|
||||
|
|
|
@ -1242,7 +1242,7 @@ impl<'ra> ResolverArenas<'ra> {
|
|||
no_implicit_prelude,
|
||||
))));
|
||||
let def_id = module.opt_def_id();
|
||||
if def_id.map_or(true, |def_id| def_id.is_local()) {
|
||||
if def_id.is_none_or(|def_id| def_id.is_local()) {
|
||||
self.local_modules.borrow_mut().push(module);
|
||||
}
|
||||
if let Some(def_id) = def_id {
|
||||
|
|
|
@ -1055,7 +1055,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
|
|||
span: Span,
|
||||
) {
|
||||
if let Some(Res::NonMacroAttr(kind)) = res {
|
||||
if kind != NonMacroAttrKind::Tool && binding.map_or(true, |b| b.is_import()) {
|
||||
if kind != NonMacroAttrKind::Tool && binding.is_none_or(|b| b.is_import()) {
|
||||
let binding_span = binding.map(|binding| binding.span);
|
||||
self.dcx().emit_err(errors::CannotUseThroughAnImport {
|
||||
span,
|
||||
|
|
|
@ -350,10 +350,7 @@ pub fn strip_generics_from_path(path_str: &str) -> Result<Box<str>, MalformedGen
|
|||
/// If there are no doc-comments, return true.
|
||||
/// FIXME(#78591): Support both inner and outer attributes on the same item.
|
||||
pub fn inner_docs(attrs: &[impl AttributeExt]) -> bool {
|
||||
attrs
|
||||
.iter()
|
||||
.find(|a| a.doc_str().is_some())
|
||||
.map_or(true, |a| a.style() == ast::AttrStyle::Inner)
|
||||
attrs.iter().find(|a| a.doc_str().is_some()).is_none_or(|a| a.style() == ast::AttrStyle::Inner)
|
||||
}
|
||||
|
||||
/// Has `#[rustc_doc_primitive]` or `#[doc(keyword)]`.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue