Skip to content

Commit 5346e84

Browse files
authored
Merge pull request rust-lang#18256 from MoskalykA/use-is_none_or
Start using `Option::is_none_or`
2 parents 7ec2042 + 56b0299 commit 5346e84

File tree

4 files changed

+4
-21
lines changed

4 files changed

+4
-21
lines changed

src/tools/rust-analyzer/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ exclude = ["crates/proc-macro-srv/proc-macro-test/imp"]
44
resolver = "2"
55

66
[workspace.package]
7-
rust-version = "1.81"
7+
rust-version = "1.82"
88
edition = "2021"
99
license = "MIT OR Apache-2.0"
1010
authors = ["rust-analyzer team"]

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 = repr.and_then(|repr| repr.int).is_none_or(|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+
module_declaration_file.is_none_or(|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)