mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 21:05:02 +00:00
internal: Add a CrateRootModuleId that encodes a module id that is always a crate root
This commit is contained in:
parent
6b3659d38f
commit
cf178cba8f
9 changed files with 102 additions and 65 deletions
|
@ -20,7 +20,7 @@ use syntax::{ast, AstNode, AstPtr, SyntaxNode, SyntaxNodePtr};
|
|||
/// `AstId` points to an AST node in a specific file.
|
||||
pub struct FileAstId<N: AstNode> {
|
||||
raw: ErasedFileAstId,
|
||||
_ty: PhantomData<fn() -> N>,
|
||||
covariant: PhantomData<fn() -> N>,
|
||||
}
|
||||
|
||||
impl<N: AstNode> Clone for FileAstId<N> {
|
||||
|
@ -54,7 +54,7 @@ impl<N: AstNode> FileAstId<N> {
|
|||
where
|
||||
N: Into<M>,
|
||||
{
|
||||
FileAstId { raw: self.raw, _ty: PhantomData }
|
||||
FileAstId { raw: self.raw, covariant: PhantomData }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -122,7 +122,7 @@ impl AstIdMap {
|
|||
|
||||
pub fn ast_id<N: AstNode>(&self, item: &N) -> FileAstId<N> {
|
||||
let raw = self.erased_ast_id(item.syntax());
|
||||
FileAstId { raw, _ty: PhantomData }
|
||||
FileAstId { raw, covariant: PhantomData }
|
||||
}
|
||||
|
||||
pub fn get<N: AstNode>(&self, id: FileAstId<N>) -> AstPtr<N> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue