From 976a3226fe0f145dfefd473e9fecd63d58aca50e Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Thu, 6 May 2021 19:59:54 +0200 Subject: Don't store call-site text offsets in hygiene info --- crates/hir/src/attrs.rs | 2 +- crates/hir/src/lib.rs | 2 +- crates/hir/src/semantics.rs | 2 +- crates/hir/src/source_analyzer.rs | 7 ++++--- 4 files changed, 7 insertions(+), 6 deletions(-) (limited to 'crates/hir') diff --git a/crates/hir/src/attrs.rs b/crates/hir/src/attrs.rs index 4a11622fc..e8fa3c56e 100644 --- a/crates/hir/src/attrs.rs +++ b/crates/hir/src/attrs.rs @@ -112,7 +112,7 @@ fn resolve_doc_path( AttrDefId::MacroDefId(_) => return None, }; let path = ast::Path::parse(link).ok()?; - let modpath = ModPath::from_src(path, &Hygiene::new_unhygienic()).unwrap(); + let modpath = ModPath::from_src(db.upcast(), path, &Hygiene::new_unhygienic()).unwrap(); let resolved = resolver.resolve_module_path_in_items(db.upcast(), &modpath); if resolved == PerNs::none() { if let Some(trait_id) = resolver.resolve_module_path_in_trait_items(db.upcast(), &modpath) { diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs index 6fcc58f61..f876339de 100644 --- a/crates/hir/src/lib.rs +++ b/crates/hir/src/lib.rs @@ -1666,7 +1666,7 @@ impl Impl { .value .attrs() .filter_map(|it| { - let path = ModPath::from_src(it.path()?, &hygenic)?; + let path = ModPath::from_src(db.upcast(), it.path()?, &hygenic)?; if path.as_ident()?.to_string() == "derive" { Some(it) } else { diff --git a/crates/hir/src/semantics.rs b/crates/hir/src/semantics.rs index 62500602a..d53d81c07 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(path.clone(), &ctx)?; + let path = Path::from_src(self.db.upcast(), 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 0895bd6f1..186421cbd 100644 --- a/crates/hir/src/source_analyzer.rs +++ b/crates/hir/src/source_analyzer.rs @@ -204,7 +204,8 @@ 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(ast, &ctx))?; + let path = + macro_call.value.path().and_then(|ast| Path::from_src(db.upcast(), ast, &ctx))?; self.resolver.resolve_path_as_macro(db.upcast(), path.mod_path()).map(|it| it.into()) } @@ -283,8 +284,8 @@ 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(&hygiene); - let hir_path = Path::from_src(path.clone(), &ctx)?; + let ctx = body::LowerCtx::with_hygiene(db.upcast(), &hygiene); + let hir_path = Path::from_src(db.upcast(), 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 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