fix: clippy warnings

This commit is contained in:
Shunsuke Shibayama 2025-02-21 18:00:45 +09:00
parent 51190620b3
commit 7c75ba0044
6 changed files with 13 additions and 13 deletions

View file

@ -688,7 +688,7 @@ impl<Checker: BuildRunnable, Parser: Parsable> Server<Checker, Parser> {
&mod_ctx.context,
)?);
}
if receiver_t.as_ref().map_or(true, |t| t == &Type::Never) {
if receiver_t.as_ref().is_none_or(|t| t == &Type::Never) {
let pos = params.text_document_position.position;
if let Some(attr) = self.file_cache.get_symbol(&uri, pos) {
result.extend(self.get_attr_completion_by_name(
@ -704,7 +704,7 @@ impl<Checker: BuildRunnable, Parser: Parsable> Server<Checker, Parser> {
}
// only show static methods, if the receiver is a type
if vi.t.is_method()
&& receiver_t.as_ref().map_or(true, |receiver| {
&& receiver_t.as_ref().is_none_or(|receiver| {
!mod_ctx
.context
.subtype_of(receiver, vi.t.self_t().unwrap_or(Type::OBJ))

View file

@ -51,7 +51,7 @@ where
let most_similar_name =
candidates.min_by_key(|v| levenshtein(v.borrow(), name, limit).unwrap_or(usize::MAX))?;
let dist = levenshtein(most_similar_name.borrow(), name, limit);
if dist.map_or(true, |d| d >= limit) {
if dist.is_none_or(|d| d >= limit) {
None
} else {
Some(most_similar_name)
@ -69,7 +69,7 @@ where
let most_similar_name_and_some = candidates
.min_by_key(|(_, v)| levenshtein(v.borrow(), name, limit).unwrap_or(usize::MAX))?;
let dist = levenshtein(most_similar_name_and_some.1.borrow(), name, limit);
if dist.map_or(true, |d| d >= limit) {
if dist.is_none_or(|d| d >= limit) {
None
} else {
Some(most_similar_name_and_some)

View file

@ -2268,7 +2268,7 @@ impl Context {
.non_default_params
.iter()
.enumerate()
.filter(|(_, pt)| pt.name().map_or(true, |name| !passed_params.contains(name)))
.filter(|(_, pt)| pt.name().is_none_or(|name| !passed_params.contains(name)))
.map(|(i, pt)| {
let n = if is_method_call { i } else { i + 1 };
let nth = format!("({} param)", ordinal_num(n));
@ -4011,14 +4011,14 @@ impl Context {
if cand
.return_t()
.zip(first.return_t())
.map_or(true, |(a, b)| a != b)
.is_none_or(|(a, b)| a != b)
{
return false;
}
if cand
.non_default_params()
.zip(first.non_default_params())
.map_or(true, |(a, b)| a.len() != b.len())
.is_none_or(|(a, b)| a.len() != b.len())
{
return false;
}
@ -4028,7 +4028,7 @@ impl Context {
if cand
.default_params()
.zip(first.default_params())
.map_or(true, |(a, b)| {
.is_none_or(|(a, b)| {
a.len() != b.len() || a.iter().zip(b.iter()).any(|(a, b)| a.name() != b.name())
})
{

View file

@ -471,7 +471,7 @@ impl<'c> SideEffectChecker<'c> {
if !self.in_context_effects_allowed()
&& !acc.var_info().is_parameter()
&& acc.ref_t().is_mut_type()
&& acc.root_obj().map_or(true, |obj| !obj.ref_t().is_ref())
&& acc.root_obj().is_none_or(|obj| !obj.ref_t().is_ref())
&& acc.var_info().def_namespace() != &self.full_path()
{
self.errs.push(EffectError::touch_mut_error(

View file

@ -1427,7 +1427,7 @@ impl<A: ASTBuildable> GenericASTLowerer<A> {
.module
.context
.current_control_flow()
.map_or(true, |kind| !kind.is_if())
.is_none_or(|kind| !kind.is_if())
&& expect.is_some_and(|subr| !subr.essential_qnames().is_empty())
{
pos_args
@ -3172,7 +3172,7 @@ impl<A: ASTBuildable> GenericASTLowerer<A> {
let outer = self.module.context.get_outer_scope().unwrap();
let trait_ctx = outer.get_nominal_type_ctx(&impl_trait);
let external_trait =
trait_ctx.map_or(true, |tr| !tr.name.starts_with(&outer.name[..]));
trait_ctx.is_none_or(|tr| !tr.name.starts_with(&outer.name[..]));
if sups.any(|t| t == mono("Sealed")) && external_trait {
return Err(LowerError::sealed_trait_error(
self.cfg.input.clone(),

View file

@ -2258,7 +2258,7 @@ impl StructuralEq for Type {
&& after
.as_ref()
.zip(after2.as_ref())
.map_or(true, |(a, b)| a.structural_eq(b))
.is_none_or(|(a, b)| a.structural_eq(b))
}
(
Self::Proj { lhs, rhs },
@ -2594,7 +2594,7 @@ impl Type {
Self::Record(attrs) => attrs.values().all(|t| t.is_singleton()),
Self::Ref(t) => t.is_singleton(),
Self::RefMut { before, after } => {
before.is_singleton() && after.as_ref().map_or(true, |t| t.is_singleton())
before.is_singleton() && after.as_ref().is_none_or(|t| t.is_singleton())
}
Self::Structural(ty) => ty.is_singleton(),
Self::Bounded { sub, sup } => sub.is_singleton() && sup.is_singleton(),