about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMoskalykA <100430077+MoskalykA@users.noreply.github.com>2024-10-07 06:46:01 +0200
committerLaurențiu Nicola <lnicola@dend.ro>2024-10-26 09:39:04 +0300
commit510090f77453980255db60725532ab5ec111ce0b (patch)
treebadd589c8664ff0df3ca7a57aa61b6f904549902
parented670e093affc0d29e8e2464a04fa29c808eb6f1 (diff)
downloadrust-510090f77453980255db60725532ab5ec111ce0b.tar.gz
rust-510090f77453980255db60725532ab5ec111ce0b.zip
Start using `Option::is_none_or`
-rw-r--r--src/tools/rust-analyzer/crates/hir-ty/src/consteval.rs4
-rw-r--r--src/tools/rust-analyzer/crates/ide-completion/src/completions/mod_.rs3
-rw-r--r--src/tools/rust-analyzer/crates/stdx/src/lib.rs16
3 files changed, 3 insertions, 20 deletions
diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/consteval.rs b/src/tools/rust-analyzer/crates/hir-ty/src/consteval.rs
index 9b0044f5c4f..ba0952f708f 100644
--- a/src/tools/rust-analyzer/crates/hir-ty/src/consteval.rs
+++ b/src/tools/rust-analyzer/crates/hir-ty/src/consteval.rs
@@ -11,7 +11,7 @@ use hir_def::{
     ConstBlockLoc, EnumVariantId, GeneralConstId, StaticId,
 };
 use hir_expand::Lookup;
-use stdx::{never, IsNoneOr};
+use stdx::never;
 use triomphe::Arc;
 
 use crate::{
@@ -287,7 +287,7 @@ pub(crate) fn const_eval_discriminant_variant(
     }
 
     let repr = db.enum_data(loc.parent).repr;
-    let is_signed = IsNoneOr::is_none_or(repr.and_then(|repr| repr.int), |int| int.is_signed());
+    let is_signed = Option::is_none_or(repr.and_then(|repr| repr.int), |int| int.is_signed());
 
     let mir_body = db.monomorphized_mir_body(
         def,
diff --git a/src/tools/rust-analyzer/crates/ide-completion/src/completions/mod_.rs b/src/tools/rust-analyzer/crates/ide-completion/src/completions/mod_.rs
index 05e2892fdc8..c0fb981749a 100644
--- a/src/tools/rust-analyzer/crates/ide-completion/src/completions/mod_.rs
+++ b/src/tools/rust-analyzer/crates/ide-completion/src/completions/mod_.rs
@@ -7,7 +7,6 @@ use ide_db::{
     base_db::{SourceRootDatabase, VfsPath},
     FxHashSet, RootDatabase, SymbolKind,
 };
-use stdx::IsNoneOr;
 use syntax::{ast, AstNode, SyntaxKind, ToSmolStr};
 
 use crate::{context::CompletionContext, CompletionItem, Completions};
@@ -66,7 +65,7 @@ pub(crate) fn complete_mod(
         .iter()
         .filter(|&submodule_candidate_file| submodule_candidate_file != module_definition_file)
         .filter(|&submodule_candidate_file| {
-            IsNoneOr::is_none_or(module_declaration_file, |it| it != submodule_candidate_file)
+            Option::is_none_or(module_declaration_file, |it| it != submodule_candidate_file)
         })
         .filter_map(|submodule_file| {
             let submodule_path = source_root.path_for_file(&submodule_file)?;
diff --git a/src/tools/rust-analyzer/crates/stdx/src/lib.rs b/src/tools/rust-analyzer/crates/stdx/src/lib.rs
index 76dbd42ff6b..1c42d198e55 100644
--- a/src/tools/rust-analyzer/crates/stdx/src/lib.rs
+++ b/src/tools/rust-analyzer/crates/stdx/src/lib.rs
@@ -304,22 +304,6 @@ pub fn slice_tails<T>(this: &[T]) -> impl Iterator<Item = &[T]> {
     (0..this.len()).map(|i| &this[i..])
 }
 
-pub trait IsNoneOr {
-    type Type;
-    #[allow(clippy::wrong_self_convention)]
-    fn is_none_or(self, s: impl FnOnce(Self::Type) -> bool) -> bool;
-}
-#[allow(unstable_name_collisions)]
-impl<T> IsNoneOr for Option<T> {
-    type Type = T;
-    fn is_none_or(self, f: impl FnOnce(T) -> bool) -> bool {
-        match self {
-            Some(v) => f(v),
-            None => true,
-        }
-    }
-}
-
 #[cfg(test)]
 mod tests {
     use super::*;