Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/hir-expand/src/files.rs')
| -rw-r--r-- | crates/hir-expand/src/files.rs | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/crates/hir-expand/src/files.rs b/crates/hir-expand/src/files.rs index e8f6b82434..a73a22370d 100644 --- a/crates/hir-expand/src/files.rs +++ b/crates/hir-expand/src/files.rs @@ -2,7 +2,7 @@ use std::borrow::Borrow; use either::Either; -use span::{ErasedFileAstId, FileAstId, FileId, SyntaxContext}; +use span::{AstIdNode, ErasedFileAstId, FileAstId, FileId, SyntaxContext}; use syntax::{AstNode, AstPtr, SyntaxNode, SyntaxNodePtr, SyntaxToken, TextRange, TextSize}; use crate::{ @@ -122,6 +122,13 @@ impl<N: AstNode> AstId<N> { pub fn erase(&self) -> ErasedAstId { crate::InFile::new(self.file_id, self.value.erase()) } + #[inline] + pub fn upcast<M: AstIdNode>(self) -> AstId<M> + where + N: Into<M>, + { + self.map(|it| it.upcast()) + } } pub type ErasedAstId = crate::InFile<ErasedFileAstId>; |