Skip to content

Commit

Permalink
Remove IsNoneOr from RA's stdx
Browse files Browse the repository at this point in the history
  • Loading branch information
slanterns committed Aug 14, 2024
1 parent e2ec115 commit 2540401
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 20 deletions.
3 changes: 1 addition & 2 deletions src/tools/rust-analyzer/crates/hir-ty/src/display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ use rustc_apfloat::{
Float,
};
use smallvec::SmallVec;
use stdx::{never, IsNoneOr};
use stdx::never;
use triomphe::Arc;

use crate::{
Expand Down Expand Up @@ -1461,7 +1461,6 @@ fn generic_args_sans_defaults<'ga>(
}
// otherwise, if the arg is equal to the param default, hide it (unless the
// default is an error which can happen for the trait Self type)
#[allow(unstable_name_collisions)]
default_parameters.get(i).is_none_or(|default_parameter| {
// !is_err(default_parameter.skip_binders())
// &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ use ide_db::{
base_db::{SourceDatabaseExt, VfsPath},
FxHashSet, RootDatabase, SymbolKind,
};
use stdx::IsNoneOr;
use syntax::{ast, AstNode, SyntaxKind, ToSmolStr};

use crate::{context::CompletionContext, CompletionItem, Completions};
Expand Down Expand Up @@ -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)?;
Expand Down
16 changes: 0 additions & 16 deletions src/tools/rust-analyzer/crates/stdx/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*;
Expand Down

0 comments on commit 2540401

Please sign in to comment.