diff options
Diffstat (limited to 'crates/ra_hir_def/src/nameres.rs')
-rw-r--r-- | crates/ra_hir_def/src/nameres.rs | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/crates/ra_hir_def/src/nameres.rs b/crates/ra_hir_def/src/nameres.rs index 03515309e..be53313ee 100644 --- a/crates/ra_hir_def/src/nameres.rs +++ b/crates/ra_hir_def/src/nameres.rs | |||
@@ -151,16 +151,17 @@ impl ModuleOrigin { | |||
151 | 151 | ||
152 | /// Returns a node which defines this module. | 152 | /// Returns a node which defines this module. |
153 | /// That is, a file or a `mod foo {}` with items. | 153 | /// That is, a file or a `mod foo {}` with items. |
154 | fn definition_source(&self, db: &impl DefDatabase) -> InFile<ModuleSource> { | 154 | fn definition_source(&self, db: &dyn DefDatabase) -> InFile<ModuleSource> { |
155 | match self { | 155 | match self { |
156 | ModuleOrigin::File { definition, .. } | ModuleOrigin::CrateRoot { definition } => { | 156 | ModuleOrigin::File { definition, .. } | ModuleOrigin::CrateRoot { definition } => { |
157 | let file_id = *definition; | 157 | let file_id = *definition; |
158 | let sf = db.parse(file_id).tree(); | 158 | let sf = db.parse(file_id).tree(); |
159 | InFile::new(file_id.into(), ModuleSource::SourceFile(sf)) | 159 | InFile::new(file_id.into(), ModuleSource::SourceFile(sf)) |
160 | } | 160 | } |
161 | ModuleOrigin::Inline { definition } => { | 161 | ModuleOrigin::Inline { definition } => InFile::new( |
162 | InFile::new(definition.file_id, ModuleSource::Module(definition.to_node(db))) | 162 | definition.file_id, |
163 | } | 163 | ModuleSource::Module(definition.to_node(db.upcast())), |
164 | ), | ||
164 | } | 165 | } |
165 | } | 166 | } |
166 | } | 167 | } |
@@ -176,7 +177,7 @@ pub struct ModuleData { | |||
176 | } | 177 | } |
177 | 178 | ||
178 | impl CrateDefMap { | 179 | impl CrateDefMap { |
179 | pub(crate) fn crate_def_map_query(db: &impl DefDatabase, krate: CrateId) -> Arc<CrateDefMap> { | 180 | pub(crate) fn crate_def_map_query(db: &dyn DefDatabase, krate: CrateId) -> Arc<CrateDefMap> { |
180 | let _p = profile("crate_def_map_query").detail(|| { | 181 | let _p = profile("crate_def_map_query").detail(|| { |
181 | db.crate_graph()[krate] | 182 | db.crate_graph()[krate] |
182 | .display_name | 183 | .display_name |
@@ -204,7 +205,7 @@ impl CrateDefMap { | |||
204 | 205 | ||
205 | pub fn add_diagnostics( | 206 | pub fn add_diagnostics( |
206 | &self, | 207 | &self, |
207 | db: &impl DefDatabase, | 208 | db: &dyn DefDatabase, |
208 | module: LocalModuleId, | 209 | module: LocalModuleId, |
209 | sink: &mut DiagnosticSink, | 210 | sink: &mut DiagnosticSink, |
210 | ) { | 211 | ) { |
@@ -220,7 +221,7 @@ impl CrateDefMap { | |||
220 | 221 | ||
221 | pub(crate) fn resolve_path( | 222 | pub(crate) fn resolve_path( |
222 | &self, | 223 | &self, |
223 | db: &impl DefDatabase, | 224 | db: &dyn DefDatabase, |
224 | original_module: LocalModuleId, | 225 | original_module: LocalModuleId, |
225 | path: &ModPath, | 226 | path: &ModPath, |
226 | shadow: BuiltinShadowMode, | 227 | shadow: BuiltinShadowMode, |
@@ -273,15 +274,15 @@ impl CrateDefMap { | |||
273 | 274 | ||
274 | impl ModuleData { | 275 | impl ModuleData { |
275 | /// Returns a node which defines this module. That is, a file or a `mod foo {}` with items. | 276 | /// Returns a node which defines this module. That is, a file or a `mod foo {}` with items. |
276 | pub fn definition_source(&self, db: &impl DefDatabase) -> InFile<ModuleSource> { | 277 | pub fn definition_source(&self, db: &dyn DefDatabase) -> InFile<ModuleSource> { |
277 | self.origin.definition_source(db) | 278 | self.origin.definition_source(db) |
278 | } | 279 | } |
279 | 280 | ||
280 | /// Returns a node which declares this module, either a `mod foo;` or a `mod foo {}`. | 281 | /// Returns a node which declares this module, either a `mod foo;` or a `mod foo {}`. |
281 | /// `None` for the crate root or block. | 282 | /// `None` for the crate root or block. |
282 | pub fn declaration_source(&self, db: &impl DefDatabase) -> Option<InFile<ast::Module>> { | 283 | pub fn declaration_source(&self, db: &dyn DefDatabase) -> Option<InFile<ast::Module>> { |
283 | let decl = self.origin.declaration()?; | 284 | let decl = self.origin.declaration()?; |
284 | let value = decl.to_node(db); | 285 | let value = decl.to_node(db.upcast()); |
285 | Some(InFile { file_id: decl.file_id, value }) | 286 | Some(InFile { file_id: decl.file_id, value }) |
286 | } | 287 | } |
287 | } | 288 | } |
@@ -311,7 +312,7 @@ mod diagnostics { | |||
311 | impl DefDiagnostic { | 312 | impl DefDiagnostic { |
312 | pub(super) fn add_to( | 313 | pub(super) fn add_to( |
313 | &self, | 314 | &self, |
314 | db: &impl DefDatabase, | 315 | db: &dyn DefDatabase, |
315 | target_module: LocalModuleId, | 316 | target_module: LocalModuleId, |
316 | sink: &mut DiagnosticSink, | 317 | sink: &mut DiagnosticSink, |
317 | ) { | 318 | ) { |
@@ -320,7 +321,7 @@ mod diagnostics { | |||
320 | if *module != target_module { | 321 | if *module != target_module { |
321 | return; | 322 | return; |
322 | } | 323 | } |
323 | let decl = declaration.to_node(db); | 324 | let decl = declaration.to_node(db.upcast()); |
324 | sink.push(UnresolvedModule { | 325 | sink.push(UnresolvedModule { |
325 | file: declaration.file_id, | 326 | file: declaration.file_id, |
326 | decl: AstPtr::new(&decl), | 327 | decl: AstPtr::new(&decl), |