Simplify instances of Option::map_or(true, …) in Clippy sources
This commit is contained in:
parent
d1688b53f1
commit
ca963b653e
34 changed files with 39 additions and 42 deletions
|
|
@ -226,7 +226,7 @@ impl Constant<'_> {
|
|||
.zip(r)
|
||||
.zip(tys)
|
||||
.map(|((li, ri), cmp_type)| Self::partial_cmp(tcx, cmp_type, li, ri))
|
||||
.find(|r| r.map_or(true, |o| o != Ordering::Equal))
|
||||
.find(|r| r.is_none_or(|o| o != Ordering::Equal))
|
||||
.unwrap_or_else(|| Some(l.len().cmp(&r.len()))),
|
||||
_ => None,
|
||||
},
|
||||
|
|
@ -236,7 +236,7 @@ impl Constant<'_> {
|
|||
};
|
||||
iter::zip(l, r)
|
||||
.map(|(li, ri)| Self::partial_cmp(tcx, cmp_type, li, ri))
|
||||
.find(|r| r.map_or(true, |o| o != Ordering::Equal))
|
||||
.find(|r| r.is_none_or(|o| o != Ordering::Equal))
|
||||
.unwrap_or_else(|| Some(l.len().cmp(&r.len())))
|
||||
},
|
||||
(Self::Repeat(lv, ls), Self::Repeat(rv, rs)) => {
|
||||
|
|
|
|||
|
|
@ -1570,7 +1570,7 @@ pub fn is_else_clause_in_let_else(tcx: TyCtxt<'_>, expr: &Expr<'_>) -> bool {
|
|||
pub fn is_range_full(cx: &LateContext<'_>, expr: &Expr<'_>, container_path: Option<&Path<'_>>) -> bool {
|
||||
let ty = cx.typeck_results().expr_ty(expr);
|
||||
if let Some(Range { start, end, limits }) = Range::hir(expr) {
|
||||
let start_is_none_or_min = start.map_or(true, |start| {
|
||||
let start_is_none_or_min = start.is_none_or(|start| {
|
||||
if let rustc_ty::Adt(_, subst) = ty.kind()
|
||||
&& let bnd_ty = subst.type_at(0)
|
||||
&& let Some(min_val) = bnd_ty.numeric_min_val(cx.tcx)
|
||||
|
|
@ -1582,7 +1582,7 @@ pub fn is_range_full(cx: &LateContext<'_>, expr: &Expr<'_>, container_path: Opti
|
|||
false
|
||||
}
|
||||
});
|
||||
let end_is_none_or_max = end.map_or(true, |end| match limits {
|
||||
let end_is_none_or_max = end.is_none_or(|end| match limits {
|
||||
RangeLimits::Closed => {
|
||||
if let rustc_ty::Adt(_, subst) = ty.kind()
|
||||
&& let bnd_ty = subst.type_at(0)
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ pub fn expn_is_local(expn: ExpnId) -> bool {
|
|||
std::iter::once((expn, data))
|
||||
.chain(backtrace)
|
||||
.find_map(|(_, data)| data.macro_def_id)
|
||||
.map_or(true, DefId::is_local)
|
||||
.is_none_or(DefId::is_local)
|
||||
}
|
||||
|
||||
/// Returns an iterator of macro expansions that created the given span.
|
||||
|
|
|
|||
|
|
@ -121,7 +121,7 @@ impl Msrv {
|
|||
}
|
||||
|
||||
pub fn meets(&self, required: RustcVersion) -> bool {
|
||||
self.current().map_or(true, |msrv| msrv >= required)
|
||||
self.current().is_none_or(|msrv| msrv >= required)
|
||||
}
|
||||
|
||||
fn parse_attr(sess: &Session, attrs: &[Attribute]) -> Option<RustcVersion> {
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ pub fn mutated_variables<'tcx>(expr: &'tcx Expr<'_>, cx: &LateContext<'tcx>) ->
|
|||
}
|
||||
|
||||
pub fn is_potentially_mutated<'tcx>(variable: HirId, expr: &'tcx Expr<'_>, cx: &LateContext<'tcx>) -> bool {
|
||||
mutated_variables(expr, cx).map_or(true, |mutated| mutated.contains(&variable))
|
||||
mutated_variables(expr, cx).is_none_or(|mutated| mutated.contains(&variable))
|
||||
}
|
||||
|
||||
pub fn is_potentially_local_place(local_id: HirId, place: &Place<'_>) -> bool {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue