1123: migrate to untyped rowan r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
This commit is contained in:
bors[bot] 2019-04-09 07:29:06 +00:00
commit 5f700179fc
10 changed files with 192 additions and 158 deletions

6
Cargo.lock generated
View file

@ -1088,7 +1088,7 @@ dependencies = [
"parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
"ra_parser 0.1.0", "ra_parser 0.1.0",
"ra_text_edit 0.1.0", "ra_text_edit 0.1.0",
"rowan 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "rowan 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
"smol_str 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "smol_str 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
"test_utils 0.1.0", "test_utils 0.1.0",
"text_unit 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "text_unit 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
@ -1309,7 +1309,7 @@ dependencies = [
[[package]] [[package]]
name = "rowan" name = "rowan"
version = "0.4.0" version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"colosseum 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "colosseum 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
@ -1975,7 +1975,7 @@ dependencies = [
"checksum relative-path 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0e7790c7f1cc73d831d28dc5a7deb316a006e7848e6a7f467cdb10a0a9e0fb1c" "checksum relative-path 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0e7790c7f1cc73d831d28dc5a7deb316a006e7848e6a7f467cdb10a0a9e0fb1c"
"checksum remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3488ba1b9a2084d38645c4c08276a1752dcbf2c7130d74f1569681ad5d2799c5" "checksum remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3488ba1b9a2084d38645c4c08276a1752dcbf2c7130d74f1569681ad5d2799c5"
"checksum ron 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "17f52a24414403f81528b67488cf8edc4eda977d3af1646bb6b106a600ead78f" "checksum ron 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "17f52a24414403f81528b67488cf8edc4eda977d3af1646bb6b106a600ead78f"
"checksum rowan 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "397cd19c109641f10f3c66433440285e232d8cbd37406cf8f944a15ab1e63a8e" "checksum rowan 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "91237e0f16ac1073139acd696d9d386c3225ba1d6eafc09b105984905994068d"
"checksum rustc-demangle 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "adacaae16d02b6ec37fdc7acfcddf365978de76d1983d3ee22afc260e1ca9619" "checksum rustc-demangle 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "adacaae16d02b6ec37fdc7acfcddf365978de76d1983d3ee22afc260e1ca9619"
"checksum rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7540fc8b0c49f096ee9c961cda096467dce8084bec6bdca2fc83895fd9b28cb8" "checksum rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7540fc8b0c49f096ee9c961cda096467dce8084bec6bdca2fc83895fd9b28cb8"
"checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a"

View file

@ -7,6 +7,7 @@ use super::SyntaxInfo;
/// The kind of syntax node, e.g. `IDENT`, `USE_KW`, or `STRUCT_DEF`. /// The kind of syntax node, e.g. `IDENT`, `USE_KW`, or `STRUCT_DEF`.
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[repr(u16)]
pub enum SyntaxKind { pub enum SyntaxKind {
// Technical SyntaxKinds: they appear temporally during parsing, // Technical SyntaxKinds: they appear temporally during parsing,
// but never end up in the final tree // but never end up in the final tree
@ -230,9 +231,25 @@ pub enum SyntaxKind {
ARG_LIST, ARG_LIST,
TYPE_BOUND, TYPE_BOUND,
TYPE_BOUND_LIST, TYPE_BOUND_LIST,
// Technical kind so that we can cast from u16 safely
#[doc(hidden)]
__LAST,
} }
use self::SyntaxKind::*; use self::SyntaxKind::*;
impl From<u16> for SyntaxKind {
fn from(d: u16) -> SyntaxKind {
assert!(d <= (__LAST as u16));
unsafe { std::mem::transmute::<u16, SyntaxKind>(d) }
}
}
impl From<SyntaxKind> for u16 {
fn from(k: SyntaxKind) -> u16 {
k as u16
}
}
impl SyntaxKind { impl SyntaxKind {
pub fn is_keyword(self) -> bool { pub fn is_keyword(self) -> bool {
match self { match self {
@ -573,6 +590,7 @@ impl SyntaxKind {
TYPE_BOUND_LIST => &SyntaxInfo { name: "TYPE_BOUND_LIST" }, TYPE_BOUND_LIST => &SyntaxInfo { name: "TYPE_BOUND_LIST" },
TOMBSTONE => &SyntaxInfo { name: "TOMBSTONE" }, TOMBSTONE => &SyntaxInfo { name: "TOMBSTONE" },
EOF => &SyntaxInfo { name: "EOF" }, EOF => &SyntaxInfo { name: "EOF" },
__LAST => &SyntaxInfo { name: "__LAST" },
} }
} }
pub fn from_keyword(ident: &str) -> Option<SyntaxKind> { pub fn from_keyword(ident: &str) -> Option<SyntaxKind> {

View file

@ -9,6 +9,7 @@ use super::SyntaxInfo;
/// The kind of syntax node, e.g. `IDENT`, `USE_KW`, or `STRUCT_DEF`. /// The kind of syntax node, e.g. `IDENT`, `USE_KW`, or `STRUCT_DEF`.
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[repr(u16)]
pub enum SyntaxKind { pub enum SyntaxKind {
// Technical SyntaxKinds: they appear temporally during parsing, // Technical SyntaxKinds: they appear temporally during parsing,
// but never end up in the final tree // but never end up in the final tree
@ -26,9 +27,25 @@ pub enum SyntaxKind {
{% for t in concat(a=literals, b=tokens, c=nodes) %} {% for t in concat(a=literals, b=tokens, c=nodes) %}
{{t}}, {{t}},
{%- endfor %} {%- endfor %}
// Technical kind so that we can cast from u16 safely
#[doc(hidden)]
__LAST,
} }
use self::SyntaxKind::*; use self::SyntaxKind::*;
impl From<u16> for SyntaxKind {
fn from(d: u16) -> SyntaxKind {
assert!(d <= (__LAST as u16));
unsafe { std::mem::transmute::<u16, SyntaxKind>(d) }
}
}
impl From<SyntaxKind> for u16 {
fn from(k: SyntaxKind) -> u16 {
k as u16
}
}
impl SyntaxKind { impl SyntaxKind {
pub fn is_keyword(self) -> bool { pub fn is_keyword(self) -> bool {
match self { match self {
@ -72,6 +89,7 @@ impl SyntaxKind {
{%- endfor %} {%- endfor %}
TOMBSTONE => &SyntaxInfo { name: "TOMBSTONE" }, TOMBSTONE => &SyntaxInfo { name: "TOMBSTONE" },
EOF => &SyntaxInfo { name: "EOF" }, EOF => &SyntaxInfo { name: "EOF" },
__LAST => &SyntaxInfo { name: "__LAST" },
} }
} }
pub fn from_keyword(ident: &str) -> Option<SyntaxKind> { pub fn from_keyword(ident: &str) -> Option<SyntaxKind> {

View file

@ -13,7 +13,7 @@ unicode-xid = "0.1.0"
itertools = "0.8.0" itertools = "0.8.0"
drop_bomb = "0.1.4" drop_bomb = "0.1.4"
parking_lot = "0.7.0" parking_lot = "0.7.0"
rowan = "0.4.0" rowan = "0.5.0"
# ideally, `serde` should be enabled by `ra_lsp_server`, but we enable it here # ideally, `serde` should be enabled by `ra_lsp_server`, but we enable it here
# to reduce number of compilations # to reduce number of compilations

View file

@ -9,7 +9,7 @@ mod expr_extensions;
use std::marker::PhantomData; use std::marker::PhantomData;
use crate::{ use crate::{
syntax_node::{SyntaxNode, SyntaxNodeChildren, TreeArc, RaTypes, SyntaxToken}, syntax_node::{SyntaxNode, SyntaxNodeChildren, TreeArc, SyntaxToken},
SmolStr, SmolStr,
}; };
@ -26,7 +26,7 @@ pub use self::{
/// the same representation: a pointer to the tree root and a pointer to the /// the same representation: a pointer to the tree root and a pointer to the
/// node itself. /// node itself.
pub trait AstNode: pub trait AstNode:
rowan::TransparentNewType<Repr = rowan::SyntaxNode<RaTypes>> + ToOwned<Owned = TreeArc<Self>> rowan::TransparentNewType<Repr = rowan::SyntaxNode> + ToOwned<Owned = TreeArc<Self>>
{ {
fn cast(syntax: &SyntaxNode) -> Option<&Self> fn cast(syntax: &SyntaxNode) -> Option<&Self>
where where

View file

@ -13,7 +13,7 @@ use rowan::TransparentNewType;
use crate::{ use crate::{
SyntaxNode, SyntaxKind::*, SyntaxNode, SyntaxKind::*,
syntax_node::{RaTypes, TreeArc}, syntax_node::{TreeArc},
ast::{self, AstNode}, ast::{self, AstNode},
}; };
@ -24,7 +24,7 @@ pub struct Alias {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
unsafe impl TransparentNewType for Alias { unsafe impl TransparentNewType for Alias {
type Repr = rowan::SyntaxNode<RaTypes>; type Repr = rowan::SyntaxNode;
} }
impl AstNode for Alias { impl AstNode for Alias {
@ -53,7 +53,7 @@ pub struct ArgList {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
unsafe impl TransparentNewType for ArgList { unsafe impl TransparentNewType for ArgList {
type Repr = rowan::SyntaxNode<RaTypes>; type Repr = rowan::SyntaxNode;
} }
impl AstNode for ArgList { impl AstNode for ArgList {
@ -85,7 +85,7 @@ pub struct ArrayExpr {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
unsafe impl TransparentNewType for ArrayExpr { unsafe impl TransparentNewType for ArrayExpr {
type Repr = rowan::SyntaxNode<RaTypes>; type Repr = rowan::SyntaxNode;
} }
impl AstNode for ArrayExpr { impl AstNode for ArrayExpr {
@ -117,7 +117,7 @@ pub struct ArrayType {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
unsafe impl TransparentNewType for ArrayType { unsafe impl TransparentNewType for ArrayType {
type Repr = rowan::SyntaxNode<RaTypes>; type Repr = rowan::SyntaxNode;
} }
impl AstNode for ArrayType { impl AstNode for ArrayType {
@ -153,7 +153,7 @@ pub struct AssocTypeArg {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
unsafe impl TransparentNewType for AssocTypeArg { unsafe impl TransparentNewType for AssocTypeArg {
type Repr = rowan::SyntaxNode<RaTypes>; type Repr = rowan::SyntaxNode;
} }
impl AstNode for AssocTypeArg { impl AstNode for AssocTypeArg {
@ -189,7 +189,7 @@ pub struct Attr {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
unsafe impl TransparentNewType for Attr { unsafe impl TransparentNewType for Attr {
type Repr = rowan::SyntaxNode<RaTypes>; type Repr = rowan::SyntaxNode;
} }
impl AstNode for Attr { impl AstNode for Attr {
@ -221,7 +221,7 @@ pub struct BinExpr {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
unsafe impl TransparentNewType for BinExpr { unsafe impl TransparentNewType for BinExpr {
type Repr = rowan::SyntaxNode<RaTypes>; type Repr = rowan::SyntaxNode;
} }
impl AstNode for BinExpr { impl AstNode for BinExpr {
@ -249,7 +249,7 @@ pub struct BindPat {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
unsafe impl TransparentNewType for BindPat { unsafe impl TransparentNewType for BindPat {
type Repr = rowan::SyntaxNode<RaTypes>; type Repr = rowan::SyntaxNode;
} }
impl AstNode for BindPat { impl AstNode for BindPat {
@ -282,7 +282,7 @@ pub struct Block {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
unsafe impl TransparentNewType for Block { unsafe impl TransparentNewType for Block {
type Repr = rowan::SyntaxNode<RaTypes>; type Repr = rowan::SyntaxNode;
} }
impl AstNode for Block { impl AstNode for Block {
@ -319,7 +319,7 @@ pub struct BlockExpr {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
unsafe impl TransparentNewType for BlockExpr { unsafe impl TransparentNewType for BlockExpr {
type Repr = rowan::SyntaxNode<RaTypes>; type Repr = rowan::SyntaxNode;
} }
impl AstNode for BlockExpr { impl AstNode for BlockExpr {
@ -351,7 +351,7 @@ pub struct BreakExpr {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
unsafe impl TransparentNewType for BreakExpr { unsafe impl TransparentNewType for BreakExpr {
type Repr = rowan::SyntaxNode<RaTypes>; type Repr = rowan::SyntaxNode;
} }
impl AstNode for BreakExpr { impl AstNode for BreakExpr {
@ -383,7 +383,7 @@ pub struct CallExpr {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
unsafe impl TransparentNewType for CallExpr { unsafe impl TransparentNewType for CallExpr {
type Repr = rowan::SyntaxNode<RaTypes>; type Repr = rowan::SyntaxNode;
} }
impl AstNode for CallExpr { impl AstNode for CallExpr {
@ -416,7 +416,7 @@ pub struct CastExpr {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
unsafe impl TransparentNewType for CastExpr { unsafe impl TransparentNewType for CastExpr {
type Repr = rowan::SyntaxNode<RaTypes>; type Repr = rowan::SyntaxNode;
} }
impl AstNode for CastExpr { impl AstNode for CastExpr {
@ -452,7 +452,7 @@ pub struct Condition {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
unsafe impl TransparentNewType for Condition { unsafe impl TransparentNewType for Condition {
type Repr = rowan::SyntaxNode<RaTypes>; type Repr = rowan::SyntaxNode;
} }
impl AstNode for Condition { impl AstNode for Condition {
@ -488,7 +488,7 @@ pub struct ConstDef {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
unsafe impl TransparentNewType for ConstDef { unsafe impl TransparentNewType for ConstDef {
type Repr = rowan::SyntaxNode<RaTypes>; type Repr = rowan::SyntaxNode;
} }
impl AstNode for ConstDef { impl AstNode for ConstDef {
@ -526,7 +526,7 @@ pub struct ContinueExpr {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
unsafe impl TransparentNewType for ContinueExpr { unsafe impl TransparentNewType for ContinueExpr {
type Repr = rowan::SyntaxNode<RaTypes>; type Repr = rowan::SyntaxNode;
} }
impl AstNode for ContinueExpr { impl AstNode for ContinueExpr {
@ -554,7 +554,7 @@ pub struct DynTraitType {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
unsafe impl TransparentNewType for DynTraitType { unsafe impl TransparentNewType for DynTraitType {
type Repr = rowan::SyntaxNode<RaTypes>; type Repr = rowan::SyntaxNode;
} }
impl AstNode for DynTraitType { impl AstNode for DynTraitType {
@ -583,7 +583,7 @@ pub struct EnumDef {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
unsafe impl TransparentNewType for EnumDef { unsafe impl TransparentNewType for EnumDef {
type Repr = rowan::SyntaxNode<RaTypes>; type Repr = rowan::SyntaxNode;
} }
impl AstNode for EnumDef { impl AstNode for EnumDef {
@ -620,7 +620,7 @@ pub struct EnumVariant {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
unsafe impl TransparentNewType for EnumVariant { unsafe impl TransparentNewType for EnumVariant {
type Repr = rowan::SyntaxNode<RaTypes>; type Repr = rowan::SyntaxNode;
} }
impl AstNode for EnumVariant { impl AstNode for EnumVariant {
@ -655,7 +655,7 @@ pub struct EnumVariantList {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
unsafe impl TransparentNewType for EnumVariantList { unsafe impl TransparentNewType for EnumVariantList {
type Repr = rowan::SyntaxNode<RaTypes>; type Repr = rowan::SyntaxNode;
} }
impl AstNode for EnumVariantList { impl AstNode for EnumVariantList {
@ -687,7 +687,7 @@ pub struct Expr {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
unsafe impl TransparentNewType for Expr { unsafe impl TransparentNewType for Expr {
type Repr = rowan::SyntaxNode<RaTypes>; type Repr = rowan::SyntaxNode;
} }
#[derive(Debug, Clone, Copy, PartialEq, Eq)] #[derive(Debug, Clone, Copy, PartialEq, Eq)]
@ -950,7 +950,7 @@ pub struct ExprStmt {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
unsafe impl TransparentNewType for ExprStmt { unsafe impl TransparentNewType for ExprStmt {
type Repr = rowan::SyntaxNode<RaTypes>; type Repr = rowan::SyntaxNode;
} }
impl AstNode for ExprStmt { impl AstNode for ExprStmt {
@ -982,7 +982,7 @@ pub struct ExternCrateItem {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
unsafe impl TransparentNewType for ExternCrateItem { unsafe impl TransparentNewType for ExternCrateItem {
type Repr = rowan::SyntaxNode<RaTypes>; type Repr = rowan::SyntaxNode;
} }
impl AstNode for ExternCrateItem { impl AstNode for ExternCrateItem {
@ -1018,7 +1018,7 @@ pub struct FieldExpr {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
unsafe impl TransparentNewType for FieldExpr { unsafe impl TransparentNewType for FieldExpr {
type Repr = rowan::SyntaxNode<RaTypes>; type Repr = rowan::SyntaxNode;
} }
impl AstNode for FieldExpr { impl AstNode for FieldExpr {
@ -1054,7 +1054,7 @@ pub struct FieldPat {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
unsafe impl TransparentNewType for FieldPat { unsafe impl TransparentNewType for FieldPat {
type Repr = rowan::SyntaxNode<RaTypes>; type Repr = rowan::SyntaxNode;
} }
impl AstNode for FieldPat { impl AstNode for FieldPat {
@ -1087,7 +1087,7 @@ pub struct FieldPatList {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
unsafe impl TransparentNewType for FieldPatList { unsafe impl TransparentNewType for FieldPatList {
type Repr = rowan::SyntaxNode<RaTypes>; type Repr = rowan::SyntaxNode;
} }
impl AstNode for FieldPatList { impl AstNode for FieldPatList {
@ -1123,7 +1123,7 @@ pub struct FnDef {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
unsafe impl TransparentNewType for FnDef { unsafe impl TransparentNewType for FnDef {
type Repr = rowan::SyntaxNode<RaTypes>; type Repr = rowan::SyntaxNode;
} }
impl AstNode for FnDef { impl AstNode for FnDef {
@ -1168,7 +1168,7 @@ pub struct FnPointerType {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
unsafe impl TransparentNewType for FnPointerType { unsafe impl TransparentNewType for FnPointerType {
type Repr = rowan::SyntaxNode<RaTypes>; type Repr = rowan::SyntaxNode;
} }
impl AstNode for FnPointerType { impl AstNode for FnPointerType {
@ -1204,7 +1204,7 @@ pub struct ForExpr {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
unsafe impl TransparentNewType for ForExpr { unsafe impl TransparentNewType for ForExpr {
type Repr = rowan::SyntaxNode<RaTypes>; type Repr = rowan::SyntaxNode;
} }
impl AstNode for ForExpr { impl AstNode for ForExpr {
@ -1241,7 +1241,7 @@ pub struct ForType {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
unsafe impl TransparentNewType for ForType { unsafe impl TransparentNewType for ForType {
type Repr = rowan::SyntaxNode<RaTypes>; type Repr = rowan::SyntaxNode;
} }
impl AstNode for ForType { impl AstNode for ForType {
@ -1273,7 +1273,7 @@ pub struct IfExpr {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
unsafe impl TransparentNewType for IfExpr { unsafe impl TransparentNewType for IfExpr {
type Repr = rowan::SyntaxNode<RaTypes>; type Repr = rowan::SyntaxNode;
} }
impl AstNode for IfExpr { impl AstNode for IfExpr {
@ -1305,7 +1305,7 @@ pub struct ImplBlock {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
unsafe impl TransparentNewType for ImplBlock { unsafe impl TransparentNewType for ImplBlock {
type Repr = rowan::SyntaxNode<RaTypes>; type Repr = rowan::SyntaxNode;
} }
impl AstNode for ImplBlock { impl AstNode for ImplBlock {
@ -1338,7 +1338,7 @@ pub struct ImplItem {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
unsafe impl TransparentNewType for ImplItem { unsafe impl TransparentNewType for ImplItem {
type Repr = rowan::SyntaxNode<RaTypes>; type Repr = rowan::SyntaxNode;
} }
#[derive(Debug, Clone, Copy, PartialEq, Eq)] #[derive(Debug, Clone, Copy, PartialEq, Eq)]
@ -1401,7 +1401,7 @@ pub struct ImplTraitType {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
unsafe impl TransparentNewType for ImplTraitType { unsafe impl TransparentNewType for ImplTraitType {
type Repr = rowan::SyntaxNode<RaTypes>; type Repr = rowan::SyntaxNode;
} }
impl AstNode for ImplTraitType { impl AstNode for ImplTraitType {
@ -1430,7 +1430,7 @@ pub struct IndexExpr {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
unsafe impl TransparentNewType for IndexExpr { unsafe impl TransparentNewType for IndexExpr {
type Repr = rowan::SyntaxNode<RaTypes>; type Repr = rowan::SyntaxNode;
} }
impl AstNode for IndexExpr { impl AstNode for IndexExpr {
@ -1458,7 +1458,7 @@ pub struct ItemList {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
unsafe impl TransparentNewType for ItemList { unsafe impl TransparentNewType for ItemList {
type Repr = rowan::SyntaxNode<RaTypes>; type Repr = rowan::SyntaxNode;
} }
impl AstNode for ItemList { impl AstNode for ItemList {
@ -1492,7 +1492,7 @@ pub struct Label {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
unsafe impl TransparentNewType for Label { unsafe impl TransparentNewType for Label {
type Repr = rowan::SyntaxNode<RaTypes>; type Repr = rowan::SyntaxNode;
} }
impl AstNode for Label { impl AstNode for Label {
@ -1520,7 +1520,7 @@ pub struct LambdaExpr {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
unsafe impl TransparentNewType for LambdaExpr { unsafe impl TransparentNewType for LambdaExpr {
type Repr = rowan::SyntaxNode<RaTypes>; type Repr = rowan::SyntaxNode;
} }
impl AstNode for LambdaExpr { impl AstNode for LambdaExpr {
@ -1556,7 +1556,7 @@ pub struct LetStmt {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
unsafe impl TransparentNewType for LetStmt { unsafe impl TransparentNewType for LetStmt {
type Repr = rowan::SyntaxNode<RaTypes>; type Repr = rowan::SyntaxNode;
} }
impl AstNode for LetStmt { impl AstNode for LetStmt {
@ -1593,7 +1593,7 @@ pub struct LifetimeArg {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
unsafe impl TransparentNewType for LifetimeArg { unsafe impl TransparentNewType for LifetimeArg {
type Repr = rowan::SyntaxNode<RaTypes>; type Repr = rowan::SyntaxNode;
} }
impl AstNode for LifetimeArg { impl AstNode for LifetimeArg {
@ -1621,7 +1621,7 @@ pub struct LifetimeParam {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
unsafe impl TransparentNewType for LifetimeParam { unsafe impl TransparentNewType for LifetimeParam {
type Repr = rowan::SyntaxNode<RaTypes>; type Repr = rowan::SyntaxNode;
} }
impl AstNode for LifetimeParam { impl AstNode for LifetimeParam {
@ -1650,7 +1650,7 @@ pub struct Literal {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
unsafe impl TransparentNewType for Literal { unsafe impl TransparentNewType for Literal {
type Repr = rowan::SyntaxNode<RaTypes>; type Repr = rowan::SyntaxNode;
} }
impl AstNode for Literal { impl AstNode for Literal {
@ -1678,7 +1678,7 @@ pub struct LiteralPat {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
unsafe impl TransparentNewType for LiteralPat { unsafe impl TransparentNewType for LiteralPat {
type Repr = rowan::SyntaxNode<RaTypes>; type Repr = rowan::SyntaxNode;
} }
impl AstNode for LiteralPat { impl AstNode for LiteralPat {
@ -1710,7 +1710,7 @@ pub struct LoopExpr {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
unsafe impl TransparentNewType for LoopExpr { unsafe impl TransparentNewType for LoopExpr {
type Repr = rowan::SyntaxNode<RaTypes>; type Repr = rowan::SyntaxNode;
} }
impl AstNode for LoopExpr { impl AstNode for LoopExpr {
@ -1739,7 +1739,7 @@ pub struct MacroCall {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
unsafe impl TransparentNewType for MacroCall { unsafe impl TransparentNewType for MacroCall {
type Repr = rowan::SyntaxNode<RaTypes>; type Repr = rowan::SyntaxNode;
} }
impl AstNode for MacroCall { impl AstNode for MacroCall {
@ -1777,7 +1777,7 @@ pub struct MatchArm {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
unsafe impl TransparentNewType for MatchArm { unsafe impl TransparentNewType for MatchArm {
type Repr = rowan::SyntaxNode<RaTypes>; type Repr = rowan::SyntaxNode;
} }
impl AstNode for MatchArm { impl AstNode for MatchArm {
@ -1818,7 +1818,7 @@ pub struct MatchArmList {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
unsafe impl TransparentNewType for MatchArmList { unsafe impl TransparentNewType for MatchArmList {
type Repr = rowan::SyntaxNode<RaTypes>; type Repr = rowan::SyntaxNode;
} }
impl AstNode for MatchArmList { impl AstNode for MatchArmList {
@ -1851,7 +1851,7 @@ pub struct MatchExpr {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
unsafe impl TransparentNewType for MatchExpr { unsafe impl TransparentNewType for MatchExpr {
type Repr = rowan::SyntaxNode<RaTypes>; type Repr = rowan::SyntaxNode;
} }
impl AstNode for MatchExpr { impl AstNode for MatchExpr {
@ -1887,7 +1887,7 @@ pub struct MatchGuard {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
unsafe impl TransparentNewType for MatchGuard { unsafe impl TransparentNewType for MatchGuard {
type Repr = rowan::SyntaxNode<RaTypes>; type Repr = rowan::SyntaxNode;
} }
impl AstNode for MatchGuard { impl AstNode for MatchGuard {
@ -1919,7 +1919,7 @@ pub struct MethodCallExpr {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
unsafe impl TransparentNewType for MethodCallExpr { unsafe impl TransparentNewType for MethodCallExpr {
type Repr = rowan::SyntaxNode<RaTypes>; type Repr = rowan::SyntaxNode;
} }
impl AstNode for MethodCallExpr { impl AstNode for MethodCallExpr {
@ -1960,7 +1960,7 @@ pub struct Module {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
unsafe impl TransparentNewType for Module { unsafe impl TransparentNewType for Module {
type Repr = rowan::SyntaxNode<RaTypes>; type Repr = rowan::SyntaxNode;
} }
impl AstNode for Module { impl AstNode for Module {
@ -1996,7 +1996,7 @@ pub struct ModuleItem {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
unsafe impl TransparentNewType for ModuleItem { unsafe impl TransparentNewType for ModuleItem {
type Repr = rowan::SyntaxNode<RaTypes>; type Repr = rowan::SyntaxNode;
} }
#[derive(Debug, Clone, Copy, PartialEq, Eq)] #[derive(Debug, Clone, Copy, PartialEq, Eq)]
@ -2123,7 +2123,7 @@ pub struct Name {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
unsafe impl TransparentNewType for Name { unsafe impl TransparentNewType for Name {
type Repr = rowan::SyntaxNode<RaTypes>; type Repr = rowan::SyntaxNode;
} }
impl AstNode for Name { impl AstNode for Name {
@ -2151,7 +2151,7 @@ pub struct NameRef {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
unsafe impl TransparentNewType for NameRef { unsafe impl TransparentNewType for NameRef {
type Repr = rowan::SyntaxNode<RaTypes>; type Repr = rowan::SyntaxNode;
} }
impl AstNode for NameRef { impl AstNode for NameRef {
@ -2179,7 +2179,7 @@ pub struct NamedField {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
unsafe impl TransparentNewType for NamedField { unsafe impl TransparentNewType for NamedField {
type Repr = rowan::SyntaxNode<RaTypes>; type Repr = rowan::SyntaxNode;
} }
impl AstNode for NamedField { impl AstNode for NamedField {
@ -2215,7 +2215,7 @@ pub struct NamedFieldDef {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
unsafe impl TransparentNewType for NamedFieldDef { unsafe impl TransparentNewType for NamedFieldDef {
type Repr = rowan::SyntaxNode<RaTypes>; type Repr = rowan::SyntaxNode;
} }
impl AstNode for NamedFieldDef { impl AstNode for NamedFieldDef {
@ -2248,7 +2248,7 @@ pub struct NamedFieldDefList {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
unsafe impl TransparentNewType for NamedFieldDefList { unsafe impl TransparentNewType for NamedFieldDefList {
type Repr = rowan::SyntaxNode<RaTypes>; type Repr = rowan::SyntaxNode;
} }
impl AstNode for NamedFieldDefList { impl AstNode for NamedFieldDefList {
@ -2280,7 +2280,7 @@ pub struct NamedFieldList {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
unsafe impl TransparentNewType for NamedFieldList { unsafe impl TransparentNewType for NamedFieldList {
type Repr = rowan::SyntaxNode<RaTypes>; type Repr = rowan::SyntaxNode;
} }
impl AstNode for NamedFieldList { impl AstNode for NamedFieldList {
@ -2312,7 +2312,7 @@ pub struct NeverType {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
unsafe impl TransparentNewType for NeverType { unsafe impl TransparentNewType for NeverType {
type Repr = rowan::SyntaxNode<RaTypes>; type Repr = rowan::SyntaxNode;
} }
impl AstNode for NeverType { impl AstNode for NeverType {
@ -2340,7 +2340,7 @@ pub struct NominalDef {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
unsafe impl TransparentNewType for NominalDef { unsafe impl TransparentNewType for NominalDef {
type Repr = rowan::SyntaxNode<RaTypes>; type Repr = rowan::SyntaxNode;
} }
#[derive(Debug, Clone, Copy, PartialEq, Eq)] #[derive(Debug, Clone, Copy, PartialEq, Eq)]
@ -2398,7 +2398,7 @@ pub struct Param {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
unsafe impl TransparentNewType for Param { unsafe impl TransparentNewType for Param {
type Repr = rowan::SyntaxNode<RaTypes>; type Repr = rowan::SyntaxNode;
} }
impl AstNode for Param { impl AstNode for Param {
@ -2431,7 +2431,7 @@ pub struct ParamList {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
unsafe impl TransparentNewType for ParamList { unsafe impl TransparentNewType for ParamList {
type Repr = rowan::SyntaxNode<RaTypes>; type Repr = rowan::SyntaxNode;
} }
impl AstNode for ParamList { impl AstNode for ParamList {
@ -2467,7 +2467,7 @@ pub struct ParenExpr {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
unsafe impl TransparentNewType for ParenExpr { unsafe impl TransparentNewType for ParenExpr {
type Repr = rowan::SyntaxNode<RaTypes>; type Repr = rowan::SyntaxNode;
} }
impl AstNode for ParenExpr { impl AstNode for ParenExpr {
@ -2499,7 +2499,7 @@ pub struct ParenType {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
unsafe impl TransparentNewType for ParenType { unsafe impl TransparentNewType for ParenType {
type Repr = rowan::SyntaxNode<RaTypes>; type Repr = rowan::SyntaxNode;
} }
impl AstNode for ParenType { impl AstNode for ParenType {
@ -2531,7 +2531,7 @@ pub struct Pat {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
unsafe impl TransparentNewType for Pat { unsafe impl TransparentNewType for Pat {
type Repr = rowan::SyntaxNode<RaTypes>; type Repr = rowan::SyntaxNode;
} }
#[derive(Debug, Clone, Copy, PartialEq, Eq)] #[derive(Debug, Clone, Copy, PartialEq, Eq)]
@ -2650,7 +2650,7 @@ pub struct Path {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
unsafe impl TransparentNewType for Path { unsafe impl TransparentNewType for Path {
type Repr = rowan::SyntaxNode<RaTypes>; type Repr = rowan::SyntaxNode;
} }
impl AstNode for Path { impl AstNode for Path {
@ -2686,7 +2686,7 @@ pub struct PathExpr {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
unsafe impl TransparentNewType for PathExpr { unsafe impl TransparentNewType for PathExpr {
type Repr = rowan::SyntaxNode<RaTypes>; type Repr = rowan::SyntaxNode;
} }
impl AstNode for PathExpr { impl AstNode for PathExpr {
@ -2718,7 +2718,7 @@ pub struct PathPat {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
unsafe impl TransparentNewType for PathPat { unsafe impl TransparentNewType for PathPat {
type Repr = rowan::SyntaxNode<RaTypes>; type Repr = rowan::SyntaxNode;
} }
impl AstNode for PathPat { impl AstNode for PathPat {
@ -2750,7 +2750,7 @@ pub struct PathSegment {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
unsafe impl TransparentNewType for PathSegment { unsafe impl TransparentNewType for PathSegment {
type Repr = rowan::SyntaxNode<RaTypes>; type Repr = rowan::SyntaxNode;
} }
impl AstNode for PathSegment { impl AstNode for PathSegment {
@ -2786,7 +2786,7 @@ pub struct PathType {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
unsafe impl TransparentNewType for PathType { unsafe impl TransparentNewType for PathType {
type Repr = rowan::SyntaxNode<RaTypes>; type Repr = rowan::SyntaxNode;
} }
impl AstNode for PathType { impl AstNode for PathType {
@ -2818,7 +2818,7 @@ pub struct PlaceholderPat {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
unsafe impl TransparentNewType for PlaceholderPat { unsafe impl TransparentNewType for PlaceholderPat {
type Repr = rowan::SyntaxNode<RaTypes>; type Repr = rowan::SyntaxNode;
} }
impl AstNode for PlaceholderPat { impl AstNode for PlaceholderPat {
@ -2846,7 +2846,7 @@ pub struct PlaceholderType {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
unsafe impl TransparentNewType for PlaceholderType { unsafe impl TransparentNewType for PlaceholderType {
type Repr = rowan::SyntaxNode<RaTypes>; type Repr = rowan::SyntaxNode;
} }
impl AstNode for PlaceholderType { impl AstNode for PlaceholderType {
@ -2874,7 +2874,7 @@ pub struct PointerType {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
unsafe impl TransparentNewType for PointerType { unsafe impl TransparentNewType for PointerType {
type Repr = rowan::SyntaxNode<RaTypes>; type Repr = rowan::SyntaxNode;
} }
impl AstNode for PointerType { impl AstNode for PointerType {
@ -2906,7 +2906,7 @@ pub struct PosFieldDef {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
unsafe impl TransparentNewType for PosFieldDef { unsafe impl TransparentNewType for PosFieldDef {
type Repr = rowan::SyntaxNode<RaTypes>; type Repr = rowan::SyntaxNode;
} }
impl AstNode for PosFieldDef { impl AstNode for PosFieldDef {
@ -2940,7 +2940,7 @@ pub struct PosFieldDefList {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
unsafe impl TransparentNewType for PosFieldDefList { unsafe impl TransparentNewType for PosFieldDefList {
type Repr = rowan::SyntaxNode<RaTypes>; type Repr = rowan::SyntaxNode;
} }
impl AstNode for PosFieldDefList { impl AstNode for PosFieldDefList {
@ -2972,7 +2972,7 @@ pub struct PrefixExpr {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
unsafe impl TransparentNewType for PrefixExpr { unsafe impl TransparentNewType for PrefixExpr {
type Repr = rowan::SyntaxNode<RaTypes>; type Repr = rowan::SyntaxNode;
} }
impl AstNode for PrefixExpr { impl AstNode for PrefixExpr {
@ -3004,7 +3004,7 @@ pub struct RangeExpr {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
unsafe impl TransparentNewType for RangeExpr { unsafe impl TransparentNewType for RangeExpr {
type Repr = rowan::SyntaxNode<RaTypes>; type Repr = rowan::SyntaxNode;
} }
impl AstNode for RangeExpr { impl AstNode for RangeExpr {
@ -3032,7 +3032,7 @@ pub struct RangePat {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
unsafe impl TransparentNewType for RangePat { unsafe impl TransparentNewType for RangePat {
type Repr = rowan::SyntaxNode<RaTypes>; type Repr = rowan::SyntaxNode;
} }
impl AstNode for RangePat { impl AstNode for RangePat {
@ -3060,7 +3060,7 @@ pub struct RefExpr {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
unsafe impl TransparentNewType for RefExpr { unsafe impl TransparentNewType for RefExpr {
type Repr = rowan::SyntaxNode<RaTypes>; type Repr = rowan::SyntaxNode;
} }
impl AstNode for RefExpr { impl AstNode for RefExpr {
@ -3092,7 +3092,7 @@ pub struct RefPat {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
unsafe impl TransparentNewType for RefPat { unsafe impl TransparentNewType for RefPat {
type Repr = rowan::SyntaxNode<RaTypes>; type Repr = rowan::SyntaxNode;
} }
impl AstNode for RefPat { impl AstNode for RefPat {
@ -3124,7 +3124,7 @@ pub struct ReferenceType {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
unsafe impl TransparentNewType for ReferenceType { unsafe impl TransparentNewType for ReferenceType {
type Repr = rowan::SyntaxNode<RaTypes>; type Repr = rowan::SyntaxNode;
} }
impl AstNode for ReferenceType { impl AstNode for ReferenceType {
@ -3156,7 +3156,7 @@ pub struct RetType {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
unsafe impl TransparentNewType for RetType { unsafe impl TransparentNewType for RetType {
type Repr = rowan::SyntaxNode<RaTypes>; type Repr = rowan::SyntaxNode;
} }
impl AstNode for RetType { impl AstNode for RetType {
@ -3188,7 +3188,7 @@ pub struct ReturnExpr {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
unsafe impl TransparentNewType for ReturnExpr { unsafe impl TransparentNewType for ReturnExpr {
type Repr = rowan::SyntaxNode<RaTypes>; type Repr = rowan::SyntaxNode;
} }
impl AstNode for ReturnExpr { impl AstNode for ReturnExpr {
@ -3220,7 +3220,7 @@ pub struct SelfParam {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
unsafe impl TransparentNewType for SelfParam { unsafe impl TransparentNewType for SelfParam {
type Repr = rowan::SyntaxNode<RaTypes>; type Repr = rowan::SyntaxNode;
} }
impl AstNode for SelfParam { impl AstNode for SelfParam {
@ -3249,7 +3249,7 @@ pub struct SlicePat {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
unsafe impl TransparentNewType for SlicePat { unsafe impl TransparentNewType for SlicePat {
type Repr = rowan::SyntaxNode<RaTypes>; type Repr = rowan::SyntaxNode;
} }
impl AstNode for SlicePat { impl AstNode for SlicePat {
@ -3277,7 +3277,7 @@ pub struct SliceType {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
unsafe impl TransparentNewType for SliceType { unsafe impl TransparentNewType for SliceType {
type Repr = rowan::SyntaxNode<RaTypes>; type Repr = rowan::SyntaxNode;
} }
impl AstNode for SliceType { impl AstNode for SliceType {
@ -3309,7 +3309,7 @@ pub struct SourceFile {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
unsafe impl TransparentNewType for SourceFile { unsafe impl TransparentNewType for SourceFile {
type Repr = rowan::SyntaxNode<RaTypes>; type Repr = rowan::SyntaxNode;
} }
impl AstNode for SourceFile { impl AstNode for SourceFile {
@ -3343,7 +3343,7 @@ pub struct StaticDef {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
unsafe impl TransparentNewType for StaticDef { unsafe impl TransparentNewType for StaticDef {
type Repr = rowan::SyntaxNode<RaTypes>; type Repr = rowan::SyntaxNode;
} }
impl AstNode for StaticDef { impl AstNode for StaticDef {
@ -3381,7 +3381,7 @@ pub struct Stmt {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
unsafe impl TransparentNewType for Stmt { unsafe impl TransparentNewType for Stmt {
type Repr = rowan::SyntaxNode<RaTypes>; type Repr = rowan::SyntaxNode;
} }
#[derive(Debug, Clone, Copy, PartialEq, Eq)] #[derive(Debug, Clone, Copy, PartialEq, Eq)]
@ -3436,7 +3436,7 @@ pub struct StructDef {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
unsafe impl TransparentNewType for StructDef { unsafe impl TransparentNewType for StructDef {
type Repr = rowan::SyntaxNode<RaTypes>; type Repr = rowan::SyntaxNode;
} }
impl AstNode for StructDef { impl AstNode for StructDef {
@ -3469,7 +3469,7 @@ pub struct StructLit {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
unsafe impl TransparentNewType for StructLit { unsafe impl TransparentNewType for StructLit {
type Repr = rowan::SyntaxNode<RaTypes>; type Repr = rowan::SyntaxNode;
} }
impl AstNode for StructLit { impl AstNode for StructLit {
@ -3509,7 +3509,7 @@ pub struct StructPat {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
unsafe impl TransparentNewType for StructPat { unsafe impl TransparentNewType for StructPat {
type Repr = rowan::SyntaxNode<RaTypes>; type Repr = rowan::SyntaxNode;
} }
impl AstNode for StructPat { impl AstNode for StructPat {
@ -3545,7 +3545,7 @@ pub struct TokenTree {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
unsafe impl TransparentNewType for TokenTree { unsafe impl TransparentNewType for TokenTree {
type Repr = rowan::SyntaxNode<RaTypes>; type Repr = rowan::SyntaxNode;
} }
impl AstNode for TokenTree { impl AstNode for TokenTree {
@ -3573,7 +3573,7 @@ pub struct TraitDef {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
unsafe impl TransparentNewType for TraitDef { unsafe impl TransparentNewType for TraitDef {
type Repr = rowan::SyntaxNode<RaTypes>; type Repr = rowan::SyntaxNode;
} }
impl AstNode for TraitDef { impl AstNode for TraitDef {
@ -3611,7 +3611,7 @@ pub struct TryExpr {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
unsafe impl TransparentNewType for TryExpr { unsafe impl TransparentNewType for TryExpr {
type Repr = rowan::SyntaxNode<RaTypes>; type Repr = rowan::SyntaxNode;
} }
impl AstNode for TryExpr { impl AstNode for TryExpr {
@ -3643,7 +3643,7 @@ pub struct TupleExpr {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
unsafe impl TransparentNewType for TupleExpr { unsafe impl TransparentNewType for TupleExpr {
type Repr = rowan::SyntaxNode<RaTypes>; type Repr = rowan::SyntaxNode;
} }
impl AstNode for TupleExpr { impl AstNode for TupleExpr {
@ -3675,7 +3675,7 @@ pub struct TuplePat {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
unsafe impl TransparentNewType for TuplePat { unsafe impl TransparentNewType for TuplePat {
type Repr = rowan::SyntaxNode<RaTypes>; type Repr = rowan::SyntaxNode;
} }
impl AstNode for TuplePat { impl AstNode for TuplePat {
@ -3707,7 +3707,7 @@ pub struct TupleStructPat {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
unsafe impl TransparentNewType for TupleStructPat { unsafe impl TransparentNewType for TupleStructPat {
type Repr = rowan::SyntaxNode<RaTypes>; type Repr = rowan::SyntaxNode;
} }
impl AstNode for TupleStructPat { impl AstNode for TupleStructPat {
@ -3743,7 +3743,7 @@ pub struct TupleType {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
unsafe impl TransparentNewType for TupleType { unsafe impl TransparentNewType for TupleType {
type Repr = rowan::SyntaxNode<RaTypes>; type Repr = rowan::SyntaxNode;
} }
impl AstNode for TupleType { impl AstNode for TupleType {
@ -3775,7 +3775,7 @@ pub struct TypeAliasDef {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
unsafe impl TransparentNewType for TypeAliasDef { unsafe impl TransparentNewType for TypeAliasDef {
type Repr = rowan::SyntaxNode<RaTypes>; type Repr = rowan::SyntaxNode;
} }
impl AstNode for TypeAliasDef { impl AstNode for TypeAliasDef {
@ -3813,7 +3813,7 @@ pub struct TypeArg {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
unsafe impl TransparentNewType for TypeArg { unsafe impl TransparentNewType for TypeArg {
type Repr = rowan::SyntaxNode<RaTypes>; type Repr = rowan::SyntaxNode;
} }
impl AstNode for TypeArg { impl AstNode for TypeArg {
@ -3845,7 +3845,7 @@ pub struct TypeArgList {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
unsafe impl TransparentNewType for TypeArgList { unsafe impl TransparentNewType for TypeArgList {
type Repr = rowan::SyntaxNode<RaTypes>; type Repr = rowan::SyntaxNode;
} }
impl AstNode for TypeArgList { impl AstNode for TypeArgList {
@ -3885,7 +3885,7 @@ pub struct TypeBound {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
unsafe impl TransparentNewType for TypeBound { unsafe impl TransparentNewType for TypeBound {
type Repr = rowan::SyntaxNode<RaTypes>; type Repr = rowan::SyntaxNode;
} }
impl AstNode for TypeBound { impl AstNode for TypeBound {
@ -3917,7 +3917,7 @@ pub struct TypeBoundList {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
unsafe impl TransparentNewType for TypeBoundList { unsafe impl TransparentNewType for TypeBoundList {
type Repr = rowan::SyntaxNode<RaTypes>; type Repr = rowan::SyntaxNode;
} }
impl AstNode for TypeBoundList { impl AstNode for TypeBoundList {
@ -3949,7 +3949,7 @@ pub struct TypeParam {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
unsafe impl TransparentNewType for TypeParam { unsafe impl TransparentNewType for TypeParam {
type Repr = rowan::SyntaxNode<RaTypes>; type Repr = rowan::SyntaxNode;
} }
impl AstNode for TypeParam { impl AstNode for TypeParam {
@ -3980,7 +3980,7 @@ pub struct TypeParamList {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
unsafe impl TransparentNewType for TypeParamList { unsafe impl TransparentNewType for TypeParamList {
type Repr = rowan::SyntaxNode<RaTypes>; type Repr = rowan::SyntaxNode;
} }
impl AstNode for TypeParamList { impl AstNode for TypeParamList {
@ -4016,7 +4016,7 @@ pub struct TypeRef {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
unsafe impl TransparentNewType for TypeRef { unsafe impl TransparentNewType for TypeRef {
type Repr = rowan::SyntaxNode<RaTypes>; type Repr = rowan::SyntaxNode;
} }
#[derive(Debug, Clone, Copy, PartialEq, Eq)] #[derive(Debug, Clone, Copy, PartialEq, Eq)]
@ -4159,7 +4159,7 @@ pub struct UseItem {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
unsafe impl TransparentNewType for UseItem { unsafe impl TransparentNewType for UseItem {
type Repr = rowan::SyntaxNode<RaTypes>; type Repr = rowan::SyntaxNode;
} }
impl AstNode for UseItem { impl AstNode for UseItem {
@ -4192,7 +4192,7 @@ pub struct UseTree {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
unsafe impl TransparentNewType for UseTree { unsafe impl TransparentNewType for UseTree {
type Repr = rowan::SyntaxNode<RaTypes>; type Repr = rowan::SyntaxNode;
} }
impl AstNode for UseTree { impl AstNode for UseTree {
@ -4232,7 +4232,7 @@ pub struct UseTreeList {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
unsafe impl TransparentNewType for UseTreeList { unsafe impl TransparentNewType for UseTreeList {
type Repr = rowan::SyntaxNode<RaTypes>; type Repr = rowan::SyntaxNode;
} }
impl AstNode for UseTreeList { impl AstNode for UseTreeList {
@ -4264,7 +4264,7 @@ pub struct Visibility {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
unsafe impl TransparentNewType for Visibility { unsafe impl TransparentNewType for Visibility {
type Repr = rowan::SyntaxNode<RaTypes>; type Repr = rowan::SyntaxNode;
} }
impl AstNode for Visibility { impl AstNode for Visibility {
@ -4292,7 +4292,7 @@ pub struct WhereClause {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
unsafe impl TransparentNewType for WhereClause { unsafe impl TransparentNewType for WhereClause {
type Repr = rowan::SyntaxNode<RaTypes>; type Repr = rowan::SyntaxNode;
} }
impl AstNode for WhereClause { impl AstNode for WhereClause {
@ -4324,7 +4324,7 @@ pub struct WherePred {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
unsafe impl TransparentNewType for WherePred { unsafe impl TransparentNewType for WherePred {
type Repr = rowan::SyntaxNode<RaTypes>; type Repr = rowan::SyntaxNode;
} }
impl AstNode for WherePred { impl AstNode for WherePred {
@ -4357,7 +4357,7 @@ pub struct WhileExpr {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
unsafe impl TransparentNewType for WhileExpr { unsafe impl TransparentNewType for WhileExpr {
type Repr = rowan::SyntaxNode<RaTypes>; type Repr = rowan::SyntaxNode;
} }
impl AstNode for WhileExpr { impl AstNode for WhileExpr {

View file

@ -15,7 +15,7 @@ use rowan::TransparentNewType;
use crate::{ use crate::{
SyntaxNode, SyntaxKind::*, SyntaxNode, SyntaxKind::*,
syntax_node::{RaTypes, TreeArc}, syntax_node::{TreeArc},
ast::{self, AstNode}, ast::{self, AstNode},
}; };
{% for node, methods in ast %} {% for node, methods in ast %}
@ -28,7 +28,7 @@ pub struct {{ node }} {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
unsafe impl TransparentNewType for {{ node }} { unsafe impl TransparentNewType for {{ node }} {
type Repr = rowan::SyntaxNode<RaTypes>; type Repr = rowan::SyntaxNode;
} }
#[derive(Debug, Clone, Copy, PartialEq, Eq)] #[derive(Debug, Clone, Copy, PartialEq, Eq)]
@ -81,7 +81,7 @@ pub struct {{ node }} {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
unsafe impl TransparentNewType for {{ node }} { unsafe impl TransparentNewType for {{ node }} {
type Repr = rowan::SyntaxNode<RaTypes>; type Repr = rowan::SyntaxNode;
} }
impl AstNode for {{ node }} { impl AstNode for {{ node }} {

View file

@ -79,7 +79,7 @@ impl SourceFile {
} }
pub fn errors(&self) -> Vec<SyntaxError> { pub fn errors(&self) -> Vec<SyntaxError> {
let mut errors = self.syntax.root_data().clone(); let mut errors = self.syntax.root_data().to_vec();
errors.extend(validation::validate(self)); errors.extend(validation::validate(self));
errors errors
} }

View file

@ -67,7 +67,7 @@ fn reparse_token<'node>(
} }
} }
let new_token = GreenToken::new(token.kind(), text.into()); let new_token = GreenToken::new(rowan::SyntaxKind(token.kind().into()), text.into());
Some((token.replace_with(new_token), token.range())) Some((token.replace_with(new_token), token.range()))
} }
_ => None, _ => None,

View file

@ -8,11 +8,12 @@
use std::{ use std::{
fmt::{self, Write}, fmt::{self, Write},
any::Any,
borrow::Borrow, borrow::Borrow,
}; };
use ra_parser::ParseError; use ra_parser::ParseError;
use rowan::{Types, TransparentNewType, GreenNodeBuilder}; use rowan::{TransparentNewType, GreenNodeBuilder};
use crate::{ use crate::{
SmolStr, SyntaxKind, TextUnit, TextRange, SyntaxText, SourceFile, AstNode, SmolStr, SyntaxKind, TextUnit, TextRange, SyntaxText, SourceFile, AstNode,
@ -20,26 +21,15 @@ use crate::{
}; };
pub use rowan::WalkEvent; pub use rowan::WalkEvent;
pub(crate) use rowan::{GreenNode, GreenToken};
#[derive(Debug, Clone, Copy)]
pub enum RaTypes {}
impl Types for RaTypes {
type Kind = SyntaxKind;
type RootData = Vec<SyntaxError>;
}
pub(crate) type GreenNode = rowan::GreenNode<RaTypes>;
pub(crate) type GreenToken = rowan::GreenToken<RaTypes>;
#[allow(unused)]
pub(crate) type GreenElement = rowan::GreenElement<RaTypes>;
/// Marker trait for CST and AST nodes /// Marker trait for CST and AST nodes
pub trait SyntaxNodeWrapper: TransparentNewType<Repr = rowan::SyntaxNode<RaTypes>> {} pub trait SyntaxNodeWrapper: TransparentNewType<Repr = rowan::SyntaxNode> {}
impl<T: TransparentNewType<Repr = rowan::SyntaxNode<RaTypes>>> SyntaxNodeWrapper for T {} impl<T: TransparentNewType<Repr = rowan::SyntaxNode>> SyntaxNodeWrapper for T {}
/// An owning smart pointer for CST or AST node. /// An owning smart pointer for CST or AST node.
#[derive(PartialEq, Eq, Hash)] #[derive(PartialEq, Eq, Hash)]
pub struct TreeArc<T: SyntaxNodeWrapper>(pub(crate) rowan::TreeArc<RaTypes, T>); pub struct TreeArc<T: SyntaxNodeWrapper>(pub(crate) rowan::TreeArc<T>);
impl<T: SyntaxNodeWrapper> Borrow<T> for TreeArc<T> { impl<T: SyntaxNodeWrapper> Borrow<T> for TreeArc<T> {
fn borrow(&self) -> &T { fn borrow(&self) -> &T {
@ -101,9 +91,9 @@ where
#[derive(PartialEq, Eq, Hash)] #[derive(PartialEq, Eq, Hash)]
#[repr(transparent)] #[repr(transparent)]
pub struct SyntaxNode(pub(crate) rowan::SyntaxNode<RaTypes>); pub struct SyntaxNode(pub(crate) rowan::SyntaxNode);
unsafe impl TransparentNewType for SyntaxNode { unsafe impl TransparentNewType for SyntaxNode {
type Repr = rowan::SyntaxNode<RaTypes>; type Repr = rowan::SyntaxNode;
} }
impl ToOwned for SyntaxNode { impl ToOwned for SyntaxNode {
@ -134,12 +124,14 @@ pub enum Direction {
impl SyntaxNode { impl SyntaxNode {
pub(crate) fn new(green: GreenNode, errors: Vec<SyntaxError>) -> TreeArc<SyntaxNode> { pub(crate) fn new(green: GreenNode, errors: Vec<SyntaxError>) -> TreeArc<SyntaxNode> {
let errors: Option<Box<Any + Send + Sync>> =
if errors.is_empty() { None } else { Some(Box::new(errors)) };
let ptr = TreeArc(rowan::SyntaxNode::new(green, errors)); let ptr = TreeArc(rowan::SyntaxNode::new(green, errors));
TreeArc::cast(ptr) TreeArc::cast(ptr)
} }
pub fn kind(&self) -> SyntaxKind { pub fn kind(&self) -> SyntaxKind {
self.0.kind() self.0.kind().0.into()
} }
pub fn range(&self) -> TextRange { pub fn range(&self) -> TextRange {
@ -303,8 +295,14 @@ impl SyntaxNode {
buf buf
} }
pub(crate) fn root_data(&self) -> &Vec<SyntaxError> { pub(crate) fn root_data(&self) -> &[SyntaxError] {
self.0.root_data() match self.0.root_data() {
None => &[],
Some(data) => {
let data: &Vec<SyntaxError> = std::any::Any::downcast_ref(data).unwrap();
data.as_slice()
}
}
} }
pub(crate) fn replace_with(&self, replacement: GreenNode) -> GreenNode { pub(crate) fn replace_with(&self, replacement: GreenNode) -> GreenNode {
@ -313,7 +311,7 @@ impl SyntaxNode {
} }
#[derive(Clone, Copy, PartialEq, Eq, Hash)] #[derive(Clone, Copy, PartialEq, Eq, Hash)]
pub struct SyntaxToken<'a>(pub(crate) rowan::SyntaxToken<'a, RaTypes>); pub struct SyntaxToken<'a>(pub(crate) rowan::SyntaxToken<'a>);
//FIXME: always output text //FIXME: always output text
impl<'a> fmt::Debug for SyntaxToken<'a> { impl<'a> fmt::Debug for SyntaxToken<'a> {
@ -339,15 +337,15 @@ impl<'a> fmt::Display for SyntaxToken<'a> {
} }
} }
impl<'a> From<rowan::SyntaxToken<'a, RaTypes>> for SyntaxToken<'a> { impl<'a> From<rowan::SyntaxToken<'a>> for SyntaxToken<'a> {
fn from(t: rowan::SyntaxToken<'a, RaTypes>) -> Self { fn from(t: rowan::SyntaxToken<'a>) -> Self {
SyntaxToken(t) SyntaxToken(t)
} }
} }
impl<'a> SyntaxToken<'a> { impl<'a> SyntaxToken<'a> {
pub fn kind(&self) -> SyntaxKind { pub fn kind(&self) -> SyntaxKind {
self.0.kind() self.0.kind().0.into()
} }
pub fn text(&self) -> &'a SmolStr { pub fn text(&self) -> &'a SmolStr {
@ -454,8 +452,8 @@ impl<'a> SyntaxElement<'a> {
} }
} }
impl<'a> From<rowan::SyntaxElement<'a, RaTypes>> for SyntaxElement<'a> { impl<'a> From<rowan::SyntaxElement<'a>> for SyntaxElement<'a> {
fn from(el: rowan::SyntaxElement<'a, RaTypes>) -> Self { fn from(el: rowan::SyntaxElement<'a>) -> Self {
match el { match el {
rowan::SyntaxElement::Node(n) => SyntaxElement::Node(SyntaxNode::from_repr(n)), rowan::SyntaxElement::Node(n) => SyntaxElement::Node(SyntaxNode::from_repr(n)),
rowan::SyntaxElement::Token(t) => SyntaxElement::Token(t.into()), rowan::SyntaxElement::Token(t) => SyntaxElement::Token(t.into()),
@ -485,7 +483,7 @@ impl<'a> SyntaxElement<'a> {
} }
#[derive(Debug)] #[derive(Debug)]
pub struct SyntaxNodeChildren<'a>(rowan::SyntaxNodeChildren<'a, RaTypes>); pub struct SyntaxNodeChildren<'a>(rowan::SyntaxNodeChildren<'a>);
impl<'a> Iterator for SyntaxNodeChildren<'a> { impl<'a> Iterator for SyntaxNodeChildren<'a> {
type Item = &'a SyntaxNode; type Item = &'a SyntaxNode;
@ -496,7 +494,7 @@ impl<'a> Iterator for SyntaxNodeChildren<'a> {
} }
#[derive(Debug)] #[derive(Debug)]
pub struct SyntaxElementChildren<'a>(rowan::SyntaxElementChildren<'a, RaTypes>); pub struct SyntaxElementChildren<'a>(rowan::SyntaxElementChildren<'a>);
impl<'a> Iterator for SyntaxElementChildren<'a> { impl<'a> Iterator for SyntaxElementChildren<'a> {
type Item = SyntaxElement<'a>; type Item = SyntaxElement<'a>;
@ -508,7 +506,7 @@ impl<'a> Iterator for SyntaxElementChildren<'a> {
pub struct SyntaxTreeBuilder { pub struct SyntaxTreeBuilder {
errors: Vec<SyntaxError>, errors: Vec<SyntaxError>,
inner: GreenNodeBuilder<RaTypes>, inner: GreenNodeBuilder,
} }
impl Default for SyntaxTreeBuilder { impl Default for SyntaxTreeBuilder {
@ -533,11 +531,11 @@ impl SyntaxTreeBuilder {
} }
pub fn token(&mut self, kind: SyntaxKind, text: SmolStr) { pub fn token(&mut self, kind: SyntaxKind, text: SmolStr) {
self.inner.token(kind, text) self.inner.token(rowan::SyntaxKind(kind.into()), text)
} }
pub fn start_node(&mut self, kind: SyntaxKind) { pub fn start_node(&mut self, kind: SyntaxKind) {
self.inner.start_node(kind) self.inner.start_node(rowan::SyntaxKind(kind.into()))
} }
pub fn finish_node(&mut self) { pub fn finish_node(&mut self) {