aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorNick Spain <[email protected]>2021-01-01 04:41:04 +0000
committerNick Spain <[email protected]>2021-01-02 10:53:52 +0000
commit71c9a884d1d9b27bf9da8ce7d328d74349db54a2 (patch)
tree3da4580708ecd1f1f5b0605658d223432ae049c4 /crates
parent68b4efd53601fd67fbba4a2aa25ac94ecff58e5e (diff)
Fix type error with .and_then
Diffstat (limited to 'crates')
-rw-r--r--crates/ide_db/src/search.rs29
1 files changed, 14 insertions, 15 deletions
diff --git a/crates/ide_db/src/search.rs b/crates/ide_db/src/search.rs
index c4aff3932..436c59d2c 100644
--- a/crates/ide_db/src/search.rs
+++ b/crates/ide_db/src/search.rs
@@ -120,20 +120,19 @@ impl Definition {
120 let file_id = module_src.file_id.original_file(db); 120 let file_id = module_src.file_id.original_file(db);
121 121
122 if let Definition::Local(var) = self { 122 if let Definition::Local(var) = self {
123 #[allow(deprecated)]
124 let range = match var.parent(db) { 123 let range = match var.parent(db) {
125 DefWithBody::Function(f) => { 124 DefWithBody::Function(f) => {
126 f.source(db).and_then(|src| src.value.syntax().text_range()) 125 f.source(db).and_then(|src| Some(src.value.syntax().text_range()))
127 } 126 }
128 DefWithBody::Const(c) => { 127 DefWithBody::Const(c) => {
129 c.source(db).and_then(|src| src.value.syntax().text_range()) 128 c.source(db).and_then(|src| Some(src.value.syntax().text_range()))
130 } 129 }
131 DefWithBody::Static(s) => { 130 DefWithBody::Static(s) => {
132 s.source(db).and_then(|src| src.value.syntax().text_range()) 131 s.source(db).and_then(|src| Some(src.value.syntax().text_range()))
133 } 132 }
134 }; 133 };
135 let mut res = FxHashMap::default(); 134 let mut res = FxHashMap::default();
136 res.insert(file_id, Some(range)); 135 res.insert(file_id, range);
137 return SearchScope::new(res); 136 return SearchScope::new(res);
138 } 137 }
139 138
@@ -141,37 +140,37 @@ impl Definition {
141 #[allow(deprecated)] 140 #[allow(deprecated)]
142 let range = match param.parent(db) { 141 let range = match param.parent(db) {
143 hir::GenericDef::Function(it) => { 142 hir::GenericDef::Function(it) => {
144 it.source(db).and_then(|src| src.value.syntax().text_range()) 143 it.source(db).and_then(|src| Some(src.value.syntax().text_range()))
145 } 144 }
146 hir::GenericDef::Adt(it) => match it { 145 hir::GenericDef::Adt(it) => match it {
147 hir::Adt::Struct(it) => { 146 hir::Adt::Struct(it) => {
148 it.source(db).and_then(|src| src.value.syntax().text_range()) 147 it.source(db).and_then(|src| Some(src.value.syntax().text_range()))
149 } 148 }
150 hir::Adt::Union(it) => { 149 hir::Adt::Union(it) => {
151 it.source(db).and_then(|src| src.value.syntax().text_range()) 150 it.source(db).and_then(|src| Some(src.value.syntax().text_range()))
152 } 151 }
153 hir::Adt::Enum(it) => { 152 hir::Adt::Enum(it) => {
154 it.source(db).and_then(|src| src.value.syntax().text_range()) 153 it.source(db).and_then(|src| Some(src.value.syntax().text_range()))
155 } 154 }
156 }, 155 },
157 hir::GenericDef::Trait(it) => { 156 hir::GenericDef::Trait(it) => {
158 it.source(db).and_then(|src| src.value.syntax().text_range()) 157 it.source(db).and_then(|src| Some(src.value.syntax().text_range()))
159 } 158 }
160 hir::GenericDef::TypeAlias(it) => { 159 hir::GenericDef::TypeAlias(it) => {
161 it.source(db).and_then(|src| src.value.syntax().text_range()) 160 it.source(db).and_then(|src| Some(src.value.syntax().text_range()))
162 } 161 }
163 hir::GenericDef::Impl(it) => { 162 hir::GenericDef::Impl(it) => {
164 it.source(db).and_then(|src| src.value.syntax().text_range()) 163 it.source(db).and_then(|src| Some(src.value.syntax().text_range()))
165 } 164 }
166 hir::GenericDef::Variant(it) => { 165 hir::GenericDef::Variant(it) => {
167 it.source(db).and_then(|src| src.value.syntax().text_range()) 166 it.source(db).and_then(|src| Some(src.value.syntax().text_range()))
168 } 167 }
169 hir::GenericDef::Const(it) => { 168 hir::GenericDef::Const(it) => {
170 it.source(db).and_then(|src| src.value.syntax().text_range()) 169 it.source(db).and_then(|src| Some(src.value.syntax().text_range()))
171 } 170 }
172 }; 171 };
173 let mut res = FxHashMap::default(); 172 let mut res = FxHashMap::default();
174 res.insert(file_id, Some(range)); 173 res.insert(file_id, range);
175 return SearchScope::new(res); 174 return SearchScope::new(res);
176 } 175 }
177 176