Skip to content

Commit 510090f

Browse files
766974616c79lnicola
authored andcommitted
Start using Option::is_none_or
1 parent ed670e0 commit 510090f

File tree

3 files changed

+3
-20
lines changed

3 files changed

+3
-20
lines changed

src/tools/rust-analyzer/crates/hir-ty/src/consteval.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use hir_def::{
1111
ConstBlockLoc, EnumVariantId, GeneralConstId, StaticId,
1212
};
1313
use hir_expand::Lookup;
14-
use stdx::{never, IsNoneOr};
14+
use stdx::never;
1515
use triomphe::Arc;
1616

1717
use crate::{
@@ -287,7 +287,7 @@ pub(crate) fn const_eval_discriminant_variant(
287287
}
288288

289289
let repr = db.enum_data(loc.parent).repr;
290-
let is_signed = IsNoneOr::is_none_or(repr.and_then(|repr| repr.int), |int| int.is_signed());
290+
let is_signed = Option::is_none_or(repr.and_then(|repr| repr.int), |int| int.is_signed());
291291

292292
let mir_body = db.monomorphized_mir_body(
293293
def,

src/tools/rust-analyzer/crates/ide-completion/src/completions/mod_.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ use ide_db::{
77
base_db::{SourceRootDatabase, VfsPath},
88
FxHashSet, RootDatabase, SymbolKind,
99
};
10-
use stdx::IsNoneOr;
1110
use syntax::{ast, AstNode, SyntaxKind, ToSmolStr};
1211

1312
use crate::{context::CompletionContext, CompletionItem, Completions};
@@ -66,7 +65,7 @@ pub(crate) fn complete_mod(
6665
.iter()
6766
.filter(|&submodule_candidate_file| submodule_candidate_file != module_definition_file)
6867
.filter(|&submodule_candidate_file| {
69-
IsNoneOr::is_none_or(module_declaration_file, |it| it != submodule_candidate_file)
68+
Option::is_none_or(module_declaration_file, |it| it != submodule_candidate_file)
7069
})
7170
.filter_map(|submodule_file| {
7271
let submodule_path = source_root.path_for_file(&submodule_file)?;

src/tools/rust-analyzer/crates/stdx/src/lib.rs

-16
Original file line numberDiff line numberDiff line change
@@ -304,22 +304,6 @@ pub fn slice_tails<T>(this: &[T]) -> impl Iterator<Item = &[T]> {
304304
(0..this.len()).map(|i| &this[i..])
305305
}
306306

307-
pub trait IsNoneOr {
308-
type Type;
309-
#[allow(clippy::wrong_self_convention)]
310-
fn is_none_or(self, s: impl FnOnce(Self::Type) -> bool) -> bool;
311-
}
312-
#[allow(unstable_name_collisions)]
313-
impl<T> IsNoneOr for Option<T> {
314-
type Type = T;
315-
fn is_none_or(self, f: impl FnOnce(T) -> bool) -> bool {
316-
match self {
317-
Some(v) => f(v),
318-
None => true,
319-
}
320-
}
321-
}
322-
323307
#[cfg(test)]
324308
mod tests {
325309
use super::*;

0 commit comments

Comments
 (0)