aboutsummaryrefslogtreecommitdiff
path: root/crates/hir
diff options
context:
space:
mode:
authorJonas Schievink <[email protected]>2021-05-06 22:23:50 +0100
committerJonas Schievink <[email protected]>2021-05-06 22:23:50 +0100
commit20ae41c1a12963e938cb3bd4c7c84007412d6fa6 (patch)
tree361153338ec7c32866a5477b3e7681d05a4b0b7c /crates/hir
parentc4f9cb9b53314b584f6451908ce40bbd65453116 (diff)
Reuse database in LowerCtx
Diffstat (limited to 'crates/hir')
-rw-r--r--crates/hir/src/semantics.rs2
-rw-r--r--crates/hir/src/source_analyzer.rs5
2 files changed, 3 insertions, 4 deletions
diff --git a/crates/hir/src/semantics.rs b/crates/hir/src/semantics.rs
index d53d81c07..62500602a 100644
--- a/crates/hir/src/semantics.rs
+++ b/crates/hir/src/semantics.rs
@@ -855,7 +855,7 @@ impl<'a> SemanticsScope<'a> {
855 /// necessary a heuristic, as it doesn't take hygiene into account. 855 /// necessary a heuristic, as it doesn't take hygiene into account.
856 pub fn speculative_resolve(&self, path: &ast::Path) -> Option<PathResolution> { 856 pub fn speculative_resolve(&self, path: &ast::Path) -> Option<PathResolution> {
857 let ctx = body::LowerCtx::new(self.db.upcast(), self.file_id); 857 let ctx = body::LowerCtx::new(self.db.upcast(), self.file_id);
858 let path = Path::from_src(self.db.upcast(), path.clone(), &ctx)?; 858 let path = Path::from_src(path.clone(), &ctx)?;
859 resolve_hir_path(self.db, &self.resolver, &path) 859 resolve_hir_path(self.db, &self.resolver, &path)
860 } 860 }
861} 861}
diff --git a/crates/hir/src/source_analyzer.rs b/crates/hir/src/source_analyzer.rs
index 186421cbd..b5c65808e 100644
--- a/crates/hir/src/source_analyzer.rs
+++ b/crates/hir/src/source_analyzer.rs
@@ -204,8 +204,7 @@ impl SourceAnalyzer {
204 macro_call: InFile<&ast::MacroCall>, 204 macro_call: InFile<&ast::MacroCall>,
205 ) -> Option<MacroDef> { 205 ) -> Option<MacroDef> {
206 let ctx = body::LowerCtx::new(db.upcast(), macro_call.file_id); 206 let ctx = body::LowerCtx::new(db.upcast(), macro_call.file_id);
207 let path = 207 let path = macro_call.value.path().and_then(|ast| Path::from_src(ast, &ctx))?;
208 macro_call.value.path().and_then(|ast| Path::from_src(db.upcast(), ast, &ctx))?;
209 self.resolver.resolve_path_as_macro(db.upcast(), path.mod_path()).map(|it| it.into()) 208 self.resolver.resolve_path_as_macro(db.upcast(), path.mod_path()).map(|it| it.into())
210 } 209 }
211 210
@@ -285,7 +284,7 @@ impl SourceAnalyzer {
285 // This must be a normal source file rather than macro file. 284 // This must be a normal source file rather than macro file.
286 let hygiene = Hygiene::new(db.upcast(), self.file_id); 285 let hygiene = Hygiene::new(db.upcast(), self.file_id);
287 let ctx = body::LowerCtx::with_hygiene(db.upcast(), &hygiene); 286 let ctx = body::LowerCtx::with_hygiene(db.upcast(), &hygiene);
288 let hir_path = Path::from_src(db.upcast(), path.clone(), &ctx)?; 287 let hir_path = Path::from_src(path.clone(), &ctx)?;
289 288
290 // Case where path is a qualifier of another path, e.g. foo::bar::Baz where we 289 // Case where path is a qualifier of another path, e.g. foo::bar::Baz where we
291 // trying to resolve foo::bar. 290 // trying to resolve foo::bar.