Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/hir-def/src/item_tree.rs')
-rw-r--r--crates/hir-def/src/item_tree.rs42
1 files changed, 4 insertions, 38 deletions
diff --git a/crates/hir-def/src/item_tree.rs b/crates/hir-def/src/item_tree.rs
index 1b97eb72b6..65dc35337a 100644
--- a/crates/hir-def/src/item_tree.rs
+++ b/crates/hir-def/src/item_tree.rs
@@ -46,7 +46,7 @@ use std::{
use ast::{AstNode, StructKind};
use base_db::Crate;
use hir_expand::{
- ExpandTo, HirFileId, InFile,
+ ExpandTo, HirFileId,
attrs::RawAttrs,
mod_path::{ModPath, PathKind},
name::Name,
@@ -62,6 +62,8 @@ use triomphe::Arc;
use crate::{BlockId, Lookup, attr::Attrs, db::DefDatabase};
+pub(crate) use crate::item_tree::lower::{lower_use_tree, visibility_from_ast};
+
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct RawVisibilityId(u32);
@@ -446,6 +448,7 @@ impl TreeId {
}
}
+ #[inline]
pub fn file_id(self) -> HirFileId {
self.file
}
@@ -878,43 +881,6 @@ pub struct Macro2 {
pub ast_id: FileAstId<ast::MacroDef>,
}
-impl Use {
- /// Maps a `UseTree` contained in this import back to its AST node.
- pub fn use_tree_to_ast(
- &self,
- db: &dyn DefDatabase,
- file_id: HirFileId,
- index: Idx<ast::UseTree>,
- ) -> ast::UseTree {
- // Re-lower the AST item and get the source map.
- // Note: The AST unwraps are fine, since if they fail we should have never obtained `index`.
- let ast = InFile::new(file_id, self.ast_id).to_node(db);
- let ast_use_tree = ast.use_tree().expect("missing `use_tree`");
- let (_, source_map) = lower::lower_use_tree(db, ast_use_tree, &mut |range| {
- db.span_map(file_id).span_for_range(range).ctx
- })
- .expect("failed to lower use tree");
- source_map[index].clone()
- }
-
- /// Maps a `UseTree` contained in this import back to its AST node.
- pub fn use_tree_source_map(
- &self,
- db: &dyn DefDatabase,
- file_id: HirFileId,
- ) -> Arena<ast::UseTree> {
- // Re-lower the AST item and get the source map.
- // Note: The AST unwraps are fine, since if they fail we should have never obtained `index`.
- let ast = InFile::new(file_id, self.ast_id).to_node(db);
- let ast_use_tree = ast.use_tree().expect("missing `use_tree`");
- lower::lower_use_tree(db, ast_use_tree, &mut |range| {
- db.span_map(file_id).span_for_range(range).ctx
- })
- .expect("failed to lower use tree")
- .1
- }
-}
-
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum ImportKind {
/// The `ModPath` is imported normally.