From 20ae41c1a12963e938cb3bd4c7c84007412d6fa6 Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Thu, 6 May 2021 23:23:50 +0200 Subject: Reuse database in LowerCtx --- crates/hir/src/semantics.rs | 2 +- crates/hir/src/source_analyzer.rs | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) (limited to 'crates/hir') 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> { /// necessary a heuristic, as it doesn't take hygiene into account. pub fn speculative_resolve(&self, path: &ast::Path) -> Option { let ctx = body::LowerCtx::new(self.db.upcast(), self.file_id); - let path = Path::from_src(self.db.upcast(), path.clone(), &ctx)?; + let path = Path::from_src(path.clone(), &ctx)?; resolve_hir_path(self.db, &self.resolver, &path) } } 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 { macro_call: InFile<&ast::MacroCall>, ) -> Option { let ctx = body::LowerCtx::new(db.upcast(), macro_call.file_id); - let path = - macro_call.value.path().and_then(|ast| Path::from_src(db.upcast(), ast, &ctx))?; + let path = macro_call.value.path().and_then(|ast| Path::from_src(ast, &ctx))?; self.resolver.resolve_path_as_macro(db.upcast(), path.mod_path()).map(|it| it.into()) } @@ -285,7 +284,7 @@ impl SourceAnalyzer { // This must be a normal source file rather than macro file. let hygiene = Hygiene::new(db.upcast(), self.file_id); let ctx = body::LowerCtx::with_hygiene(db.upcast(), &hygiene); - let hir_path = Path::from_src(db.upcast(), path.clone(), &ctx)?; + let hir_path = Path::from_src(path.clone(), &ctx)?; // Case where path is a qualifier of another path, e.g. foo::bar::Baz where we // trying to resolve foo::bar. -- cgit v1.2.3