633: use ToOwned trait instead of inherent method r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
This commit is contained in:
bors[bot] 2019-01-24 23:10:09 +00:00
commit 1d4b421aad
4 changed files with 523 additions and 8 deletions

View file

@ -15,12 +15,13 @@ use crate::{
/// conversion itself has zero runtime cost: ast and syntax nodes have exactly
/// the same representation: a pointer to the tree root and a pointer to the
/// node itself.
pub trait AstNode: rowan::TransparentNewType<Repr = rowan::SyntaxNode<RaTypes>> {
pub trait AstNode:
rowan::TransparentNewType<Repr = rowan::SyntaxNode<RaTypes>> + ToOwned<Owned = TreeArc<Self>>
{
fn cast(syntax: &SyntaxNode) -> Option<&Self>
where
Self: Sized;
fn syntax(&self) -> &SyntaxNode;
fn to_owned(&self) -> TreeArc<Self>;
}
pub trait AstToken: AstNode {