aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_def/src/path.rs
diff options
context:
space:
mode:
authorJonas Schievink <[email protected]>2021-05-06 18:59:54 +0100
committerJonas Schievink <[email protected]>2021-05-06 18:59:54 +0100
commit976a3226fe0f145dfefd473e9fecd63d58aca50e (patch)
tree59dd6c2e4cc81c3f9285d47e5a44e370110818c7 /crates/hir_def/src/path.rs
parentb37b709459a4ff881a91965ebf0c39e3a449c304 (diff)
Don't store call-site text offsets in hygiene info
Diffstat (limited to 'crates/hir_def/src/path.rs')
-rw-r--r--crates/hir_def/src/path.rs15
1 files changed, 8 insertions, 7 deletions
diff --git a/crates/hir_def/src/path.rs b/crates/hir_def/src/path.rs
index 509f77850..64bff318e 100644
--- a/crates/hir_def/src/path.rs
+++ b/crates/hir_def/src/path.rs
@@ -7,7 +7,7 @@ use std::{
7 sync::Arc, 7 sync::Arc,
8}; 8};
9 9
10use crate::{body::LowerCtx, intern::Interned, type_ref::LifetimeRef}; 10use crate::{body::LowerCtx, db::DefDatabase, intern::Interned, type_ref::LifetimeRef};
11use base_db::CrateId; 11use base_db::CrateId;
12use hir_expand::{ 12use hir_expand::{
13 hygiene::Hygiene, 13 hygiene::Hygiene,
@@ -47,9 +47,9 @@ pub enum ImportAlias {
47} 47}
48 48
49impl ModPath { 49impl ModPath {
50 pub fn from_src(path: ast::Path, hygiene: &Hygiene) -> Option<ModPath> { 50 pub fn from_src(db: &dyn DefDatabase, path: ast::Path, hygiene: &Hygiene) -> Option<ModPath> {
51 let ctx = LowerCtx::with_hygiene(hygiene); 51 let ctx = LowerCtx::with_hygiene(db, hygiene);
52 lower::lower_path(path, &ctx).map(|it| (*it.mod_path).clone()) 52 lower::lower_path(db, path, &ctx).map(|it| (*it.mod_path).clone())
53 } 53 }
54 54
55 pub fn from_segments(kind: PathKind, segments: impl IntoIterator<Item = Name>) -> ModPath { 55 pub fn from_segments(kind: PathKind, segments: impl IntoIterator<Item = Name>) -> ModPath {
@@ -64,12 +64,13 @@ impl ModPath {
64 64
65 /// Calls `cb` with all paths, represented by this use item. 65 /// Calls `cb` with all paths, represented by this use item.
66 pub(crate) fn expand_use_item( 66 pub(crate) fn expand_use_item(
67 db: &dyn DefDatabase,
67 item_src: InFile<ast::Use>, 68 item_src: InFile<ast::Use>,
68 hygiene: &Hygiene, 69 hygiene: &Hygiene,
69 mut cb: impl FnMut(ModPath, &ast::UseTree, /* is_glob */ bool, Option<ImportAlias>), 70 mut cb: impl FnMut(ModPath, &ast::UseTree, /* is_glob */ bool, Option<ImportAlias>),
70 ) { 71 ) {
71 if let Some(tree) = item_src.value.use_tree() { 72 if let Some(tree) = item_src.value.use_tree() {
72 lower::lower_use_tree(None, tree, hygiene, &mut cb); 73 lower::lower_use_tree(db, None, tree, hygiene, &mut cb);
73 } 74 }
74 } 75 }
75 76
@@ -168,8 +169,8 @@ pub enum GenericArg {
168impl Path { 169impl Path {
169 /// Converts an `ast::Path` to `Path`. Works with use trees. 170 /// Converts an `ast::Path` to `Path`. Works with use trees.
170 /// It correctly handles `$crate` based path from macro call. 171 /// It correctly handles `$crate` based path from macro call.
171 pub fn from_src(path: ast::Path, ctx: &LowerCtx) -> Option<Path> { 172 pub fn from_src(db: &dyn DefDatabase, path: ast::Path, ctx: &LowerCtx) -> Option<Path> {
172 lower::lower_path(path, ctx) 173 lower::lower_path(db, path, ctx)
173 } 174 }
174 175
175 /// Converts a known mod path to `Path`. 176 /// Converts a known mod path to `Path`.