From 4b03b39d5b4b00daffb120a4d2d9ea4a55a9a7ac Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Mon, 22 Jun 2020 15:07:06 +0200 Subject: draw the rest of the owl --- crates/ra_hir_expand/src/ast_id_map.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'crates/ra_hir_expand/src/ast_id_map.rs') diff --git a/crates/ra_hir_expand/src/ast_id_map.rs b/crates/ra_hir_expand/src/ast_id_map.rs index d19569245..f4d31526a 100644 --- a/crates/ra_hir_expand/src/ast_id_map.rs +++ b/crates/ra_hir_expand/src/ast_id_map.rs @@ -6,6 +6,8 @@ //! changes. use std::{ + any::type_name, + fmt, hash::{Hash, Hasher}, marker::PhantomData, }; @@ -14,7 +16,6 @@ use ra_arena::{Arena, Idx}; use ra_syntax::{ast, AstNode, AstPtr, SyntaxNode, SyntaxNodePtr}; /// `AstId` points to an AST node in a specific file. -#[derive(Debug)] pub struct FileAstId { raw: ErasedFileAstId, _ty: PhantomData N>, @@ -39,11 +40,17 @@ impl Hash for FileAstId { } } +impl fmt::Debug for FileAstId { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "FileAstId::<{}>({})", type_name::(), self.raw.into_raw()) + } +} + impl FileAstId { // Can't make this a From implementation because of coherence pub fn upcast(self) -> FileAstId where - M: From, + N: Into, { FileAstId { raw: self.raw, _ty: PhantomData } } @@ -89,7 +96,7 @@ impl AstIdMap { } } - pub(crate) fn get(&self, id: FileAstId) -> AstPtr { + pub fn get(&self, id: FileAstId) -> AstPtr { self.arena[id.raw].clone().cast::().unwrap() } -- cgit v1.2.3