internal: Add a CrateRootModuleId that encodes a module id that is always a crate root

This commit is contained in:
Lukas Wirth 2023-06-13 12:59:52 +02:00
parent 6b3659d38f
commit cf178cba8f
9 changed files with 102 additions and 65 deletions

View file

@ -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> {