From ff5f90d8ae2da8e4856d5c78f55e5cd02b178325 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Wed, 17 Mar 2021 02:34:46 +0100 Subject: use simpler .map(|x| y) instead of .and_then(|x| Some(y)) for Options. (clippy::bind_instead_of_map) --- crates/ide_db/src/search.rs | 34 ++++++++++++---------------------- 1 file changed, 12 insertions(+), 22 deletions(-) (limited to 'crates/ide_db/src') diff --git a/crates/ide_db/src/search.rs b/crates/ide_db/src/search.rs index f56221a6c..324817cd0 100644 --- a/crates/ide_db/src/search.rs +++ b/crates/ide_db/src/search.rs @@ -161,15 +161,9 @@ impl Definition { if let Definition::Local(var) = self { let range = match var.parent(db) { - DefWithBody::Function(f) => { - f.source(db).and_then(|src| Some(src.value.syntax().text_range())) - } - DefWithBody::Const(c) => { - c.source(db).and_then(|src| Some(src.value.syntax().text_range())) - } - DefWithBody::Static(s) => { - s.source(db).and_then(|src| Some(src.value.syntax().text_range())) - } + DefWithBody::Function(f) => f.source(db).map(|src| src.value.syntax().text_range()), + DefWithBody::Const(c) => c.source(db).map(|src| src.value.syntax().text_range()), + DefWithBody::Static(s) => s.source(db).map(|src| src.value.syntax().text_range()), }; let mut res = FxHashMap::default(); res.insert(file_id, range); @@ -179,33 +173,29 @@ impl Definition { if let Definition::GenericParam(hir::GenericParam::LifetimeParam(param)) = self { let range = match param.parent(db) { hir::GenericDef::Function(it) => { - it.source(db).and_then(|src| Some(src.value.syntax().text_range())) + it.source(db).map(|src| src.value.syntax().text_range()) } hir::GenericDef::Adt(it) => match it { hir::Adt::Struct(it) => { - it.source(db).and_then(|src| Some(src.value.syntax().text_range())) - } - hir::Adt::Union(it) => { - it.source(db).and_then(|src| Some(src.value.syntax().text_range())) - } - hir::Adt::Enum(it) => { - it.source(db).and_then(|src| Some(src.value.syntax().text_range())) + it.source(db).map(|src| src.value.syntax().text_range()) } + hir::Adt::Union(it) => it.source(db).map(|src| src.value.syntax().text_range()), + hir::Adt::Enum(it) => it.source(db).map(|src| src.value.syntax().text_range()), }, hir::GenericDef::Trait(it) => { - it.source(db).and_then(|src| Some(src.value.syntax().text_range())) + it.source(db).map(|src| src.value.syntax().text_range()) } hir::GenericDef::TypeAlias(it) => { - it.source(db).and_then(|src| Some(src.value.syntax().text_range())) + it.source(db).map(|src| src.value.syntax().text_range()) } hir::GenericDef::Impl(it) => { - it.source(db).and_then(|src| Some(src.value.syntax().text_range())) + it.source(db).map(|src| src.value.syntax().text_range()) } hir::GenericDef::Variant(it) => { - it.source(db).and_then(|src| Some(src.value.syntax().text_range())) + it.source(db).map(|src| src.value.syntax().text_range()) } hir::GenericDef::Const(it) => { - it.source(db).and_then(|src| Some(src.value.syntax().text_range())) + it.source(db).map(|src| src.value.syntax().text_range()) } }; let mut res = FxHashMap::default(); -- cgit v1.2.3