diff options
-rw-r--r-- | .travis.yml | 3 | ||||
-rw-r--r-- | Cargo.lock | 6 | ||||
-rw-r--r-- | crates/ra_analysis/src/descriptors/function/imp.rs | 4 | ||||
-rw-r--r-- | crates/ra_analysis/src/descriptors/module/imp.rs | 8 | ||||
-rw-r--r-- | crates/ra_analysis/src/descriptors/module/mod.rs | 10 | ||||
-rw-r--r-- | crates/ra_analysis/src/imp.rs | 2 | ||||
-rw-r--r-- | crates/ra_syntax/Cargo.toml | 2 | ||||
-rw-r--r-- | crates/ra_syntax/src/algo/mod.rs | 113 | ||||
-rw-r--r-- | crates/ra_syntax/src/ast/generated.rs | 3407 | ||||
-rw-r--r-- | crates/ra_syntax/src/ast/generated.rs.tera | 52 | ||||
-rw-r--r-- | crates/ra_syntax/src/ast/mod.rs | 4 | ||||
-rw-r--r-- | crates/ra_syntax/src/grammar/type_params.rs | 6 | ||||
-rw-r--r-- | crates/ra_syntax/src/lib.rs | 15 | ||||
-rw-r--r-- | crates/ra_syntax/src/validation.rs | 2 | ||||
-rw-r--r-- | crates/ra_syntax/src/yellow/mod.rs | 2 | ||||
-rw-r--r-- | crates/ra_syntax/tests/data/parser/err/0027_incomplere_where_for.rs | 3 | ||||
-rw-r--r-- | crates/ra_syntax/tests/data/parser/err/0027_incomplere_where_for.txt | 27 |
17 files changed, 1907 insertions, 1759 deletions
diff --git a/.travis.yml b/.travis.yml index 5252f20e2..ecb3b76f4 100644 --- a/.travis.yml +++ b/.travis.yml | |||
@@ -1,7 +1,8 @@ | |||
1 | cache: cargo | 1 | cache: cargo |
2 | before_cache: | 2 | before_cache: |
3 | - find ./target/debug -type f -maxdepth 1 -delete | 3 | - find ./target/debug -type f -maxdepth 1 -delete |
4 | - rm -f ./target/debug/deps/*ra_* | 4 | - rm -fr ./target/debug/{deps,.fingerprint}/{*ra_*,*test*,*tools*,*gen_lsp*} |
5 | - rm -f ./target/.rustc_info.json | ||
5 | 6 | ||
6 | env: | 7 | env: |
7 | - CARGO_INCREMENTAL=0 | 8 | - CARGO_INCREMENTAL=0 |
diff --git a/Cargo.lock b/Cargo.lock index 555efdfb9..c1f773055 100644 --- a/Cargo.lock +++ b/Cargo.lock | |||
@@ -675,7 +675,7 @@ dependencies = [ | |||
675 | "drop_bomb 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", | 675 | "drop_bomb 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", |
676 | "itertools 0.7.8 (registry+https://github.com/rust-lang/crates.io-index)", | 676 | "itertools 0.7.8 (registry+https://github.com/rust-lang/crates.io-index)", |
677 | "parking_lot 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", | 677 | "parking_lot 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", |
678 | "rowan 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", | 678 | "rowan 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", |
679 | "test_utils 0.1.0", | 679 | "test_utils 0.1.0", |
680 | "text_unit 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", | 680 | "text_unit 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", |
681 | "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", | 681 | "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", |
@@ -796,7 +796,7 @@ dependencies = [ | |||
796 | 796 | ||
797 | [[package]] | 797 | [[package]] |
798 | name = "rowan" | 798 | name = "rowan" |
799 | version = "0.1.1" | 799 | version = "0.1.2" |
800 | source = "registry+https://github.com/rust-lang/crates.io-index" | 800 | source = "registry+https://github.com/rust-lang/crates.io-index" |
801 | dependencies = [ | 801 | dependencies = [ |
802 | "parking_lot 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", | 802 | "parking_lot 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", |
@@ -1347,7 +1347,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
1347 | "checksum relative-path 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0e7790c7f1cc73d831d28dc5a7deb316a006e7848e6a7f467cdb10a0a9e0fb1c" | 1347 | "checksum relative-path 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0e7790c7f1cc73d831d28dc5a7deb316a006e7848e6a7f467cdb10a0a9e0fb1c" |
1348 | "checksum remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3488ba1b9a2084d38645c4c08276a1752dcbf2c7130d74f1569681ad5d2799c5" | 1348 | "checksum remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3488ba1b9a2084d38645c4c08276a1752dcbf2c7130d74f1569681ad5d2799c5" |
1349 | "checksum ron 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c48677d8a9247a4e0d1f3f9cb4b0a8e29167fdc3c04f383a5e669cd7a960ae0f" | 1349 | "checksum ron 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c48677d8a9247a4e0d1f3f9cb4b0a8e29167fdc3c04f383a5e669cd7a960ae0f" |
1350 | "checksum rowan 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4bb1f952404091f61bfea7cd09c564090a0fcee3d22223f98084e8756e01c04d" | 1350 | "checksum rowan 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "795b1c830f5335e89f93415315518e9727307308c44c1e5adebe8a38f856c334" |
1351 | "checksum rustc-demangle 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "bcfe5b13211b4d78e5c2cadfebd7769197d95c639c35a50057eb4c05de811395" | 1351 | "checksum rustc-demangle 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "bcfe5b13211b4d78e5c2cadfebd7769197d95c639c35a50057eb4c05de811395" |
1352 | "checksum rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7540fc8b0c49f096ee9c961cda096467dce8084bec6bdca2fc83895fd9b28cb8" | 1352 | "checksum rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7540fc8b0c49f096ee9c961cda096467dce8084bec6bdca2fc83895fd9b28cb8" |
1353 | "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" | 1353 | "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" |
diff --git a/crates/ra_analysis/src/descriptors/function/imp.rs b/crates/ra_analysis/src/descriptors/function/imp.rs index 755e05819..a989a04cd 100644 --- a/crates/ra_analysis/src/descriptors/function/imp.rs +++ b/crates/ra_analysis/src/descriptors/function/imp.rs | |||
@@ -11,11 +11,11 @@ use crate::descriptors::{ | |||
11 | /// TODO: this should return something more type-safe then `SyntaxNode` | 11 | /// TODO: this should return something more type-safe then `SyntaxNode` |
12 | pub(crate) fn fn_syntax(db: &impl DescriptorDatabase, fn_id: FnId) -> FnDefNode { | 12 | pub(crate) fn fn_syntax(db: &impl DescriptorDatabase, fn_id: FnId) -> FnDefNode { |
13 | let syntax = db.resolve_syntax_ptr(fn_id.0); | 13 | let syntax = db.resolve_syntax_ptr(fn_id.0); |
14 | FnDef::cast(syntax.borrowed()).unwrap().into() | 14 | FnDef::cast(syntax.borrowed()).unwrap().owned() |
15 | } | 15 | } |
16 | 16 | ||
17 | pub(crate) fn fn_scopes(db: &impl DescriptorDatabase, fn_id: FnId) -> Arc<FnScopes> { | 17 | pub(crate) fn fn_scopes(db: &impl DescriptorDatabase, fn_id: FnId) -> Arc<FnScopes> { |
18 | let syntax = db.fn_syntax(fn_id); | 18 | let syntax = db.fn_syntax(fn_id); |
19 | let res = FnScopes::new(syntax.ast()); | 19 | let res = FnScopes::new(syntax.borrowed()); |
20 | Arc::new(res) | 20 | Arc::new(res) |
21 | } | 21 | } |
diff --git a/crates/ra_analysis/src/descriptors/module/imp.rs b/crates/ra_analysis/src/descriptors/module/imp.rs index b3b1f1f21..b5c232ea4 100644 --- a/crates/ra_analysis/src/descriptors/module/imp.rs +++ b/crates/ra_analysis/src/descriptors/module/imp.rs | |||
@@ -41,9 +41,9 @@ pub(crate) fn submodules( | |||
41 | db::check_canceled(db)?; | 41 | db::check_canceled(db)?; |
42 | let file_id = source.file_id(); | 42 | let file_id = source.file_id(); |
43 | let submodules = match source.resolve(db) { | 43 | let submodules = match source.resolve(db) { |
44 | ModuleSourceNode::Root(it) => collect_submodules(file_id, it.ast()), | 44 | ModuleSourceNode::Root(it) => collect_submodules(file_id, it.borrowed()), |
45 | ModuleSourceNode::Inline(it) => it | 45 | ModuleSourceNode::Inline(it) => it |
46 | .ast() | 46 | .borrowed() |
47 | .item_list() | 47 | .item_list() |
48 | .map(|it| collect_submodules(file_id, it)) | 48 | .map(|it| collect_submodules(file_id, it)) |
49 | .unwrap_or_else(Vec::new), | 49 | .unwrap_or_else(Vec::new), |
@@ -89,8 +89,8 @@ pub(crate) fn module_scope( | |||
89 | let tree = db.module_tree(source_root_id)?; | 89 | let tree = db.module_tree(source_root_id)?; |
90 | let source = module_id.source(&tree).resolve(db); | 90 | let source = module_id.source(&tree).resolve(db); |
91 | let res = match source { | 91 | let res = match source { |
92 | ModuleSourceNode::Root(root) => ModuleScope::new(root.ast().items()), | 92 | ModuleSourceNode::Root(root) => ModuleScope::new(root.borrowed().items()), |
93 | ModuleSourceNode::Inline(inline) => match inline.ast().item_list() { | 93 | ModuleSourceNode::Inline(inline) => match inline.borrowed().item_list() { |
94 | Some(items) => ModuleScope::new(items.items()), | 94 | Some(items) => ModuleScope::new(items.items()), |
95 | None => ModuleScope::new(std::iter::empty()), | 95 | None => ModuleScope::new(std::iter::empty()), |
96 | }, | 96 | }, |
diff --git a/crates/ra_analysis/src/descriptors/module/mod.rs b/crates/ra_analysis/src/descriptors/module/mod.rs index 3d799ba05..03330240d 100644 --- a/crates/ra_analysis/src/descriptors/module/mod.rs +++ b/crates/ra_analysis/src/descriptors/module/mod.rs | |||
@@ -117,7 +117,7 @@ impl ModuleId { | |||
117 | .filter_map(|&it| { | 117 | .filter_map(|&it| { |
118 | let p = tree.link(it).problem.clone()?; | 118 | let p = tree.link(it).problem.clone()?; |
119 | let s = it.bind_source(tree, db); | 119 | let s = it.bind_source(tree, db); |
120 | let s = s.ast().name().unwrap().syntax().owned(); | 120 | let s = s.borrowed().name().unwrap().syntax().owned(); |
121 | Some((s, p)) | 121 | Some((s, p)) |
122 | }) | 122 | }) |
123 | .collect() | 123 | .collect() |
@@ -136,11 +136,11 @@ impl LinkId { | |||
136 | let owner = self.owner(tree); | 136 | let owner = self.owner(tree); |
137 | match owner.source(tree).resolve(db) { | 137 | match owner.source(tree).resolve(db) { |
138 | ModuleSourceNode::Root(root) => { | 138 | ModuleSourceNode::Root(root) => { |
139 | let ast = imp::modules(root.ast()) | 139 | let ast = imp::modules(root.borrowed()) |
140 | .find(|(name, _)| name == &tree.link(self).name) | 140 | .find(|(name, _)| name == &tree.link(self).name) |
141 | .unwrap() | 141 | .unwrap() |
142 | .1; | 142 | .1; |
143 | ast.into() | 143 | ast.owned() |
144 | } | 144 | } |
145 | ModuleSourceNode::Inline(it) => it, | 145 | ModuleSourceNode::Inline(it) => it, |
146 | } | 146 | } |
@@ -179,13 +179,13 @@ impl ModuleSource { | |||
179 | match self { | 179 | match self { |
180 | ModuleSource::File(file_id) => { | 180 | ModuleSource::File(file_id) => { |
181 | let syntax = db.file_syntax(file_id); | 181 | let syntax = db.file_syntax(file_id); |
182 | ModuleSourceNode::Root(syntax.ast().into()) | 182 | ModuleSourceNode::Root(syntax.ast().owned()) |
183 | } | 183 | } |
184 | ModuleSource::Inline(ptr) => { | 184 | ModuleSource::Inline(ptr) => { |
185 | let syntax = db.resolve_syntax_ptr(ptr); | 185 | let syntax = db.resolve_syntax_ptr(ptr); |
186 | let syntax = syntax.borrowed(); | 186 | let syntax = syntax.borrowed(); |
187 | let module = ast::Module::cast(syntax).unwrap(); | 187 | let module = ast::Module::cast(syntax).unwrap(); |
188 | ModuleSourceNode::Inline(module.into()) | 188 | ModuleSourceNode::Inline(module.owned()) |
189 | } | 189 | } |
190 | } | 190 | } |
191 | } | 191 | } |
diff --git a/crates/ra_analysis/src/imp.rs b/crates/ra_analysis/src/imp.rs index f2482559f..819827b95 100644 --- a/crates/ra_analysis/src/imp.rs +++ b/crates/ra_analysis/src/imp.rs | |||
@@ -236,7 +236,7 @@ impl AnalysisImpl { | |||
236 | let link = module_id.parent_link(&module_tree)?; | 236 | let link = module_id.parent_link(&module_tree)?; |
237 | let file_id = link.owner(&module_tree).source(&module_tree).file_id(); | 237 | let file_id = link.owner(&module_tree).source(&module_tree).file_id(); |
238 | let decl = link.bind_source(&module_tree, &*self.db); | 238 | let decl = link.bind_source(&module_tree, &*self.db); |
239 | let decl = decl.ast(); | 239 | let decl = decl.borrowed(); |
240 | 240 | ||
241 | let decl_name = decl.name().unwrap(); | 241 | let decl_name = decl.name().unwrap(); |
242 | 242 | ||
diff --git a/crates/ra_syntax/Cargo.toml b/crates/ra_syntax/Cargo.toml index 0f709026f..54ee72386 100644 --- a/crates/ra_syntax/Cargo.toml +++ b/crates/ra_syntax/Cargo.toml | |||
@@ -13,7 +13,7 @@ unicode-xid = "0.1.0" | |||
13 | itertools = "0.7.8" | 13 | itertools = "0.7.8" |
14 | drop_bomb = "0.1.4" | 14 | drop_bomb = "0.1.4" |
15 | parking_lot = "0.6.0" | 15 | parking_lot = "0.6.0" |
16 | rowan = "0.1.1" | 16 | rowan = "0.1.2" |
17 | text_unit = "0.1.5" | 17 | text_unit = "0.1.5" |
18 | 18 | ||
19 | [dev-dependencies] | 19 | [dev-dependencies] |
diff --git a/crates/ra_syntax/src/algo/mod.rs b/crates/ra_syntax/src/algo/mod.rs index faf5a6211..4b3548ea9 100644 --- a/crates/ra_syntax/src/algo/mod.rs +++ b/crates/ra_syntax/src/algo/mod.rs | |||
@@ -1,116 +1,19 @@ | |||
1 | pub mod visit; | 1 | pub mod visit; |
2 | // pub mod walk; | ||
3 | 2 | ||
4 | use crate::{text_utils::contains_offset_nonstrict, SyntaxNodeRef, TextRange, TextUnit}; | 3 | use crate::{SyntaxNode, SyntaxNodeRef, TextRange, TextUnit}; |
5 | 4 | ||
6 | pub fn find_leaf_at_offset(node: SyntaxNodeRef, offset: TextUnit) -> LeafAtOffset { | 5 | pub use rowan::LeafAtOffset; |
7 | let range = node.range(); | ||
8 | assert!( | ||
9 | contains_offset_nonstrict(range, offset), | ||
10 | "Bad offset: range {:?} offset {:?}", | ||
11 | range, | ||
12 | offset | ||
13 | ); | ||
14 | if range.is_empty() { | ||
15 | return LeafAtOffset::None; | ||
16 | } | ||
17 | |||
18 | if node.is_leaf() { | ||
19 | return LeafAtOffset::Single(node); | ||
20 | } | ||
21 | |||
22 | let mut children = node.children().filter(|child| { | ||
23 | let child_range = child.range(); | ||
24 | !child_range.is_empty() && contains_offset_nonstrict(child_range, offset) | ||
25 | }); | ||
26 | |||
27 | let left = children.next().unwrap(); | ||
28 | let right = children.next(); | ||
29 | assert!(children.next().is_none()); | ||
30 | |||
31 | if let Some(right) = right { | ||
32 | match ( | ||
33 | find_leaf_at_offset(left, offset), | ||
34 | find_leaf_at_offset(right, offset), | ||
35 | ) { | ||
36 | (LeafAtOffset::Single(left), LeafAtOffset::Single(right)) => { | ||
37 | LeafAtOffset::Between(left, right) | ||
38 | } | ||
39 | _ => unreachable!(), | ||
40 | } | ||
41 | } else { | ||
42 | find_leaf_at_offset(left, offset) | ||
43 | } | ||
44 | } | ||
45 | |||
46 | #[derive(Clone, Debug)] | ||
47 | pub enum LeafAtOffset<'a> { | ||
48 | None, | ||
49 | Single(SyntaxNodeRef<'a>), | ||
50 | Between(SyntaxNodeRef<'a>, SyntaxNodeRef<'a>), | ||
51 | } | ||
52 | 6 | ||
53 | impl<'a> LeafAtOffset<'a> { | 7 | pub fn find_leaf_at_offset(node: SyntaxNodeRef, offset: TextUnit) -> LeafAtOffset<SyntaxNodeRef> { |
54 | pub fn right_biased(self) -> Option<SyntaxNodeRef<'a>> { | 8 | match node.0.leaf_at_offset(offset) { |
55 | match self { | 9 | LeafAtOffset::None => LeafAtOffset::None, |
56 | LeafAtOffset::None => None, | 10 | LeafAtOffset::Single(n) => LeafAtOffset::Single(SyntaxNode(n)), |
57 | LeafAtOffset::Single(node) => Some(node), | 11 | LeafAtOffset::Between(l, r) => LeafAtOffset::Between(SyntaxNode(l), SyntaxNode(r)), |
58 | LeafAtOffset::Between(_, right) => Some(right), | ||
59 | } | ||
60 | } | ||
61 | |||
62 | pub fn left_biased(self) -> Option<SyntaxNodeRef<'a>> { | ||
63 | match self { | ||
64 | LeafAtOffset::None => None, | ||
65 | LeafAtOffset::Single(node) => Some(node), | ||
66 | LeafAtOffset::Between(left, _) => Some(left), | ||
67 | } | ||
68 | } | ||
69 | } | ||
70 | |||
71 | impl<'f> Iterator for LeafAtOffset<'f> { | ||
72 | type Item = SyntaxNodeRef<'f>; | ||
73 | |||
74 | fn next(&mut self) -> Option<SyntaxNodeRef<'f>> { | ||
75 | match *self { | ||
76 | LeafAtOffset::None => None, | ||
77 | LeafAtOffset::Single(node) => { | ||
78 | *self = LeafAtOffset::None; | ||
79 | Some(node) | ||
80 | } | ||
81 | LeafAtOffset::Between(left, right) => { | ||
82 | *self = LeafAtOffset::Single(right); | ||
83 | Some(left) | ||
84 | } | ||
85 | } | ||
86 | } | 12 | } |
87 | } | 13 | } |
88 | 14 | ||
89 | pub fn find_covering_node(root: SyntaxNodeRef, range: TextRange) -> SyntaxNodeRef { | 15 | pub fn find_covering_node(root: SyntaxNodeRef, range: TextRange) -> SyntaxNodeRef { |
90 | assert!( | 16 | SyntaxNode(root.0.covering_node(range)) |
91 | range.is_subrange(&root.range()), | ||
92 | "node range: {:?}, target range: {:?}", | ||
93 | root.range(), | ||
94 | range, | ||
95 | ); | ||
96 | let (left, right) = match ( | ||
97 | find_leaf_at_offset(root, range.start()).right_biased(), | ||
98 | find_leaf_at_offset(root, range.end()).left_biased(), | ||
99 | ) { | ||
100 | (Some(l), Some(r)) => (l, r), | ||
101 | _ => return root, | ||
102 | }; | ||
103 | |||
104 | common_ancestor(left, right) | ||
105 | } | ||
106 | |||
107 | fn common_ancestor<'a>(n1: SyntaxNodeRef<'a>, n2: SyntaxNodeRef<'a>) -> SyntaxNodeRef<'a> { | ||
108 | for p in n1.ancestors() { | ||
109 | if n2.ancestors().any(|a| a == p) { | ||
110 | return p; | ||
111 | } | ||
112 | } | ||
113 | panic!("Can't find common ancestor of {:?} and {:?}", n1, n2) | ||
114 | } | 17 | } |
115 | 18 | ||
116 | pub fn generate<T>(seed: Option<T>, step: impl Fn(&T) -> Option<T>) -> impl Iterator<Item = T> { | 19 | pub fn generate<T>(seed: Option<T>, step: impl Fn(&T) -> Option<T>) -> impl Iterator<Item = T> { |
diff --git a/crates/ra_syntax/src/ast/generated.rs b/crates/ra_syntax/src/ast/generated.rs index 75769a4e9..3878c99a8 100644 --- a/crates/ra_syntax/src/ast/generated.rs +++ b/crates/ra_syntax/src/ast/generated.rs | |||
@@ -1,34 +1,36 @@ | |||
1 | // This file is automatically generated based on the file `./generated.rs.tera` when `cargo gen-syntax` is run | 1 | // This file is automatically generated based on the file `./generated.rs.tera` when `cargo gen-syntax` is run |
2 | // Do not edit manually | 2 | // Do not edit manually |
3 | 3 | ||
4 | //! This module contains auto-generated Rust AST. Like `SyntaxNode`s, AST nodes | ||
5 | //! are generic over ownership: `X<'a>` things are `Copy` references, `XNode` | ||
6 | //! are Arc-based. You can switch between the two variants using `.owned` and | ||
7 | //! `.borrowed` functions. Most of the code works with borowed mode, and only | ||
8 | //! this mode has all AST accessors. | ||
9 | |||
4 | #![cfg_attr(rustfmt, rustfmt_skip)] | 10 | #![cfg_attr(rustfmt, rustfmt_skip)] |
5 | 11 | ||
12 | use std::hash::{Hash, Hasher}; | ||
13 | |||
6 | use crate::{ | 14 | use crate::{ |
7 | ast, | 15 | ast, |
8 | SyntaxNode, SyntaxNodeRef, AstNode, | 16 | SyntaxNode, SyntaxNodeRef, AstNode, |
17 | yellow::{TreeRoot, RaTypes, OwnedRoot, RefRoot}, | ||
9 | SyntaxKind::*, | 18 | SyntaxKind::*, |
10 | }; | 19 | }; |
11 | 20 | ||
12 | // ArgList | 21 | // ArgList |
13 | 22 | #[derive(Debug, Clone, Copy,)] | |
14 | #[derive(Debug, Clone)] | 23 | pub struct ArgListNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
15 | pub struct ArgListNode(SyntaxNode); | 24 | pub(crate) syntax: SyntaxNode<R>, |
16 | |||
17 | impl ArgListNode { | ||
18 | pub fn ast(&self) -> ArgList { | ||
19 | ArgList::cast(self.0.borrowed()).unwrap() | ||
20 | } | ||
21 | } | 25 | } |
26 | pub type ArgList<'a> = ArgListNode<RefRoot<'a>>; | ||
22 | 27 | ||
23 | impl<'a> From<ArgList<'a>> for ArgListNode { | 28 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<ArgListNode<R1>> for ArgListNode<R2> { |
24 | fn from(ast: ArgList<'a>) -> ArgListNode { | 29 | fn eq(&self, other: &ArgListNode<R1>) -> bool { self.syntax == other.syntax } |
25 | let syntax = ast.syntax().owned(); | ||
26 | ArgListNode(syntax) | ||
27 | } | ||
28 | } | 30 | } |
29 | #[derive(Debug, Clone, Copy)] | 31 | impl<R: TreeRoot<RaTypes>> Eq for ArgListNode<R> {} |
30 | pub struct ArgList<'a> { | 32 | impl<R: TreeRoot<RaTypes>> Hash for ArgListNode<R> { |
31 | syntax: SyntaxNodeRef<'a>, | 33 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } |
32 | } | 34 | } |
33 | 35 | ||
34 | impl<'a> AstNode<'a> for ArgList<'a> { | 36 | impl<'a> AstNode<'a> for ArgList<'a> { |
@@ -41,6 +43,16 @@ impl<'a> AstNode<'a> for ArgList<'a> { | |||
41 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 43 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
42 | } | 44 | } |
43 | 45 | ||
46 | impl<R: TreeRoot<RaTypes>> ArgListNode<R> { | ||
47 | pub fn borrowed(&self) -> ArgList { | ||
48 | ArgListNode { syntax: self.syntax.borrowed() } | ||
49 | } | ||
50 | pub fn owned(&self) -> ArgListNode { | ||
51 | ArgListNode { syntax: self.syntax.owned() } | ||
52 | } | ||
53 | } | ||
54 | |||
55 | |||
44 | impl<'a> ArgList<'a> { | 56 | impl<'a> ArgList<'a> { |
45 | pub fn args(self) -> impl Iterator<Item = Expr<'a>> + 'a { | 57 | pub fn args(self) -> impl Iterator<Item = Expr<'a>> + 'a { |
46 | super::children(self) | 58 | super::children(self) |
@@ -48,25 +60,18 @@ impl<'a> ArgList<'a> { | |||
48 | } | 60 | } |
49 | 61 | ||
50 | // ArrayExpr | 62 | // ArrayExpr |
51 | 63 | #[derive(Debug, Clone, Copy,)] | |
52 | #[derive(Debug, Clone)] | 64 | pub struct ArrayExprNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
53 | pub struct ArrayExprNode(SyntaxNode); | 65 | pub(crate) syntax: SyntaxNode<R>, |
54 | |||
55 | impl ArrayExprNode { | ||
56 | pub fn ast(&self) -> ArrayExpr { | ||
57 | ArrayExpr::cast(self.0.borrowed()).unwrap() | ||
58 | } | ||
59 | } | 66 | } |
67 | pub type ArrayExpr<'a> = ArrayExprNode<RefRoot<'a>>; | ||
60 | 68 | ||
61 | impl<'a> From<ArrayExpr<'a>> for ArrayExprNode { | 69 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<ArrayExprNode<R1>> for ArrayExprNode<R2> { |
62 | fn from(ast: ArrayExpr<'a>) -> ArrayExprNode { | 70 | fn eq(&self, other: &ArrayExprNode<R1>) -> bool { self.syntax == other.syntax } |
63 | let syntax = ast.syntax().owned(); | ||
64 | ArrayExprNode(syntax) | ||
65 | } | ||
66 | } | 71 | } |
67 | #[derive(Debug, Clone, Copy)] | 72 | impl<R: TreeRoot<RaTypes>> Eq for ArrayExprNode<R> {} |
68 | pub struct ArrayExpr<'a> { | 73 | impl<R: TreeRoot<RaTypes>> Hash for ArrayExprNode<R> { |
69 | syntax: SyntaxNodeRef<'a>, | 74 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } |
70 | } | 75 | } |
71 | 76 | ||
72 | impl<'a> AstNode<'a> for ArrayExpr<'a> { | 77 | impl<'a> AstNode<'a> for ArrayExpr<'a> { |
@@ -79,28 +84,31 @@ impl<'a> AstNode<'a> for ArrayExpr<'a> { | |||
79 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 84 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
80 | } | 85 | } |
81 | 86 | ||
82 | impl<'a> ArrayExpr<'a> {} | 87 | impl<R: TreeRoot<RaTypes>> ArrayExprNode<R> { |
88 | pub fn borrowed(&self) -> ArrayExpr { | ||
89 | ArrayExprNode { syntax: self.syntax.borrowed() } | ||
90 | } | ||
91 | pub fn owned(&self) -> ArrayExprNode { | ||
92 | ArrayExprNode { syntax: self.syntax.owned() } | ||
93 | } | ||
94 | } | ||
83 | 95 | ||
84 | // ArrayType | ||
85 | 96 | ||
86 | #[derive(Debug, Clone)] | 97 | impl<'a> ArrayExpr<'a> {} |
87 | pub struct ArrayTypeNode(SyntaxNode); | ||
88 | 98 | ||
89 | impl ArrayTypeNode { | 99 | // ArrayType |
90 | pub fn ast(&self) -> ArrayType { | 100 | #[derive(Debug, Clone, Copy,)] |
91 | ArrayType::cast(self.0.borrowed()).unwrap() | 101 | pub struct ArrayTypeNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
92 | } | 102 | pub(crate) syntax: SyntaxNode<R>, |
93 | } | 103 | } |
104 | pub type ArrayType<'a> = ArrayTypeNode<RefRoot<'a>>; | ||
94 | 105 | ||
95 | impl<'a> From<ArrayType<'a>> for ArrayTypeNode { | 106 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<ArrayTypeNode<R1>> for ArrayTypeNode<R2> { |
96 | fn from(ast: ArrayType<'a>) -> ArrayTypeNode { | 107 | fn eq(&self, other: &ArrayTypeNode<R1>) -> bool { self.syntax == other.syntax } |
97 | let syntax = ast.syntax().owned(); | ||
98 | ArrayTypeNode(syntax) | ||
99 | } | ||
100 | } | 108 | } |
101 | #[derive(Debug, Clone, Copy)] | 109 | impl<R: TreeRoot<RaTypes>> Eq for ArrayTypeNode<R> {} |
102 | pub struct ArrayType<'a> { | 110 | impl<R: TreeRoot<RaTypes>> Hash for ArrayTypeNode<R> { |
103 | syntax: SyntaxNodeRef<'a>, | 111 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } |
104 | } | 112 | } |
105 | 113 | ||
106 | impl<'a> AstNode<'a> for ArrayType<'a> { | 114 | impl<'a> AstNode<'a> for ArrayType<'a> { |
@@ -113,28 +121,31 @@ impl<'a> AstNode<'a> for ArrayType<'a> { | |||
113 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 121 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
114 | } | 122 | } |
115 | 123 | ||
116 | impl<'a> ArrayType<'a> {} | 124 | impl<R: TreeRoot<RaTypes>> ArrayTypeNode<R> { |
125 | pub fn borrowed(&self) -> ArrayType { | ||
126 | ArrayTypeNode { syntax: self.syntax.borrowed() } | ||
127 | } | ||
128 | pub fn owned(&self) -> ArrayTypeNode { | ||
129 | ArrayTypeNode { syntax: self.syntax.owned() } | ||
130 | } | ||
131 | } | ||
117 | 132 | ||
118 | // Attr | ||
119 | 133 | ||
120 | #[derive(Debug, Clone)] | 134 | impl<'a> ArrayType<'a> {} |
121 | pub struct AttrNode(SyntaxNode); | ||
122 | 135 | ||
123 | impl AttrNode { | 136 | // Attr |
124 | pub fn ast(&self) -> Attr { | 137 | #[derive(Debug, Clone, Copy,)] |
125 | Attr::cast(self.0.borrowed()).unwrap() | 138 | pub struct AttrNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
126 | } | 139 | pub(crate) syntax: SyntaxNode<R>, |
127 | } | 140 | } |
141 | pub type Attr<'a> = AttrNode<RefRoot<'a>>; | ||
128 | 142 | ||
129 | impl<'a> From<Attr<'a>> for AttrNode { | 143 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<AttrNode<R1>> for AttrNode<R2> { |
130 | fn from(ast: Attr<'a>) -> AttrNode { | 144 | fn eq(&self, other: &AttrNode<R1>) -> bool { self.syntax == other.syntax } |
131 | let syntax = ast.syntax().owned(); | ||
132 | AttrNode(syntax) | ||
133 | } | ||
134 | } | 145 | } |
135 | #[derive(Debug, Clone, Copy)] | 146 | impl<R: TreeRoot<RaTypes>> Eq for AttrNode<R> {} |
136 | pub struct Attr<'a> { | 147 | impl<R: TreeRoot<RaTypes>> Hash for AttrNode<R> { |
137 | syntax: SyntaxNodeRef<'a>, | 148 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } |
138 | } | 149 | } |
139 | 150 | ||
140 | impl<'a> AstNode<'a> for Attr<'a> { | 151 | impl<'a> AstNode<'a> for Attr<'a> { |
@@ -147,6 +158,16 @@ impl<'a> AstNode<'a> for Attr<'a> { | |||
147 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 158 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
148 | } | 159 | } |
149 | 160 | ||
161 | impl<R: TreeRoot<RaTypes>> AttrNode<R> { | ||
162 | pub fn borrowed(&self) -> Attr { | ||
163 | AttrNode { syntax: self.syntax.borrowed() } | ||
164 | } | ||
165 | pub fn owned(&self) -> AttrNode { | ||
166 | AttrNode { syntax: self.syntax.owned() } | ||
167 | } | ||
168 | } | ||
169 | |||
170 | |||
150 | impl<'a> Attr<'a> { | 171 | impl<'a> Attr<'a> { |
151 | pub fn value(self) -> Option<TokenTree<'a>> { | 172 | pub fn value(self) -> Option<TokenTree<'a>> { |
152 | super::child_opt(self) | 173 | super::child_opt(self) |
@@ -154,25 +175,18 @@ impl<'a> Attr<'a> { | |||
154 | } | 175 | } |
155 | 176 | ||
156 | // BinExpr | 177 | // BinExpr |
157 | 178 | #[derive(Debug, Clone, Copy,)] | |
158 | #[derive(Debug, Clone)] | 179 | pub struct BinExprNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
159 | pub struct BinExprNode(SyntaxNode); | 180 | pub(crate) syntax: SyntaxNode<R>, |
160 | |||
161 | impl BinExprNode { | ||
162 | pub fn ast(&self) -> BinExpr { | ||
163 | BinExpr::cast(self.0.borrowed()).unwrap() | ||
164 | } | ||
165 | } | 181 | } |
182 | pub type BinExpr<'a> = BinExprNode<RefRoot<'a>>; | ||
166 | 183 | ||
167 | impl<'a> From<BinExpr<'a>> for BinExprNode { | 184 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<BinExprNode<R1>> for BinExprNode<R2> { |
168 | fn from(ast: BinExpr<'a>) -> BinExprNode { | 185 | fn eq(&self, other: &BinExprNode<R1>) -> bool { self.syntax == other.syntax } |
169 | let syntax = ast.syntax().owned(); | ||
170 | BinExprNode(syntax) | ||
171 | } | ||
172 | } | 186 | } |
173 | #[derive(Debug, Clone, Copy)] | 187 | impl<R: TreeRoot<RaTypes>> Eq for BinExprNode<R> {} |
174 | pub struct BinExpr<'a> { | 188 | impl<R: TreeRoot<RaTypes>> Hash for BinExprNode<R> { |
175 | syntax: SyntaxNodeRef<'a>, | 189 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } |
176 | } | 190 | } |
177 | 191 | ||
178 | impl<'a> AstNode<'a> for BinExpr<'a> { | 192 | impl<'a> AstNode<'a> for BinExpr<'a> { |
@@ -185,28 +199,31 @@ impl<'a> AstNode<'a> for BinExpr<'a> { | |||
185 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 199 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
186 | } | 200 | } |
187 | 201 | ||
188 | impl<'a> BinExpr<'a> {} | 202 | impl<R: TreeRoot<RaTypes>> BinExprNode<R> { |
203 | pub fn borrowed(&self) -> BinExpr { | ||
204 | BinExprNode { syntax: self.syntax.borrowed() } | ||
205 | } | ||
206 | pub fn owned(&self) -> BinExprNode { | ||
207 | BinExprNode { syntax: self.syntax.owned() } | ||
208 | } | ||
209 | } | ||
189 | 210 | ||
190 | // BindPat | ||
191 | 211 | ||
192 | #[derive(Debug, Clone)] | 212 | impl<'a> BinExpr<'a> {} |
193 | pub struct BindPatNode(SyntaxNode); | ||
194 | 213 | ||
195 | impl BindPatNode { | 214 | // BindPat |
196 | pub fn ast(&self) -> BindPat { | 215 | #[derive(Debug, Clone, Copy,)] |
197 | BindPat::cast(self.0.borrowed()).unwrap() | 216 | pub struct BindPatNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
198 | } | 217 | pub(crate) syntax: SyntaxNode<R>, |
199 | } | 218 | } |
219 | pub type BindPat<'a> = BindPatNode<RefRoot<'a>>; | ||
200 | 220 | ||
201 | impl<'a> From<BindPat<'a>> for BindPatNode { | 221 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<BindPatNode<R1>> for BindPatNode<R2> { |
202 | fn from(ast: BindPat<'a>) -> BindPatNode { | 222 | fn eq(&self, other: &BindPatNode<R1>) -> bool { self.syntax == other.syntax } |
203 | let syntax = ast.syntax().owned(); | ||
204 | BindPatNode(syntax) | ||
205 | } | ||
206 | } | 223 | } |
207 | #[derive(Debug, Clone, Copy)] | 224 | impl<R: TreeRoot<RaTypes>> Eq for BindPatNode<R> {} |
208 | pub struct BindPat<'a> { | 225 | impl<R: TreeRoot<RaTypes>> Hash for BindPatNode<R> { |
209 | syntax: SyntaxNodeRef<'a>, | 226 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } |
210 | } | 227 | } |
211 | 228 | ||
212 | impl<'a> AstNode<'a> for BindPat<'a> { | 229 | impl<'a> AstNode<'a> for BindPat<'a> { |
@@ -219,29 +236,32 @@ impl<'a> AstNode<'a> for BindPat<'a> { | |||
219 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 236 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
220 | } | 237 | } |
221 | 238 | ||
239 | impl<R: TreeRoot<RaTypes>> BindPatNode<R> { | ||
240 | pub fn borrowed(&self) -> BindPat { | ||
241 | BindPatNode { syntax: self.syntax.borrowed() } | ||
242 | } | ||
243 | pub fn owned(&self) -> BindPatNode { | ||
244 | BindPatNode { syntax: self.syntax.owned() } | ||
245 | } | ||
246 | } | ||
247 | |||
248 | |||
222 | impl<'a> ast::NameOwner<'a> for BindPat<'a> {} | 249 | impl<'a> ast::NameOwner<'a> for BindPat<'a> {} |
223 | impl<'a> BindPat<'a> {} | 250 | impl<'a> BindPat<'a> {} |
224 | 251 | ||
225 | // Block | 252 | // Block |
226 | 253 | #[derive(Debug, Clone, Copy,)] | |
227 | #[derive(Debug, Clone)] | 254 | pub struct BlockNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
228 | pub struct BlockNode(SyntaxNode); | 255 | pub(crate) syntax: SyntaxNode<R>, |
229 | |||
230 | impl BlockNode { | ||
231 | pub fn ast(&self) -> Block { | ||
232 | Block::cast(self.0.borrowed()).unwrap() | ||
233 | } | ||
234 | } | 256 | } |
257 | pub type Block<'a> = BlockNode<RefRoot<'a>>; | ||
235 | 258 | ||
236 | impl<'a> From<Block<'a>> for BlockNode { | 259 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<BlockNode<R1>> for BlockNode<R2> { |
237 | fn from(ast: Block<'a>) -> BlockNode { | 260 | fn eq(&self, other: &BlockNode<R1>) -> bool { self.syntax == other.syntax } |
238 | let syntax = ast.syntax().owned(); | ||
239 | BlockNode(syntax) | ||
240 | } | ||
241 | } | 261 | } |
242 | #[derive(Debug, Clone, Copy)] | 262 | impl<R: TreeRoot<RaTypes>> Eq for BlockNode<R> {} |
243 | pub struct Block<'a> { | 263 | impl<R: TreeRoot<RaTypes>> Hash for BlockNode<R> { |
244 | syntax: SyntaxNodeRef<'a>, | 264 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } |
245 | } | 265 | } |
246 | 266 | ||
247 | impl<'a> AstNode<'a> for Block<'a> { | 267 | impl<'a> AstNode<'a> for Block<'a> { |
@@ -254,6 +274,16 @@ impl<'a> AstNode<'a> for Block<'a> { | |||
254 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 274 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
255 | } | 275 | } |
256 | 276 | ||
277 | impl<R: TreeRoot<RaTypes>> BlockNode<R> { | ||
278 | pub fn borrowed(&self) -> Block { | ||
279 | BlockNode { syntax: self.syntax.borrowed() } | ||
280 | } | ||
281 | pub fn owned(&self) -> BlockNode { | ||
282 | BlockNode { syntax: self.syntax.owned() } | ||
283 | } | ||
284 | } | ||
285 | |||
286 | |||
257 | impl<'a> Block<'a> { | 287 | impl<'a> Block<'a> { |
258 | pub fn statements(self) -> impl Iterator<Item = Stmt<'a>> + 'a { | 288 | pub fn statements(self) -> impl Iterator<Item = Stmt<'a>> + 'a { |
259 | super::children(self) | 289 | super::children(self) |
@@ -265,25 +295,18 @@ impl<'a> Block<'a> { | |||
265 | } | 295 | } |
266 | 296 | ||
267 | // BlockExpr | 297 | // BlockExpr |
268 | 298 | #[derive(Debug, Clone, Copy,)] | |
269 | #[derive(Debug, Clone)] | 299 | pub struct BlockExprNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
270 | pub struct BlockExprNode(SyntaxNode); | 300 | pub(crate) syntax: SyntaxNode<R>, |
271 | |||
272 | impl BlockExprNode { | ||
273 | pub fn ast(&self) -> BlockExpr { | ||
274 | BlockExpr::cast(self.0.borrowed()).unwrap() | ||
275 | } | ||
276 | } | 301 | } |
302 | pub type BlockExpr<'a> = BlockExprNode<RefRoot<'a>>; | ||
277 | 303 | ||
278 | impl<'a> From<BlockExpr<'a>> for BlockExprNode { | 304 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<BlockExprNode<R1>> for BlockExprNode<R2> { |
279 | fn from(ast: BlockExpr<'a>) -> BlockExprNode { | 305 | fn eq(&self, other: &BlockExprNode<R1>) -> bool { self.syntax == other.syntax } |
280 | let syntax = ast.syntax().owned(); | ||
281 | BlockExprNode(syntax) | ||
282 | } | ||
283 | } | 306 | } |
284 | #[derive(Debug, Clone, Copy)] | 307 | impl<R: TreeRoot<RaTypes>> Eq for BlockExprNode<R> {} |
285 | pub struct BlockExpr<'a> { | 308 | impl<R: TreeRoot<RaTypes>> Hash for BlockExprNode<R> { |
286 | syntax: SyntaxNodeRef<'a>, | 309 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } |
287 | } | 310 | } |
288 | 311 | ||
289 | impl<'a> AstNode<'a> for BlockExpr<'a> { | 312 | impl<'a> AstNode<'a> for BlockExpr<'a> { |
@@ -296,6 +319,16 @@ impl<'a> AstNode<'a> for BlockExpr<'a> { | |||
296 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 319 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
297 | } | 320 | } |
298 | 321 | ||
322 | impl<R: TreeRoot<RaTypes>> BlockExprNode<R> { | ||
323 | pub fn borrowed(&self) -> BlockExpr { | ||
324 | BlockExprNode { syntax: self.syntax.borrowed() } | ||
325 | } | ||
326 | pub fn owned(&self) -> BlockExprNode { | ||
327 | BlockExprNode { syntax: self.syntax.owned() } | ||
328 | } | ||
329 | } | ||
330 | |||
331 | |||
299 | impl<'a> BlockExpr<'a> { | 332 | impl<'a> BlockExpr<'a> { |
300 | pub fn block(self) -> Option<Block<'a>> { | 333 | pub fn block(self) -> Option<Block<'a>> { |
301 | super::child_opt(self) | 334 | super::child_opt(self) |
@@ -303,25 +336,18 @@ impl<'a> BlockExpr<'a> { | |||
303 | } | 336 | } |
304 | 337 | ||
305 | // BreakExpr | 338 | // BreakExpr |
306 | 339 | #[derive(Debug, Clone, Copy,)] | |
307 | #[derive(Debug, Clone)] | 340 | pub struct BreakExprNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
308 | pub struct BreakExprNode(SyntaxNode); | 341 | pub(crate) syntax: SyntaxNode<R>, |
309 | |||
310 | impl BreakExprNode { | ||
311 | pub fn ast(&self) -> BreakExpr { | ||
312 | BreakExpr::cast(self.0.borrowed()).unwrap() | ||
313 | } | ||
314 | } | 342 | } |
343 | pub type BreakExpr<'a> = BreakExprNode<RefRoot<'a>>; | ||
315 | 344 | ||
316 | impl<'a> From<BreakExpr<'a>> for BreakExprNode { | 345 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<BreakExprNode<R1>> for BreakExprNode<R2> { |
317 | fn from(ast: BreakExpr<'a>) -> BreakExprNode { | 346 | fn eq(&self, other: &BreakExprNode<R1>) -> bool { self.syntax == other.syntax } |
318 | let syntax = ast.syntax().owned(); | ||
319 | BreakExprNode(syntax) | ||
320 | } | ||
321 | } | 347 | } |
322 | #[derive(Debug, Clone, Copy)] | 348 | impl<R: TreeRoot<RaTypes>> Eq for BreakExprNode<R> {} |
323 | pub struct BreakExpr<'a> { | 349 | impl<R: TreeRoot<RaTypes>> Hash for BreakExprNode<R> { |
324 | syntax: SyntaxNodeRef<'a>, | 350 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } |
325 | } | 351 | } |
326 | 352 | ||
327 | impl<'a> AstNode<'a> for BreakExpr<'a> { | 353 | impl<'a> AstNode<'a> for BreakExpr<'a> { |
@@ -334,28 +360,31 @@ impl<'a> AstNode<'a> for BreakExpr<'a> { | |||
334 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 360 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
335 | } | 361 | } |
336 | 362 | ||
337 | impl<'a> BreakExpr<'a> {} | 363 | impl<R: TreeRoot<RaTypes>> BreakExprNode<R> { |
364 | pub fn borrowed(&self) -> BreakExpr { | ||
365 | BreakExprNode { syntax: self.syntax.borrowed() } | ||
366 | } | ||
367 | pub fn owned(&self) -> BreakExprNode { | ||
368 | BreakExprNode { syntax: self.syntax.owned() } | ||
369 | } | ||
370 | } | ||
338 | 371 | ||
339 | // CallExpr | ||
340 | 372 | ||
341 | #[derive(Debug, Clone)] | 373 | impl<'a> BreakExpr<'a> {} |
342 | pub struct CallExprNode(SyntaxNode); | ||
343 | 374 | ||
344 | impl CallExprNode { | 375 | // CallExpr |
345 | pub fn ast(&self) -> CallExpr { | 376 | #[derive(Debug, Clone, Copy,)] |
346 | CallExpr::cast(self.0.borrowed()).unwrap() | 377 | pub struct CallExprNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
347 | } | 378 | pub(crate) syntax: SyntaxNode<R>, |
348 | } | 379 | } |
380 | pub type CallExpr<'a> = CallExprNode<RefRoot<'a>>; | ||
349 | 381 | ||
350 | impl<'a> From<CallExpr<'a>> for CallExprNode { | 382 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<CallExprNode<R1>> for CallExprNode<R2> { |
351 | fn from(ast: CallExpr<'a>) -> CallExprNode { | 383 | fn eq(&self, other: &CallExprNode<R1>) -> bool { self.syntax == other.syntax } |
352 | let syntax = ast.syntax().owned(); | ||
353 | CallExprNode(syntax) | ||
354 | } | ||
355 | } | 384 | } |
356 | #[derive(Debug, Clone, Copy)] | 385 | impl<R: TreeRoot<RaTypes>> Eq for CallExprNode<R> {} |
357 | pub struct CallExpr<'a> { | 386 | impl<R: TreeRoot<RaTypes>> Hash for CallExprNode<R> { |
358 | syntax: SyntaxNodeRef<'a>, | 387 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } |
359 | } | 388 | } |
360 | 389 | ||
361 | impl<'a> AstNode<'a> for CallExpr<'a> { | 390 | impl<'a> AstNode<'a> for CallExpr<'a> { |
@@ -368,6 +397,16 @@ impl<'a> AstNode<'a> for CallExpr<'a> { | |||
368 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 397 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
369 | } | 398 | } |
370 | 399 | ||
400 | impl<R: TreeRoot<RaTypes>> CallExprNode<R> { | ||
401 | pub fn borrowed(&self) -> CallExpr { | ||
402 | CallExprNode { syntax: self.syntax.borrowed() } | ||
403 | } | ||
404 | pub fn owned(&self) -> CallExprNode { | ||
405 | CallExprNode { syntax: self.syntax.owned() } | ||
406 | } | ||
407 | } | ||
408 | |||
409 | |||
371 | impl<'a> ast::ArgListOwner<'a> for CallExpr<'a> {} | 410 | impl<'a> ast::ArgListOwner<'a> for CallExpr<'a> {} |
372 | impl<'a> CallExpr<'a> { | 411 | impl<'a> CallExpr<'a> { |
373 | pub fn expr(self) -> Option<Expr<'a>> { | 412 | pub fn expr(self) -> Option<Expr<'a>> { |
@@ -376,25 +415,18 @@ impl<'a> CallExpr<'a> { | |||
376 | } | 415 | } |
377 | 416 | ||
378 | // CastExpr | 417 | // CastExpr |
379 | 418 | #[derive(Debug, Clone, Copy,)] | |
380 | #[derive(Debug, Clone)] | 419 | pub struct CastExprNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
381 | pub struct CastExprNode(SyntaxNode); | 420 | pub(crate) syntax: SyntaxNode<R>, |
382 | |||
383 | impl CastExprNode { | ||
384 | pub fn ast(&self) -> CastExpr { | ||
385 | CastExpr::cast(self.0.borrowed()).unwrap() | ||
386 | } | ||
387 | } | 421 | } |
422 | pub type CastExpr<'a> = CastExprNode<RefRoot<'a>>; | ||
388 | 423 | ||
389 | impl<'a> From<CastExpr<'a>> for CastExprNode { | 424 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<CastExprNode<R1>> for CastExprNode<R2> { |
390 | fn from(ast: CastExpr<'a>) -> CastExprNode { | 425 | fn eq(&self, other: &CastExprNode<R1>) -> bool { self.syntax == other.syntax } |
391 | let syntax = ast.syntax().owned(); | ||
392 | CastExprNode(syntax) | ||
393 | } | ||
394 | } | 426 | } |
395 | #[derive(Debug, Clone, Copy)] | 427 | impl<R: TreeRoot<RaTypes>> Eq for CastExprNode<R> {} |
396 | pub struct CastExpr<'a> { | 428 | impl<R: TreeRoot<RaTypes>> Hash for CastExprNode<R> { |
397 | syntax: SyntaxNodeRef<'a>, | 429 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } |
398 | } | 430 | } |
399 | 431 | ||
400 | impl<'a> AstNode<'a> for CastExpr<'a> { | 432 | impl<'a> AstNode<'a> for CastExpr<'a> { |
@@ -407,28 +439,31 @@ impl<'a> AstNode<'a> for CastExpr<'a> { | |||
407 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 439 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
408 | } | 440 | } |
409 | 441 | ||
410 | impl<'a> CastExpr<'a> {} | 442 | impl<R: TreeRoot<RaTypes>> CastExprNode<R> { |
443 | pub fn borrowed(&self) -> CastExpr { | ||
444 | CastExprNode { syntax: self.syntax.borrowed() } | ||
445 | } | ||
446 | pub fn owned(&self) -> CastExprNode { | ||
447 | CastExprNode { syntax: self.syntax.owned() } | ||
448 | } | ||
449 | } | ||
411 | 450 | ||
412 | // Char | ||
413 | 451 | ||
414 | #[derive(Debug, Clone)] | 452 | impl<'a> CastExpr<'a> {} |
415 | pub struct CharNode(SyntaxNode); | ||
416 | 453 | ||
417 | impl CharNode { | 454 | // Char |
418 | pub fn ast(&self) -> Char { | 455 | #[derive(Debug, Clone, Copy,)] |
419 | Char::cast(self.0.borrowed()).unwrap() | 456 | pub struct CharNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
420 | } | 457 | pub(crate) syntax: SyntaxNode<R>, |
421 | } | 458 | } |
459 | pub type Char<'a> = CharNode<RefRoot<'a>>; | ||
422 | 460 | ||
423 | impl<'a> From<Char<'a>> for CharNode { | 461 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<CharNode<R1>> for CharNode<R2> { |
424 | fn from(ast: Char<'a>) -> CharNode { | 462 | fn eq(&self, other: &CharNode<R1>) -> bool { self.syntax == other.syntax } |
425 | let syntax = ast.syntax().owned(); | ||
426 | CharNode(syntax) | ||
427 | } | ||
428 | } | 463 | } |
429 | #[derive(Debug, Clone, Copy)] | 464 | impl<R: TreeRoot<RaTypes>> Eq for CharNode<R> {} |
430 | pub struct Char<'a> { | 465 | impl<R: TreeRoot<RaTypes>> Hash for CharNode<R> { |
431 | syntax: SyntaxNodeRef<'a>, | 466 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } |
432 | } | 467 | } |
433 | 468 | ||
434 | impl<'a> AstNode<'a> for Char<'a> { | 469 | impl<'a> AstNode<'a> for Char<'a> { |
@@ -441,28 +476,31 @@ impl<'a> AstNode<'a> for Char<'a> { | |||
441 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 476 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
442 | } | 477 | } |
443 | 478 | ||
444 | impl<'a> Char<'a> {} | 479 | impl<R: TreeRoot<RaTypes>> CharNode<R> { |
480 | pub fn borrowed(&self) -> Char { | ||
481 | CharNode { syntax: self.syntax.borrowed() } | ||
482 | } | ||
483 | pub fn owned(&self) -> CharNode { | ||
484 | CharNode { syntax: self.syntax.owned() } | ||
485 | } | ||
486 | } | ||
445 | 487 | ||
446 | // Comment | ||
447 | 488 | ||
448 | #[derive(Debug, Clone)] | 489 | impl<'a> Char<'a> {} |
449 | pub struct CommentNode(SyntaxNode); | ||
450 | 490 | ||
451 | impl CommentNode { | 491 | // Comment |
452 | pub fn ast(&self) -> Comment { | 492 | #[derive(Debug, Clone, Copy,)] |
453 | Comment::cast(self.0.borrowed()).unwrap() | 493 | pub struct CommentNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
454 | } | 494 | pub(crate) syntax: SyntaxNode<R>, |
455 | } | 495 | } |
496 | pub type Comment<'a> = CommentNode<RefRoot<'a>>; | ||
456 | 497 | ||
457 | impl<'a> From<Comment<'a>> for CommentNode { | 498 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<CommentNode<R1>> for CommentNode<R2> { |
458 | fn from(ast: Comment<'a>) -> CommentNode { | 499 | fn eq(&self, other: &CommentNode<R1>) -> bool { self.syntax == other.syntax } |
459 | let syntax = ast.syntax().owned(); | ||
460 | CommentNode(syntax) | ||
461 | } | ||
462 | } | 500 | } |
463 | #[derive(Debug, Clone, Copy)] | 501 | impl<R: TreeRoot<RaTypes>> Eq for CommentNode<R> {} |
464 | pub struct Comment<'a> { | 502 | impl<R: TreeRoot<RaTypes>> Hash for CommentNode<R> { |
465 | syntax: SyntaxNodeRef<'a>, | 503 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } |
466 | } | 504 | } |
467 | 505 | ||
468 | impl<'a> AstNode<'a> for Comment<'a> { | 506 | impl<'a> AstNode<'a> for Comment<'a> { |
@@ -475,28 +513,31 @@ impl<'a> AstNode<'a> for Comment<'a> { | |||
475 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 513 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
476 | } | 514 | } |
477 | 515 | ||
478 | impl<'a> Comment<'a> {} | 516 | impl<R: TreeRoot<RaTypes>> CommentNode<R> { |
517 | pub fn borrowed(&self) -> Comment { | ||
518 | CommentNode { syntax: self.syntax.borrowed() } | ||
519 | } | ||
520 | pub fn owned(&self) -> CommentNode { | ||
521 | CommentNode { syntax: self.syntax.owned() } | ||
522 | } | ||
523 | } | ||
479 | 524 | ||
480 | // Condition | ||
481 | 525 | ||
482 | #[derive(Debug, Clone)] | 526 | impl<'a> Comment<'a> {} |
483 | pub struct ConditionNode(SyntaxNode); | ||
484 | 527 | ||
485 | impl ConditionNode { | 528 | // Condition |
486 | pub fn ast(&self) -> Condition { | 529 | #[derive(Debug, Clone, Copy,)] |
487 | Condition::cast(self.0.borrowed()).unwrap() | 530 | pub struct ConditionNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
488 | } | 531 | pub(crate) syntax: SyntaxNode<R>, |
489 | } | 532 | } |
533 | pub type Condition<'a> = ConditionNode<RefRoot<'a>>; | ||
490 | 534 | ||
491 | impl<'a> From<Condition<'a>> for ConditionNode { | 535 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<ConditionNode<R1>> for ConditionNode<R2> { |
492 | fn from(ast: Condition<'a>) -> ConditionNode { | 536 | fn eq(&self, other: &ConditionNode<R1>) -> bool { self.syntax == other.syntax } |
493 | let syntax = ast.syntax().owned(); | ||
494 | ConditionNode(syntax) | ||
495 | } | ||
496 | } | 537 | } |
497 | #[derive(Debug, Clone, Copy)] | 538 | impl<R: TreeRoot<RaTypes>> Eq for ConditionNode<R> {} |
498 | pub struct Condition<'a> { | 539 | impl<R: TreeRoot<RaTypes>> Hash for ConditionNode<R> { |
499 | syntax: SyntaxNodeRef<'a>, | 540 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } |
500 | } | 541 | } |
501 | 542 | ||
502 | impl<'a> AstNode<'a> for Condition<'a> { | 543 | impl<'a> AstNode<'a> for Condition<'a> { |
@@ -509,6 +550,16 @@ impl<'a> AstNode<'a> for Condition<'a> { | |||
509 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 550 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
510 | } | 551 | } |
511 | 552 | ||
553 | impl<R: TreeRoot<RaTypes>> ConditionNode<R> { | ||
554 | pub fn borrowed(&self) -> Condition { | ||
555 | ConditionNode { syntax: self.syntax.borrowed() } | ||
556 | } | ||
557 | pub fn owned(&self) -> ConditionNode { | ||
558 | ConditionNode { syntax: self.syntax.owned() } | ||
559 | } | ||
560 | } | ||
561 | |||
562 | |||
512 | impl<'a> Condition<'a> { | 563 | impl<'a> Condition<'a> { |
513 | pub fn pat(self) -> Option<Pat<'a>> { | 564 | pub fn pat(self) -> Option<Pat<'a>> { |
514 | super::child_opt(self) | 565 | super::child_opt(self) |
@@ -520,25 +571,18 @@ impl<'a> Condition<'a> { | |||
520 | } | 571 | } |
521 | 572 | ||
522 | // ConstDef | 573 | // ConstDef |
523 | 574 | #[derive(Debug, Clone, Copy,)] | |
524 | #[derive(Debug, Clone)] | 575 | pub struct ConstDefNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
525 | pub struct ConstDefNode(SyntaxNode); | 576 | pub(crate) syntax: SyntaxNode<R>, |
526 | |||
527 | impl ConstDefNode { | ||
528 | pub fn ast(&self) -> ConstDef { | ||
529 | ConstDef::cast(self.0.borrowed()).unwrap() | ||
530 | } | ||
531 | } | 577 | } |
578 | pub type ConstDef<'a> = ConstDefNode<RefRoot<'a>>; | ||
532 | 579 | ||
533 | impl<'a> From<ConstDef<'a>> for ConstDefNode { | 580 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<ConstDefNode<R1>> for ConstDefNode<R2> { |
534 | fn from(ast: ConstDef<'a>) -> ConstDefNode { | 581 | fn eq(&self, other: &ConstDefNode<R1>) -> bool { self.syntax == other.syntax } |
535 | let syntax = ast.syntax().owned(); | ||
536 | ConstDefNode(syntax) | ||
537 | } | ||
538 | } | 582 | } |
539 | #[derive(Debug, Clone, Copy)] | 583 | impl<R: TreeRoot<RaTypes>> Eq for ConstDefNode<R> {} |
540 | pub struct ConstDef<'a> { | 584 | impl<R: TreeRoot<RaTypes>> Hash for ConstDefNode<R> { |
541 | syntax: SyntaxNodeRef<'a>, | 585 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } |
542 | } | 586 | } |
543 | 587 | ||
544 | impl<'a> AstNode<'a> for ConstDef<'a> { | 588 | impl<'a> AstNode<'a> for ConstDef<'a> { |
@@ -551,31 +595,34 @@ impl<'a> AstNode<'a> for ConstDef<'a> { | |||
551 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 595 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
552 | } | 596 | } |
553 | 597 | ||
598 | impl<R: TreeRoot<RaTypes>> ConstDefNode<R> { | ||
599 | pub fn borrowed(&self) -> ConstDef { | ||
600 | ConstDefNode { syntax: self.syntax.borrowed() } | ||
601 | } | ||
602 | pub fn owned(&self) -> ConstDefNode { | ||
603 | ConstDefNode { syntax: self.syntax.owned() } | ||
604 | } | ||
605 | } | ||
606 | |||
607 | |||
554 | impl<'a> ast::NameOwner<'a> for ConstDef<'a> {} | 608 | impl<'a> ast::NameOwner<'a> for ConstDef<'a> {} |
555 | impl<'a> ast::TypeParamsOwner<'a> for ConstDef<'a> {} | 609 | impl<'a> ast::TypeParamsOwner<'a> for ConstDef<'a> {} |
556 | impl<'a> ast::AttrsOwner<'a> for ConstDef<'a> {} | 610 | impl<'a> ast::AttrsOwner<'a> for ConstDef<'a> {} |
557 | impl<'a> ConstDef<'a> {} | 611 | impl<'a> ConstDef<'a> {} |
558 | 612 | ||
559 | // ContinueExpr | 613 | // ContinueExpr |
560 | 614 | #[derive(Debug, Clone, Copy,)] | |
561 | #[derive(Debug, Clone)] | 615 | pub struct ContinueExprNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
562 | pub struct ContinueExprNode(SyntaxNode); | 616 | pub(crate) syntax: SyntaxNode<R>, |
563 | |||
564 | impl ContinueExprNode { | ||
565 | pub fn ast(&self) -> ContinueExpr { | ||
566 | ContinueExpr::cast(self.0.borrowed()).unwrap() | ||
567 | } | ||
568 | } | 617 | } |
618 | pub type ContinueExpr<'a> = ContinueExprNode<RefRoot<'a>>; | ||
569 | 619 | ||
570 | impl<'a> From<ContinueExpr<'a>> for ContinueExprNode { | 620 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<ContinueExprNode<R1>> for ContinueExprNode<R2> { |
571 | fn from(ast: ContinueExpr<'a>) -> ContinueExprNode { | 621 | fn eq(&self, other: &ContinueExprNode<R1>) -> bool { self.syntax == other.syntax } |
572 | let syntax = ast.syntax().owned(); | ||
573 | ContinueExprNode(syntax) | ||
574 | } | ||
575 | } | 622 | } |
576 | #[derive(Debug, Clone, Copy)] | 623 | impl<R: TreeRoot<RaTypes>> Eq for ContinueExprNode<R> {} |
577 | pub struct ContinueExpr<'a> { | 624 | impl<R: TreeRoot<RaTypes>> Hash for ContinueExprNode<R> { |
578 | syntax: SyntaxNodeRef<'a>, | 625 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } |
579 | } | 626 | } |
580 | 627 | ||
581 | impl<'a> AstNode<'a> for ContinueExpr<'a> { | 628 | impl<'a> AstNode<'a> for ContinueExpr<'a> { |
@@ -588,28 +635,31 @@ impl<'a> AstNode<'a> for ContinueExpr<'a> { | |||
588 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 635 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
589 | } | 636 | } |
590 | 637 | ||
591 | impl<'a> ContinueExpr<'a> {} | 638 | impl<R: TreeRoot<RaTypes>> ContinueExprNode<R> { |
639 | pub fn borrowed(&self) -> ContinueExpr { | ||
640 | ContinueExprNode { syntax: self.syntax.borrowed() } | ||
641 | } | ||
642 | pub fn owned(&self) -> ContinueExprNode { | ||
643 | ContinueExprNode { syntax: self.syntax.owned() } | ||
644 | } | ||
645 | } | ||
592 | 646 | ||
593 | // DynTraitType | ||
594 | 647 | ||
595 | #[derive(Debug, Clone)] | 648 | impl<'a> ContinueExpr<'a> {} |
596 | pub struct DynTraitTypeNode(SyntaxNode); | ||
597 | 649 | ||
598 | impl DynTraitTypeNode { | 650 | // DynTraitType |
599 | pub fn ast(&self) -> DynTraitType { | 651 | #[derive(Debug, Clone, Copy,)] |
600 | DynTraitType::cast(self.0.borrowed()).unwrap() | 652 | pub struct DynTraitTypeNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
601 | } | 653 | pub(crate) syntax: SyntaxNode<R>, |
602 | } | 654 | } |
655 | pub type DynTraitType<'a> = DynTraitTypeNode<RefRoot<'a>>; | ||
603 | 656 | ||
604 | impl<'a> From<DynTraitType<'a>> for DynTraitTypeNode { | 657 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<DynTraitTypeNode<R1>> for DynTraitTypeNode<R2> { |
605 | fn from(ast: DynTraitType<'a>) -> DynTraitTypeNode { | 658 | fn eq(&self, other: &DynTraitTypeNode<R1>) -> bool { self.syntax == other.syntax } |
606 | let syntax = ast.syntax().owned(); | ||
607 | DynTraitTypeNode(syntax) | ||
608 | } | ||
609 | } | 659 | } |
610 | #[derive(Debug, Clone, Copy)] | 660 | impl<R: TreeRoot<RaTypes>> Eq for DynTraitTypeNode<R> {} |
611 | pub struct DynTraitType<'a> { | 661 | impl<R: TreeRoot<RaTypes>> Hash for DynTraitTypeNode<R> { |
612 | syntax: SyntaxNodeRef<'a>, | 662 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } |
613 | } | 663 | } |
614 | 664 | ||
615 | impl<'a> AstNode<'a> for DynTraitType<'a> { | 665 | impl<'a> AstNode<'a> for DynTraitType<'a> { |
@@ -622,28 +672,31 @@ impl<'a> AstNode<'a> for DynTraitType<'a> { | |||
622 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 672 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
623 | } | 673 | } |
624 | 674 | ||
625 | impl<'a> DynTraitType<'a> {} | 675 | impl<R: TreeRoot<RaTypes>> DynTraitTypeNode<R> { |
676 | pub fn borrowed(&self) -> DynTraitType { | ||
677 | DynTraitTypeNode { syntax: self.syntax.borrowed() } | ||
678 | } | ||
679 | pub fn owned(&self) -> DynTraitTypeNode { | ||
680 | DynTraitTypeNode { syntax: self.syntax.owned() } | ||
681 | } | ||
682 | } | ||
626 | 683 | ||
627 | // EnumDef | ||
628 | 684 | ||
629 | #[derive(Debug, Clone)] | 685 | impl<'a> DynTraitType<'a> {} |
630 | pub struct EnumDefNode(SyntaxNode); | ||
631 | 686 | ||
632 | impl EnumDefNode { | 687 | // EnumDef |
633 | pub fn ast(&self) -> EnumDef { | 688 | #[derive(Debug, Clone, Copy,)] |
634 | EnumDef::cast(self.0.borrowed()).unwrap() | 689 | pub struct EnumDefNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
635 | } | 690 | pub(crate) syntax: SyntaxNode<R>, |
636 | } | 691 | } |
692 | pub type EnumDef<'a> = EnumDefNode<RefRoot<'a>>; | ||
637 | 693 | ||
638 | impl<'a> From<EnumDef<'a>> for EnumDefNode { | 694 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<EnumDefNode<R1>> for EnumDefNode<R2> { |
639 | fn from(ast: EnumDef<'a>) -> EnumDefNode { | 695 | fn eq(&self, other: &EnumDefNode<R1>) -> bool { self.syntax == other.syntax } |
640 | let syntax = ast.syntax().owned(); | ||
641 | EnumDefNode(syntax) | ||
642 | } | ||
643 | } | 696 | } |
644 | #[derive(Debug, Clone, Copy)] | 697 | impl<R: TreeRoot<RaTypes>> Eq for EnumDefNode<R> {} |
645 | pub struct EnumDef<'a> { | 698 | impl<R: TreeRoot<RaTypes>> Hash for EnumDefNode<R> { |
646 | syntax: SyntaxNodeRef<'a>, | 699 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } |
647 | } | 700 | } |
648 | 701 | ||
649 | impl<'a> AstNode<'a> for EnumDef<'a> { | 702 | impl<'a> AstNode<'a> for EnumDef<'a> { |
@@ -656,29 +709,23 @@ impl<'a> AstNode<'a> for EnumDef<'a> { | |||
656 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 709 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
657 | } | 710 | } |
658 | 711 | ||
712 | impl<R: TreeRoot<RaTypes>> EnumDefNode<R> { | ||
713 | pub fn borrowed(&self) -> EnumDef { | ||
714 | EnumDefNode { syntax: self.syntax.borrowed() } | ||
715 | } | ||
716 | pub fn owned(&self) -> EnumDefNode { | ||
717 | EnumDefNode { syntax: self.syntax.owned() } | ||
718 | } | ||
719 | } | ||
720 | |||
721 | |||
659 | impl<'a> ast::NameOwner<'a> for EnumDef<'a> {} | 722 | impl<'a> ast::NameOwner<'a> for EnumDef<'a> {} |
660 | impl<'a> ast::TypeParamsOwner<'a> for EnumDef<'a> {} | 723 | impl<'a> ast::TypeParamsOwner<'a> for EnumDef<'a> {} |
661 | impl<'a> ast::AttrsOwner<'a> for EnumDef<'a> {} | 724 | impl<'a> ast::AttrsOwner<'a> for EnumDef<'a> {} |
662 | impl<'a> EnumDef<'a> {} | 725 | impl<'a> EnumDef<'a> {} |
663 | 726 | ||
664 | // Expr | 727 | // Expr |
665 | 728 | #[derive(Debug, Clone, Copy, PartialEq, Eq)] | |
666 | #[derive(Debug, Clone)] | ||
667 | pub struct ExprNode(SyntaxNode); | ||
668 | |||
669 | impl ExprNode { | ||
670 | pub fn ast(&self) -> Expr { | ||
671 | Expr::cast(self.0.borrowed()).unwrap() | ||
672 | } | ||
673 | } | ||
674 | |||
675 | impl<'a> From<Expr<'a>> for ExprNode { | ||
676 | fn from(ast: Expr<'a>) -> ExprNode { | ||
677 | let syntax = ast.syntax().owned(); | ||
678 | ExprNode(syntax) | ||
679 | } | ||
680 | } | ||
681 | #[derive(Debug, Clone, Copy)] | ||
682 | pub enum Expr<'a> { | 729 | pub enum Expr<'a> { |
683 | TupleExpr(TupleExpr<'a>), | 730 | TupleExpr(TupleExpr<'a>), |
684 | ArrayExpr(ArrayExpr<'a>), | 731 | ArrayExpr(ArrayExpr<'a>), |
@@ -793,25 +840,18 @@ impl<'a> AstNode<'a> for Expr<'a> { | |||
793 | impl<'a> Expr<'a> {} | 840 | impl<'a> Expr<'a> {} |
794 | 841 | ||
795 | // ExprStmt | 842 | // ExprStmt |
796 | 843 | #[derive(Debug, Clone, Copy,)] | |
797 | #[derive(Debug, Clone)] | 844 | pub struct ExprStmtNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
798 | pub struct ExprStmtNode(SyntaxNode); | 845 | pub(crate) syntax: SyntaxNode<R>, |
799 | |||
800 | impl ExprStmtNode { | ||
801 | pub fn ast(&self) -> ExprStmt { | ||
802 | ExprStmt::cast(self.0.borrowed()).unwrap() | ||
803 | } | ||
804 | } | 846 | } |
847 | pub type ExprStmt<'a> = ExprStmtNode<RefRoot<'a>>; | ||
805 | 848 | ||
806 | impl<'a> From<ExprStmt<'a>> for ExprStmtNode { | 849 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<ExprStmtNode<R1>> for ExprStmtNode<R2> { |
807 | fn from(ast: ExprStmt<'a>) -> ExprStmtNode { | 850 | fn eq(&self, other: &ExprStmtNode<R1>) -> bool { self.syntax == other.syntax } |
808 | let syntax = ast.syntax().owned(); | ||
809 | ExprStmtNode(syntax) | ||
810 | } | ||
811 | } | 851 | } |
812 | #[derive(Debug, Clone, Copy)] | 852 | impl<R: TreeRoot<RaTypes>> Eq for ExprStmtNode<R> {} |
813 | pub struct ExprStmt<'a> { | 853 | impl<R: TreeRoot<RaTypes>> Hash for ExprStmtNode<R> { |
814 | syntax: SyntaxNodeRef<'a>, | 854 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } |
815 | } | 855 | } |
816 | 856 | ||
817 | impl<'a> AstNode<'a> for ExprStmt<'a> { | 857 | impl<'a> AstNode<'a> for ExprStmt<'a> { |
@@ -824,6 +864,16 @@ impl<'a> AstNode<'a> for ExprStmt<'a> { | |||
824 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 864 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
825 | } | 865 | } |
826 | 866 | ||
867 | impl<R: TreeRoot<RaTypes>> ExprStmtNode<R> { | ||
868 | pub fn borrowed(&self) -> ExprStmt { | ||
869 | ExprStmtNode { syntax: self.syntax.borrowed() } | ||
870 | } | ||
871 | pub fn owned(&self) -> ExprStmtNode { | ||
872 | ExprStmtNode { syntax: self.syntax.owned() } | ||
873 | } | ||
874 | } | ||
875 | |||
876 | |||
827 | impl<'a> ExprStmt<'a> { | 877 | impl<'a> ExprStmt<'a> { |
828 | pub fn expr(self) -> Option<Expr<'a>> { | 878 | pub fn expr(self) -> Option<Expr<'a>> { |
829 | super::child_opt(self) | 879 | super::child_opt(self) |
@@ -831,25 +881,18 @@ impl<'a> ExprStmt<'a> { | |||
831 | } | 881 | } |
832 | 882 | ||
833 | // ExternCrateItem | 883 | // ExternCrateItem |
834 | 884 | #[derive(Debug, Clone, Copy,)] | |
835 | #[derive(Debug, Clone)] | 885 | pub struct ExternCrateItemNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
836 | pub struct ExternCrateItemNode(SyntaxNode); | 886 | pub(crate) syntax: SyntaxNode<R>, |
837 | |||
838 | impl ExternCrateItemNode { | ||
839 | pub fn ast(&self) -> ExternCrateItem { | ||
840 | ExternCrateItem::cast(self.0.borrowed()).unwrap() | ||
841 | } | ||
842 | } | 887 | } |
888 | pub type ExternCrateItem<'a> = ExternCrateItemNode<RefRoot<'a>>; | ||
843 | 889 | ||
844 | impl<'a> From<ExternCrateItem<'a>> for ExternCrateItemNode { | 890 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<ExternCrateItemNode<R1>> for ExternCrateItemNode<R2> { |
845 | fn from(ast: ExternCrateItem<'a>) -> ExternCrateItemNode { | 891 | fn eq(&self, other: &ExternCrateItemNode<R1>) -> bool { self.syntax == other.syntax } |
846 | let syntax = ast.syntax().owned(); | ||
847 | ExternCrateItemNode(syntax) | ||
848 | } | ||
849 | } | 892 | } |
850 | #[derive(Debug, Clone, Copy)] | 893 | impl<R: TreeRoot<RaTypes>> Eq for ExternCrateItemNode<R> {} |
851 | pub struct ExternCrateItem<'a> { | 894 | impl<R: TreeRoot<RaTypes>> Hash for ExternCrateItemNode<R> { |
852 | syntax: SyntaxNodeRef<'a>, | 895 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } |
853 | } | 896 | } |
854 | 897 | ||
855 | impl<'a> AstNode<'a> for ExternCrateItem<'a> { | 898 | impl<'a> AstNode<'a> for ExternCrateItem<'a> { |
@@ -862,28 +905,31 @@ impl<'a> AstNode<'a> for ExternCrateItem<'a> { | |||
862 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 905 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
863 | } | 906 | } |
864 | 907 | ||
865 | impl<'a> ExternCrateItem<'a> {} | 908 | impl<R: TreeRoot<RaTypes>> ExternCrateItemNode<R> { |
909 | pub fn borrowed(&self) -> ExternCrateItem { | ||
910 | ExternCrateItemNode { syntax: self.syntax.borrowed() } | ||
911 | } | ||
912 | pub fn owned(&self) -> ExternCrateItemNode { | ||
913 | ExternCrateItemNode { syntax: self.syntax.owned() } | ||
914 | } | ||
915 | } | ||
866 | 916 | ||
867 | // FieldExpr | ||
868 | 917 | ||
869 | #[derive(Debug, Clone)] | 918 | impl<'a> ExternCrateItem<'a> {} |
870 | pub struct FieldExprNode(SyntaxNode); | ||
871 | 919 | ||
872 | impl FieldExprNode { | 920 | // FieldExpr |
873 | pub fn ast(&self) -> FieldExpr { | 921 | #[derive(Debug, Clone, Copy,)] |
874 | FieldExpr::cast(self.0.borrowed()).unwrap() | 922 | pub struct FieldExprNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
875 | } | 923 | pub(crate) syntax: SyntaxNode<R>, |
876 | } | 924 | } |
925 | pub type FieldExpr<'a> = FieldExprNode<RefRoot<'a>>; | ||
877 | 926 | ||
878 | impl<'a> From<FieldExpr<'a>> for FieldExprNode { | 927 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<FieldExprNode<R1>> for FieldExprNode<R2> { |
879 | fn from(ast: FieldExpr<'a>) -> FieldExprNode { | 928 | fn eq(&self, other: &FieldExprNode<R1>) -> bool { self.syntax == other.syntax } |
880 | let syntax = ast.syntax().owned(); | ||
881 | FieldExprNode(syntax) | ||
882 | } | ||
883 | } | 929 | } |
884 | #[derive(Debug, Clone, Copy)] | 930 | impl<R: TreeRoot<RaTypes>> Eq for FieldExprNode<R> {} |
885 | pub struct FieldExpr<'a> { | 931 | impl<R: TreeRoot<RaTypes>> Hash for FieldExprNode<R> { |
886 | syntax: SyntaxNodeRef<'a>, | 932 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } |
887 | } | 933 | } |
888 | 934 | ||
889 | impl<'a> AstNode<'a> for FieldExpr<'a> { | 935 | impl<'a> AstNode<'a> for FieldExpr<'a> { |
@@ -896,28 +942,31 @@ impl<'a> AstNode<'a> for FieldExpr<'a> { | |||
896 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 942 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
897 | } | 943 | } |
898 | 944 | ||
899 | impl<'a> FieldExpr<'a> {} | 945 | impl<R: TreeRoot<RaTypes>> FieldExprNode<R> { |
946 | pub fn borrowed(&self) -> FieldExpr { | ||
947 | FieldExprNode { syntax: self.syntax.borrowed() } | ||
948 | } | ||
949 | pub fn owned(&self) -> FieldExprNode { | ||
950 | FieldExprNode { syntax: self.syntax.owned() } | ||
951 | } | ||
952 | } | ||
900 | 953 | ||
901 | // FieldPatList | ||
902 | 954 | ||
903 | #[derive(Debug, Clone)] | 955 | impl<'a> FieldExpr<'a> {} |
904 | pub struct FieldPatListNode(SyntaxNode); | ||
905 | 956 | ||
906 | impl FieldPatListNode { | 957 | // FieldPatList |
907 | pub fn ast(&self) -> FieldPatList { | 958 | #[derive(Debug, Clone, Copy,)] |
908 | FieldPatList::cast(self.0.borrowed()).unwrap() | 959 | pub struct FieldPatListNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
909 | } | 960 | pub(crate) syntax: SyntaxNode<R>, |
910 | } | 961 | } |
962 | pub type FieldPatList<'a> = FieldPatListNode<RefRoot<'a>>; | ||
911 | 963 | ||
912 | impl<'a> From<FieldPatList<'a>> for FieldPatListNode { | 964 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<FieldPatListNode<R1>> for FieldPatListNode<R2> { |
913 | fn from(ast: FieldPatList<'a>) -> FieldPatListNode { | 965 | fn eq(&self, other: &FieldPatListNode<R1>) -> bool { self.syntax == other.syntax } |
914 | let syntax = ast.syntax().owned(); | ||
915 | FieldPatListNode(syntax) | ||
916 | } | ||
917 | } | 966 | } |
918 | #[derive(Debug, Clone, Copy)] | 967 | impl<R: TreeRoot<RaTypes>> Eq for FieldPatListNode<R> {} |
919 | pub struct FieldPatList<'a> { | 968 | impl<R: TreeRoot<RaTypes>> Hash for FieldPatListNode<R> { |
920 | syntax: SyntaxNodeRef<'a>, | 969 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } |
921 | } | 970 | } |
922 | 971 | ||
923 | impl<'a> AstNode<'a> for FieldPatList<'a> { | 972 | impl<'a> AstNode<'a> for FieldPatList<'a> { |
@@ -930,28 +979,31 @@ impl<'a> AstNode<'a> for FieldPatList<'a> { | |||
930 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 979 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
931 | } | 980 | } |
932 | 981 | ||
933 | impl<'a> FieldPatList<'a> {} | 982 | impl<R: TreeRoot<RaTypes>> FieldPatListNode<R> { |
983 | pub fn borrowed(&self) -> FieldPatList { | ||
984 | FieldPatListNode { syntax: self.syntax.borrowed() } | ||
985 | } | ||
986 | pub fn owned(&self) -> FieldPatListNode { | ||
987 | FieldPatListNode { syntax: self.syntax.owned() } | ||
988 | } | ||
989 | } | ||
934 | 990 | ||
935 | // FnDef | ||
936 | 991 | ||
937 | #[derive(Debug, Clone)] | 992 | impl<'a> FieldPatList<'a> {} |
938 | pub struct FnDefNode(SyntaxNode); | ||
939 | 993 | ||
940 | impl FnDefNode { | 994 | // FnDef |
941 | pub fn ast(&self) -> FnDef { | 995 | #[derive(Debug, Clone, Copy,)] |
942 | FnDef::cast(self.0.borrowed()).unwrap() | 996 | pub struct FnDefNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
943 | } | 997 | pub(crate) syntax: SyntaxNode<R>, |
944 | } | 998 | } |
999 | pub type FnDef<'a> = FnDefNode<RefRoot<'a>>; | ||
945 | 1000 | ||
946 | impl<'a> From<FnDef<'a>> for FnDefNode { | 1001 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<FnDefNode<R1>> for FnDefNode<R2> { |
947 | fn from(ast: FnDef<'a>) -> FnDefNode { | 1002 | fn eq(&self, other: &FnDefNode<R1>) -> bool { self.syntax == other.syntax } |
948 | let syntax = ast.syntax().owned(); | ||
949 | FnDefNode(syntax) | ||
950 | } | ||
951 | } | 1003 | } |
952 | #[derive(Debug, Clone, Copy)] | 1004 | impl<R: TreeRoot<RaTypes>> Eq for FnDefNode<R> {} |
953 | pub struct FnDef<'a> { | 1005 | impl<R: TreeRoot<RaTypes>> Hash for FnDefNode<R> { |
954 | syntax: SyntaxNodeRef<'a>, | 1006 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } |
955 | } | 1007 | } |
956 | 1008 | ||
957 | impl<'a> AstNode<'a> for FnDef<'a> { | 1009 | impl<'a> AstNode<'a> for FnDef<'a> { |
@@ -964,6 +1016,16 @@ impl<'a> AstNode<'a> for FnDef<'a> { | |||
964 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 1016 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
965 | } | 1017 | } |
966 | 1018 | ||
1019 | impl<R: TreeRoot<RaTypes>> FnDefNode<R> { | ||
1020 | pub fn borrowed(&self) -> FnDef { | ||
1021 | FnDefNode { syntax: self.syntax.borrowed() } | ||
1022 | } | ||
1023 | pub fn owned(&self) -> FnDefNode { | ||
1024 | FnDefNode { syntax: self.syntax.owned() } | ||
1025 | } | ||
1026 | } | ||
1027 | |||
1028 | |||
967 | impl<'a> ast::NameOwner<'a> for FnDef<'a> {} | 1029 | impl<'a> ast::NameOwner<'a> for FnDef<'a> {} |
968 | impl<'a> ast::TypeParamsOwner<'a> for FnDef<'a> {} | 1030 | impl<'a> ast::TypeParamsOwner<'a> for FnDef<'a> {} |
969 | impl<'a> ast::AttrsOwner<'a> for FnDef<'a> {} | 1031 | impl<'a> ast::AttrsOwner<'a> for FnDef<'a> {} |
@@ -983,25 +1045,18 @@ impl<'a> FnDef<'a> { | |||
983 | } | 1045 | } |
984 | 1046 | ||
985 | // FnPointerType | 1047 | // FnPointerType |
986 | 1048 | #[derive(Debug, Clone, Copy,)] | |
987 | #[derive(Debug, Clone)] | 1049 | pub struct FnPointerTypeNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
988 | pub struct FnPointerTypeNode(SyntaxNode); | 1050 | pub(crate) syntax: SyntaxNode<R>, |
989 | |||
990 | impl FnPointerTypeNode { | ||
991 | pub fn ast(&self) -> FnPointerType { | ||
992 | FnPointerType::cast(self.0.borrowed()).unwrap() | ||
993 | } | ||
994 | } | 1051 | } |
1052 | pub type FnPointerType<'a> = FnPointerTypeNode<RefRoot<'a>>; | ||
995 | 1053 | ||
996 | impl<'a> From<FnPointerType<'a>> for FnPointerTypeNode { | 1054 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<FnPointerTypeNode<R1>> for FnPointerTypeNode<R2> { |
997 | fn from(ast: FnPointerType<'a>) -> FnPointerTypeNode { | 1055 | fn eq(&self, other: &FnPointerTypeNode<R1>) -> bool { self.syntax == other.syntax } |
998 | let syntax = ast.syntax().owned(); | ||
999 | FnPointerTypeNode(syntax) | ||
1000 | } | ||
1001 | } | 1056 | } |
1002 | #[derive(Debug, Clone, Copy)] | 1057 | impl<R: TreeRoot<RaTypes>> Eq for FnPointerTypeNode<R> {} |
1003 | pub struct FnPointerType<'a> { | 1058 | impl<R: TreeRoot<RaTypes>> Hash for FnPointerTypeNode<R> { |
1004 | syntax: SyntaxNodeRef<'a>, | 1059 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } |
1005 | } | 1060 | } |
1006 | 1061 | ||
1007 | impl<'a> AstNode<'a> for FnPointerType<'a> { | 1062 | impl<'a> AstNode<'a> for FnPointerType<'a> { |
@@ -1014,28 +1069,31 @@ impl<'a> AstNode<'a> for FnPointerType<'a> { | |||
1014 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 1069 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
1015 | } | 1070 | } |
1016 | 1071 | ||
1017 | impl<'a> FnPointerType<'a> {} | 1072 | impl<R: TreeRoot<RaTypes>> FnPointerTypeNode<R> { |
1073 | pub fn borrowed(&self) -> FnPointerType { | ||
1074 | FnPointerTypeNode { syntax: self.syntax.borrowed() } | ||
1075 | } | ||
1076 | pub fn owned(&self) -> FnPointerTypeNode { | ||
1077 | FnPointerTypeNode { syntax: self.syntax.owned() } | ||
1078 | } | ||
1079 | } | ||
1018 | 1080 | ||
1019 | // ForExpr | ||
1020 | 1081 | ||
1021 | #[derive(Debug, Clone)] | 1082 | impl<'a> FnPointerType<'a> {} |
1022 | pub struct ForExprNode(SyntaxNode); | ||
1023 | 1083 | ||
1024 | impl ForExprNode { | 1084 | // ForExpr |
1025 | pub fn ast(&self) -> ForExpr { | 1085 | #[derive(Debug, Clone, Copy,)] |
1026 | ForExpr::cast(self.0.borrowed()).unwrap() | 1086 | pub struct ForExprNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
1027 | } | 1087 | pub(crate) syntax: SyntaxNode<R>, |
1028 | } | 1088 | } |
1089 | pub type ForExpr<'a> = ForExprNode<RefRoot<'a>>; | ||
1029 | 1090 | ||
1030 | impl<'a> From<ForExpr<'a>> for ForExprNode { | 1091 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<ForExprNode<R1>> for ForExprNode<R2> { |
1031 | fn from(ast: ForExpr<'a>) -> ForExprNode { | 1092 | fn eq(&self, other: &ForExprNode<R1>) -> bool { self.syntax == other.syntax } |
1032 | let syntax = ast.syntax().owned(); | ||
1033 | ForExprNode(syntax) | ||
1034 | } | ||
1035 | } | 1093 | } |
1036 | #[derive(Debug, Clone, Copy)] | 1094 | impl<R: TreeRoot<RaTypes>> Eq for ForExprNode<R> {} |
1037 | pub struct ForExpr<'a> { | 1095 | impl<R: TreeRoot<RaTypes>> Hash for ForExprNode<R> { |
1038 | syntax: SyntaxNodeRef<'a>, | 1096 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } |
1039 | } | 1097 | } |
1040 | 1098 | ||
1041 | impl<'a> AstNode<'a> for ForExpr<'a> { | 1099 | impl<'a> AstNode<'a> for ForExpr<'a> { |
@@ -1048,6 +1106,16 @@ impl<'a> AstNode<'a> for ForExpr<'a> { | |||
1048 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 1106 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
1049 | } | 1107 | } |
1050 | 1108 | ||
1109 | impl<R: TreeRoot<RaTypes>> ForExprNode<R> { | ||
1110 | pub fn borrowed(&self) -> ForExpr { | ||
1111 | ForExprNode { syntax: self.syntax.borrowed() } | ||
1112 | } | ||
1113 | pub fn owned(&self) -> ForExprNode { | ||
1114 | ForExprNode { syntax: self.syntax.owned() } | ||
1115 | } | ||
1116 | } | ||
1117 | |||
1118 | |||
1051 | impl<'a> ast::LoopBodyOwner<'a> for ForExpr<'a> {} | 1119 | impl<'a> ast::LoopBodyOwner<'a> for ForExpr<'a> {} |
1052 | impl<'a> ForExpr<'a> { | 1120 | impl<'a> ForExpr<'a> { |
1053 | pub fn pat(self) -> Option<Pat<'a>> { | 1121 | pub fn pat(self) -> Option<Pat<'a>> { |
@@ -1060,25 +1128,18 @@ impl<'a> ForExpr<'a> { | |||
1060 | } | 1128 | } |
1061 | 1129 | ||
1062 | // ForType | 1130 | // ForType |
1063 | 1131 | #[derive(Debug, Clone, Copy,)] | |
1064 | #[derive(Debug, Clone)] | 1132 | pub struct ForTypeNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
1065 | pub struct ForTypeNode(SyntaxNode); | 1133 | pub(crate) syntax: SyntaxNode<R>, |
1066 | |||
1067 | impl ForTypeNode { | ||
1068 | pub fn ast(&self) -> ForType { | ||
1069 | ForType::cast(self.0.borrowed()).unwrap() | ||
1070 | } | ||
1071 | } | 1134 | } |
1135 | pub type ForType<'a> = ForTypeNode<RefRoot<'a>>; | ||
1072 | 1136 | ||
1073 | impl<'a> From<ForType<'a>> for ForTypeNode { | 1137 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<ForTypeNode<R1>> for ForTypeNode<R2> { |
1074 | fn from(ast: ForType<'a>) -> ForTypeNode { | 1138 | fn eq(&self, other: &ForTypeNode<R1>) -> bool { self.syntax == other.syntax } |
1075 | let syntax = ast.syntax().owned(); | ||
1076 | ForTypeNode(syntax) | ||
1077 | } | ||
1078 | } | 1139 | } |
1079 | #[derive(Debug, Clone, Copy)] | 1140 | impl<R: TreeRoot<RaTypes>> Eq for ForTypeNode<R> {} |
1080 | pub struct ForType<'a> { | 1141 | impl<R: TreeRoot<RaTypes>> Hash for ForTypeNode<R> { |
1081 | syntax: SyntaxNodeRef<'a>, | 1142 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } |
1082 | } | 1143 | } |
1083 | 1144 | ||
1084 | impl<'a> AstNode<'a> for ForType<'a> { | 1145 | impl<'a> AstNode<'a> for ForType<'a> { |
@@ -1091,28 +1152,31 @@ impl<'a> AstNode<'a> for ForType<'a> { | |||
1091 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 1152 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
1092 | } | 1153 | } |
1093 | 1154 | ||
1094 | impl<'a> ForType<'a> {} | 1155 | impl<R: TreeRoot<RaTypes>> ForTypeNode<R> { |
1156 | pub fn borrowed(&self) -> ForType { | ||
1157 | ForTypeNode { syntax: self.syntax.borrowed() } | ||
1158 | } | ||
1159 | pub fn owned(&self) -> ForTypeNode { | ||
1160 | ForTypeNode { syntax: self.syntax.owned() } | ||
1161 | } | ||
1162 | } | ||
1095 | 1163 | ||
1096 | // IfExpr | ||
1097 | 1164 | ||
1098 | #[derive(Debug, Clone)] | 1165 | impl<'a> ForType<'a> {} |
1099 | pub struct IfExprNode(SyntaxNode); | ||
1100 | 1166 | ||
1101 | impl IfExprNode { | 1167 | // IfExpr |
1102 | pub fn ast(&self) -> IfExpr { | 1168 | #[derive(Debug, Clone, Copy,)] |
1103 | IfExpr::cast(self.0.borrowed()).unwrap() | 1169 | pub struct IfExprNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
1104 | } | 1170 | pub(crate) syntax: SyntaxNode<R>, |
1105 | } | 1171 | } |
1172 | pub type IfExpr<'a> = IfExprNode<RefRoot<'a>>; | ||
1106 | 1173 | ||
1107 | impl<'a> From<IfExpr<'a>> for IfExprNode { | 1174 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<IfExprNode<R1>> for IfExprNode<R2> { |
1108 | fn from(ast: IfExpr<'a>) -> IfExprNode { | 1175 | fn eq(&self, other: &IfExprNode<R1>) -> bool { self.syntax == other.syntax } |
1109 | let syntax = ast.syntax().owned(); | ||
1110 | IfExprNode(syntax) | ||
1111 | } | ||
1112 | } | 1176 | } |
1113 | #[derive(Debug, Clone, Copy)] | 1177 | impl<R: TreeRoot<RaTypes>> Eq for IfExprNode<R> {} |
1114 | pub struct IfExpr<'a> { | 1178 | impl<R: TreeRoot<RaTypes>> Hash for IfExprNode<R> { |
1115 | syntax: SyntaxNodeRef<'a>, | 1179 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } |
1116 | } | 1180 | } |
1117 | 1181 | ||
1118 | impl<'a> AstNode<'a> for IfExpr<'a> { | 1182 | impl<'a> AstNode<'a> for IfExpr<'a> { |
@@ -1125,6 +1189,16 @@ impl<'a> AstNode<'a> for IfExpr<'a> { | |||
1125 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 1189 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
1126 | } | 1190 | } |
1127 | 1191 | ||
1192 | impl<R: TreeRoot<RaTypes>> IfExprNode<R> { | ||
1193 | pub fn borrowed(&self) -> IfExpr { | ||
1194 | IfExprNode { syntax: self.syntax.borrowed() } | ||
1195 | } | ||
1196 | pub fn owned(&self) -> IfExprNode { | ||
1197 | IfExprNode { syntax: self.syntax.owned() } | ||
1198 | } | ||
1199 | } | ||
1200 | |||
1201 | |||
1128 | impl<'a> IfExpr<'a> { | 1202 | impl<'a> IfExpr<'a> { |
1129 | pub fn condition(self) -> Option<Condition<'a>> { | 1203 | pub fn condition(self) -> Option<Condition<'a>> { |
1130 | super::child_opt(self) | 1204 | super::child_opt(self) |
@@ -1132,25 +1206,18 @@ impl<'a> IfExpr<'a> { | |||
1132 | } | 1206 | } |
1133 | 1207 | ||
1134 | // ImplItem | 1208 | // ImplItem |
1135 | 1209 | #[derive(Debug, Clone, Copy,)] | |
1136 | #[derive(Debug, Clone)] | 1210 | pub struct ImplItemNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
1137 | pub struct ImplItemNode(SyntaxNode); | 1211 | pub(crate) syntax: SyntaxNode<R>, |
1138 | |||
1139 | impl ImplItemNode { | ||
1140 | pub fn ast(&self) -> ImplItem { | ||
1141 | ImplItem::cast(self.0.borrowed()).unwrap() | ||
1142 | } | ||
1143 | } | 1212 | } |
1213 | pub type ImplItem<'a> = ImplItemNode<RefRoot<'a>>; | ||
1144 | 1214 | ||
1145 | impl<'a> From<ImplItem<'a>> for ImplItemNode { | 1215 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<ImplItemNode<R1>> for ImplItemNode<R2> { |
1146 | fn from(ast: ImplItem<'a>) -> ImplItemNode { | 1216 | fn eq(&self, other: &ImplItemNode<R1>) -> bool { self.syntax == other.syntax } |
1147 | let syntax = ast.syntax().owned(); | ||
1148 | ImplItemNode(syntax) | ||
1149 | } | ||
1150 | } | 1217 | } |
1151 | #[derive(Debug, Clone, Copy)] | 1218 | impl<R: TreeRoot<RaTypes>> Eq for ImplItemNode<R> {} |
1152 | pub struct ImplItem<'a> { | 1219 | impl<R: TreeRoot<RaTypes>> Hash for ImplItemNode<R> { |
1153 | syntax: SyntaxNodeRef<'a>, | 1220 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } |
1154 | } | 1221 | } |
1155 | 1222 | ||
1156 | impl<'a> AstNode<'a> for ImplItem<'a> { | 1223 | impl<'a> AstNode<'a> for ImplItem<'a> { |
@@ -1163,28 +1230,31 @@ impl<'a> AstNode<'a> for ImplItem<'a> { | |||
1163 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 1230 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
1164 | } | 1231 | } |
1165 | 1232 | ||
1166 | impl<'a> ImplItem<'a> {} | 1233 | impl<R: TreeRoot<RaTypes>> ImplItemNode<R> { |
1234 | pub fn borrowed(&self) -> ImplItem { | ||
1235 | ImplItemNode { syntax: self.syntax.borrowed() } | ||
1236 | } | ||
1237 | pub fn owned(&self) -> ImplItemNode { | ||
1238 | ImplItemNode { syntax: self.syntax.owned() } | ||
1239 | } | ||
1240 | } | ||
1167 | 1241 | ||
1168 | // ImplTraitType | ||
1169 | 1242 | ||
1170 | #[derive(Debug, Clone)] | 1243 | impl<'a> ImplItem<'a> {} |
1171 | pub struct ImplTraitTypeNode(SyntaxNode); | ||
1172 | 1244 | ||
1173 | impl ImplTraitTypeNode { | 1245 | // ImplTraitType |
1174 | pub fn ast(&self) -> ImplTraitType { | 1246 | #[derive(Debug, Clone, Copy,)] |
1175 | ImplTraitType::cast(self.0.borrowed()).unwrap() | 1247 | pub struct ImplTraitTypeNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
1176 | } | 1248 | pub(crate) syntax: SyntaxNode<R>, |
1177 | } | 1249 | } |
1250 | pub type ImplTraitType<'a> = ImplTraitTypeNode<RefRoot<'a>>; | ||
1178 | 1251 | ||
1179 | impl<'a> From<ImplTraitType<'a>> for ImplTraitTypeNode { | 1252 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<ImplTraitTypeNode<R1>> for ImplTraitTypeNode<R2> { |
1180 | fn from(ast: ImplTraitType<'a>) -> ImplTraitTypeNode { | 1253 | fn eq(&self, other: &ImplTraitTypeNode<R1>) -> bool { self.syntax == other.syntax } |
1181 | let syntax = ast.syntax().owned(); | ||
1182 | ImplTraitTypeNode(syntax) | ||
1183 | } | ||
1184 | } | 1254 | } |
1185 | #[derive(Debug, Clone, Copy)] | 1255 | impl<R: TreeRoot<RaTypes>> Eq for ImplTraitTypeNode<R> {} |
1186 | pub struct ImplTraitType<'a> { | 1256 | impl<R: TreeRoot<RaTypes>> Hash for ImplTraitTypeNode<R> { |
1187 | syntax: SyntaxNodeRef<'a>, | 1257 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } |
1188 | } | 1258 | } |
1189 | 1259 | ||
1190 | impl<'a> AstNode<'a> for ImplTraitType<'a> { | 1260 | impl<'a> AstNode<'a> for ImplTraitType<'a> { |
@@ -1197,28 +1267,31 @@ impl<'a> AstNode<'a> for ImplTraitType<'a> { | |||
1197 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 1267 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
1198 | } | 1268 | } |
1199 | 1269 | ||
1200 | impl<'a> ImplTraitType<'a> {} | 1270 | impl<R: TreeRoot<RaTypes>> ImplTraitTypeNode<R> { |
1271 | pub fn borrowed(&self) -> ImplTraitType { | ||
1272 | ImplTraitTypeNode { syntax: self.syntax.borrowed() } | ||
1273 | } | ||
1274 | pub fn owned(&self) -> ImplTraitTypeNode { | ||
1275 | ImplTraitTypeNode { syntax: self.syntax.owned() } | ||
1276 | } | ||
1277 | } | ||
1201 | 1278 | ||
1202 | // IndexExpr | ||
1203 | 1279 | ||
1204 | #[derive(Debug, Clone)] | 1280 | impl<'a> ImplTraitType<'a> {} |
1205 | pub struct IndexExprNode(SyntaxNode); | ||
1206 | 1281 | ||
1207 | impl IndexExprNode { | 1282 | // IndexExpr |
1208 | pub fn ast(&self) -> IndexExpr { | 1283 | #[derive(Debug, Clone, Copy,)] |
1209 | IndexExpr::cast(self.0.borrowed()).unwrap() | 1284 | pub struct IndexExprNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
1210 | } | 1285 | pub(crate) syntax: SyntaxNode<R>, |
1211 | } | 1286 | } |
1287 | pub type IndexExpr<'a> = IndexExprNode<RefRoot<'a>>; | ||
1212 | 1288 | ||
1213 | impl<'a> From<IndexExpr<'a>> for IndexExprNode { | 1289 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<IndexExprNode<R1>> for IndexExprNode<R2> { |
1214 | fn from(ast: IndexExpr<'a>) -> IndexExprNode { | 1290 | fn eq(&self, other: &IndexExprNode<R1>) -> bool { self.syntax == other.syntax } |
1215 | let syntax = ast.syntax().owned(); | ||
1216 | IndexExprNode(syntax) | ||
1217 | } | ||
1218 | } | 1291 | } |
1219 | #[derive(Debug, Clone, Copy)] | 1292 | impl<R: TreeRoot<RaTypes>> Eq for IndexExprNode<R> {} |
1220 | pub struct IndexExpr<'a> { | 1293 | impl<R: TreeRoot<RaTypes>> Hash for IndexExprNode<R> { |
1221 | syntax: SyntaxNodeRef<'a>, | 1294 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } |
1222 | } | 1295 | } |
1223 | 1296 | ||
1224 | impl<'a> AstNode<'a> for IndexExpr<'a> { | 1297 | impl<'a> AstNode<'a> for IndexExpr<'a> { |
@@ -1231,28 +1304,31 @@ impl<'a> AstNode<'a> for IndexExpr<'a> { | |||
1231 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 1304 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
1232 | } | 1305 | } |
1233 | 1306 | ||
1234 | impl<'a> IndexExpr<'a> {} | 1307 | impl<R: TreeRoot<RaTypes>> IndexExprNode<R> { |
1308 | pub fn borrowed(&self) -> IndexExpr { | ||
1309 | IndexExprNode { syntax: self.syntax.borrowed() } | ||
1310 | } | ||
1311 | pub fn owned(&self) -> IndexExprNode { | ||
1312 | IndexExprNode { syntax: self.syntax.owned() } | ||
1313 | } | ||
1314 | } | ||
1235 | 1315 | ||
1236 | // ItemList | ||
1237 | 1316 | ||
1238 | #[derive(Debug, Clone)] | 1317 | impl<'a> IndexExpr<'a> {} |
1239 | pub struct ItemListNode(SyntaxNode); | ||
1240 | 1318 | ||
1241 | impl ItemListNode { | 1319 | // ItemList |
1242 | pub fn ast(&self) -> ItemList { | 1320 | #[derive(Debug, Clone, Copy,)] |
1243 | ItemList::cast(self.0.borrowed()).unwrap() | 1321 | pub struct ItemListNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
1244 | } | 1322 | pub(crate) syntax: SyntaxNode<R>, |
1245 | } | 1323 | } |
1324 | pub type ItemList<'a> = ItemListNode<RefRoot<'a>>; | ||
1246 | 1325 | ||
1247 | impl<'a> From<ItemList<'a>> for ItemListNode { | 1326 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<ItemListNode<R1>> for ItemListNode<R2> { |
1248 | fn from(ast: ItemList<'a>) -> ItemListNode { | 1327 | fn eq(&self, other: &ItemListNode<R1>) -> bool { self.syntax == other.syntax } |
1249 | let syntax = ast.syntax().owned(); | ||
1250 | ItemListNode(syntax) | ||
1251 | } | ||
1252 | } | 1328 | } |
1253 | #[derive(Debug, Clone, Copy)] | 1329 | impl<R: TreeRoot<RaTypes>> Eq for ItemListNode<R> {} |
1254 | pub struct ItemList<'a> { | 1330 | impl<R: TreeRoot<RaTypes>> Hash for ItemListNode<R> { |
1255 | syntax: SyntaxNodeRef<'a>, | 1331 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } |
1256 | } | 1332 | } |
1257 | 1333 | ||
1258 | impl<'a> AstNode<'a> for ItemList<'a> { | 1334 | impl<'a> AstNode<'a> for ItemList<'a> { |
@@ -1265,30 +1341,33 @@ impl<'a> AstNode<'a> for ItemList<'a> { | |||
1265 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 1341 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
1266 | } | 1342 | } |
1267 | 1343 | ||
1344 | impl<R: TreeRoot<RaTypes>> ItemListNode<R> { | ||
1345 | pub fn borrowed(&self) -> ItemList { | ||
1346 | ItemListNode { syntax: self.syntax.borrowed() } | ||
1347 | } | ||
1348 | pub fn owned(&self) -> ItemListNode { | ||
1349 | ItemListNode { syntax: self.syntax.owned() } | ||
1350 | } | ||
1351 | } | ||
1352 | |||
1353 | |||
1268 | impl<'a> ast::FnDefOwner<'a> for ItemList<'a> {} | 1354 | impl<'a> ast::FnDefOwner<'a> for ItemList<'a> {} |
1269 | impl<'a> ast::ModuleItemOwner<'a> for ItemList<'a> {} | 1355 | impl<'a> ast::ModuleItemOwner<'a> for ItemList<'a> {} |
1270 | impl<'a> ItemList<'a> {} | 1356 | impl<'a> ItemList<'a> {} |
1271 | 1357 | ||
1272 | // Label | 1358 | // Label |
1273 | 1359 | #[derive(Debug, Clone, Copy,)] | |
1274 | #[derive(Debug, Clone)] | 1360 | pub struct LabelNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
1275 | pub struct LabelNode(SyntaxNode); | 1361 | pub(crate) syntax: SyntaxNode<R>, |
1276 | |||
1277 | impl LabelNode { | ||
1278 | pub fn ast(&self) -> Label { | ||
1279 | Label::cast(self.0.borrowed()).unwrap() | ||
1280 | } | ||
1281 | } | 1362 | } |
1363 | pub type Label<'a> = LabelNode<RefRoot<'a>>; | ||
1282 | 1364 | ||
1283 | impl<'a> From<Label<'a>> for LabelNode { | 1365 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<LabelNode<R1>> for LabelNode<R2> { |
1284 | fn from(ast: Label<'a>) -> LabelNode { | 1366 | fn eq(&self, other: &LabelNode<R1>) -> bool { self.syntax == other.syntax } |
1285 | let syntax = ast.syntax().owned(); | ||
1286 | LabelNode(syntax) | ||
1287 | } | ||
1288 | } | 1367 | } |
1289 | #[derive(Debug, Clone, Copy)] | 1368 | impl<R: TreeRoot<RaTypes>> Eq for LabelNode<R> {} |
1290 | pub struct Label<'a> { | 1369 | impl<R: TreeRoot<RaTypes>> Hash for LabelNode<R> { |
1291 | syntax: SyntaxNodeRef<'a>, | 1370 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } |
1292 | } | 1371 | } |
1293 | 1372 | ||
1294 | impl<'a> AstNode<'a> for Label<'a> { | 1373 | impl<'a> AstNode<'a> for Label<'a> { |
@@ -1301,28 +1380,31 @@ impl<'a> AstNode<'a> for Label<'a> { | |||
1301 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 1380 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
1302 | } | 1381 | } |
1303 | 1382 | ||
1304 | impl<'a> Label<'a> {} | 1383 | impl<R: TreeRoot<RaTypes>> LabelNode<R> { |
1384 | pub fn borrowed(&self) -> Label { | ||
1385 | LabelNode { syntax: self.syntax.borrowed() } | ||
1386 | } | ||
1387 | pub fn owned(&self) -> LabelNode { | ||
1388 | LabelNode { syntax: self.syntax.owned() } | ||
1389 | } | ||
1390 | } | ||
1305 | 1391 | ||
1306 | // LambdaExpr | ||
1307 | 1392 | ||
1308 | #[derive(Debug, Clone)] | 1393 | impl<'a> Label<'a> {} |
1309 | pub struct LambdaExprNode(SyntaxNode); | ||
1310 | 1394 | ||
1311 | impl LambdaExprNode { | 1395 | // LambdaExpr |
1312 | pub fn ast(&self) -> LambdaExpr { | 1396 | #[derive(Debug, Clone, Copy,)] |
1313 | LambdaExpr::cast(self.0.borrowed()).unwrap() | 1397 | pub struct LambdaExprNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
1314 | } | 1398 | pub(crate) syntax: SyntaxNode<R>, |
1315 | } | 1399 | } |
1400 | pub type LambdaExpr<'a> = LambdaExprNode<RefRoot<'a>>; | ||
1316 | 1401 | ||
1317 | impl<'a> From<LambdaExpr<'a>> for LambdaExprNode { | 1402 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<LambdaExprNode<R1>> for LambdaExprNode<R2> { |
1318 | fn from(ast: LambdaExpr<'a>) -> LambdaExprNode { | 1403 | fn eq(&self, other: &LambdaExprNode<R1>) -> bool { self.syntax == other.syntax } |
1319 | let syntax = ast.syntax().owned(); | ||
1320 | LambdaExprNode(syntax) | ||
1321 | } | ||
1322 | } | 1404 | } |
1323 | #[derive(Debug, Clone, Copy)] | 1405 | impl<R: TreeRoot<RaTypes>> Eq for LambdaExprNode<R> {} |
1324 | pub struct LambdaExpr<'a> { | 1406 | impl<R: TreeRoot<RaTypes>> Hash for LambdaExprNode<R> { |
1325 | syntax: SyntaxNodeRef<'a>, | 1407 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } |
1326 | } | 1408 | } |
1327 | 1409 | ||
1328 | impl<'a> AstNode<'a> for LambdaExpr<'a> { | 1410 | impl<'a> AstNode<'a> for LambdaExpr<'a> { |
@@ -1335,6 +1417,16 @@ impl<'a> AstNode<'a> for LambdaExpr<'a> { | |||
1335 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 1417 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
1336 | } | 1418 | } |
1337 | 1419 | ||
1420 | impl<R: TreeRoot<RaTypes>> LambdaExprNode<R> { | ||
1421 | pub fn borrowed(&self) -> LambdaExpr { | ||
1422 | LambdaExprNode { syntax: self.syntax.borrowed() } | ||
1423 | } | ||
1424 | pub fn owned(&self) -> LambdaExprNode { | ||
1425 | LambdaExprNode { syntax: self.syntax.owned() } | ||
1426 | } | ||
1427 | } | ||
1428 | |||
1429 | |||
1338 | impl<'a> LambdaExpr<'a> { | 1430 | impl<'a> LambdaExpr<'a> { |
1339 | pub fn param_list(self) -> Option<ParamList<'a>> { | 1431 | pub fn param_list(self) -> Option<ParamList<'a>> { |
1340 | super::child_opt(self) | 1432 | super::child_opt(self) |
@@ -1346,25 +1438,18 @@ impl<'a> LambdaExpr<'a> { | |||
1346 | } | 1438 | } |
1347 | 1439 | ||
1348 | // LetStmt | 1440 | // LetStmt |
1349 | 1441 | #[derive(Debug, Clone, Copy,)] | |
1350 | #[derive(Debug, Clone)] | 1442 | pub struct LetStmtNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
1351 | pub struct LetStmtNode(SyntaxNode); | 1443 | pub(crate) syntax: SyntaxNode<R>, |
1352 | |||
1353 | impl LetStmtNode { | ||
1354 | pub fn ast(&self) -> LetStmt { | ||
1355 | LetStmt::cast(self.0.borrowed()).unwrap() | ||
1356 | } | ||
1357 | } | 1444 | } |
1445 | pub type LetStmt<'a> = LetStmtNode<RefRoot<'a>>; | ||
1358 | 1446 | ||
1359 | impl<'a> From<LetStmt<'a>> for LetStmtNode { | 1447 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<LetStmtNode<R1>> for LetStmtNode<R2> { |
1360 | fn from(ast: LetStmt<'a>) -> LetStmtNode { | 1448 | fn eq(&self, other: &LetStmtNode<R1>) -> bool { self.syntax == other.syntax } |
1361 | let syntax = ast.syntax().owned(); | ||
1362 | LetStmtNode(syntax) | ||
1363 | } | ||
1364 | } | 1449 | } |
1365 | #[derive(Debug, Clone, Copy)] | 1450 | impl<R: TreeRoot<RaTypes>> Eq for LetStmtNode<R> {} |
1366 | pub struct LetStmt<'a> { | 1451 | impl<R: TreeRoot<RaTypes>> Hash for LetStmtNode<R> { |
1367 | syntax: SyntaxNodeRef<'a>, | 1452 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } |
1368 | } | 1453 | } |
1369 | 1454 | ||
1370 | impl<'a> AstNode<'a> for LetStmt<'a> { | 1455 | impl<'a> AstNode<'a> for LetStmt<'a> { |
@@ -1377,6 +1462,16 @@ impl<'a> AstNode<'a> for LetStmt<'a> { | |||
1377 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 1462 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
1378 | } | 1463 | } |
1379 | 1464 | ||
1465 | impl<R: TreeRoot<RaTypes>> LetStmtNode<R> { | ||
1466 | pub fn borrowed(&self) -> LetStmt { | ||
1467 | LetStmtNode { syntax: self.syntax.borrowed() } | ||
1468 | } | ||
1469 | pub fn owned(&self) -> LetStmtNode { | ||
1470 | LetStmtNode { syntax: self.syntax.owned() } | ||
1471 | } | ||
1472 | } | ||
1473 | |||
1474 | |||
1380 | impl<'a> LetStmt<'a> { | 1475 | impl<'a> LetStmt<'a> { |
1381 | pub fn pat(self) -> Option<Pat<'a>> { | 1476 | pub fn pat(self) -> Option<Pat<'a>> { |
1382 | super::child_opt(self) | 1477 | super::child_opt(self) |
@@ -1388,25 +1483,18 @@ impl<'a> LetStmt<'a> { | |||
1388 | } | 1483 | } |
1389 | 1484 | ||
1390 | // Lifetime | 1485 | // Lifetime |
1391 | 1486 | #[derive(Debug, Clone, Copy,)] | |
1392 | #[derive(Debug, Clone)] | 1487 | pub struct LifetimeNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
1393 | pub struct LifetimeNode(SyntaxNode); | 1488 | pub(crate) syntax: SyntaxNode<R>, |
1394 | |||
1395 | impl LifetimeNode { | ||
1396 | pub fn ast(&self) -> Lifetime { | ||
1397 | Lifetime::cast(self.0.borrowed()).unwrap() | ||
1398 | } | ||
1399 | } | 1489 | } |
1490 | pub type Lifetime<'a> = LifetimeNode<RefRoot<'a>>; | ||
1400 | 1491 | ||
1401 | impl<'a> From<Lifetime<'a>> for LifetimeNode { | 1492 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<LifetimeNode<R1>> for LifetimeNode<R2> { |
1402 | fn from(ast: Lifetime<'a>) -> LifetimeNode { | 1493 | fn eq(&self, other: &LifetimeNode<R1>) -> bool { self.syntax == other.syntax } |
1403 | let syntax = ast.syntax().owned(); | ||
1404 | LifetimeNode(syntax) | ||
1405 | } | ||
1406 | } | 1494 | } |
1407 | #[derive(Debug, Clone, Copy)] | 1495 | impl<R: TreeRoot<RaTypes>> Eq for LifetimeNode<R> {} |
1408 | pub struct Lifetime<'a> { | 1496 | impl<R: TreeRoot<RaTypes>> Hash for LifetimeNode<R> { |
1409 | syntax: SyntaxNodeRef<'a>, | 1497 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } |
1410 | } | 1498 | } |
1411 | 1499 | ||
1412 | impl<'a> AstNode<'a> for Lifetime<'a> { | 1500 | impl<'a> AstNode<'a> for Lifetime<'a> { |
@@ -1419,28 +1507,31 @@ impl<'a> AstNode<'a> for Lifetime<'a> { | |||
1419 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 1507 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
1420 | } | 1508 | } |
1421 | 1509 | ||
1422 | impl<'a> Lifetime<'a> {} | 1510 | impl<R: TreeRoot<RaTypes>> LifetimeNode<R> { |
1511 | pub fn borrowed(&self) -> Lifetime { | ||
1512 | LifetimeNode { syntax: self.syntax.borrowed() } | ||
1513 | } | ||
1514 | pub fn owned(&self) -> LifetimeNode { | ||
1515 | LifetimeNode { syntax: self.syntax.owned() } | ||
1516 | } | ||
1517 | } | ||
1423 | 1518 | ||
1424 | // LifetimeParam | ||
1425 | 1519 | ||
1426 | #[derive(Debug, Clone)] | 1520 | impl<'a> Lifetime<'a> {} |
1427 | pub struct LifetimeParamNode(SyntaxNode); | ||
1428 | 1521 | ||
1429 | impl LifetimeParamNode { | 1522 | // LifetimeParam |
1430 | pub fn ast(&self) -> LifetimeParam { | 1523 | #[derive(Debug, Clone, Copy,)] |
1431 | LifetimeParam::cast(self.0.borrowed()).unwrap() | 1524 | pub struct LifetimeParamNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
1432 | } | 1525 | pub(crate) syntax: SyntaxNode<R>, |
1433 | } | 1526 | } |
1527 | pub type LifetimeParam<'a> = LifetimeParamNode<RefRoot<'a>>; | ||
1434 | 1528 | ||
1435 | impl<'a> From<LifetimeParam<'a>> for LifetimeParamNode { | 1529 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<LifetimeParamNode<R1>> for LifetimeParamNode<R2> { |
1436 | fn from(ast: LifetimeParam<'a>) -> LifetimeParamNode { | 1530 | fn eq(&self, other: &LifetimeParamNode<R1>) -> bool { self.syntax == other.syntax } |
1437 | let syntax = ast.syntax().owned(); | ||
1438 | LifetimeParamNode(syntax) | ||
1439 | } | ||
1440 | } | 1531 | } |
1441 | #[derive(Debug, Clone, Copy)] | 1532 | impl<R: TreeRoot<RaTypes>> Eq for LifetimeParamNode<R> {} |
1442 | pub struct LifetimeParam<'a> { | 1533 | impl<R: TreeRoot<RaTypes>> Hash for LifetimeParamNode<R> { |
1443 | syntax: SyntaxNodeRef<'a>, | 1534 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } |
1444 | } | 1535 | } |
1445 | 1536 | ||
1446 | impl<'a> AstNode<'a> for LifetimeParam<'a> { | 1537 | impl<'a> AstNode<'a> for LifetimeParam<'a> { |
@@ -1453,6 +1544,16 @@ impl<'a> AstNode<'a> for LifetimeParam<'a> { | |||
1453 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 1544 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
1454 | } | 1545 | } |
1455 | 1546 | ||
1547 | impl<R: TreeRoot<RaTypes>> LifetimeParamNode<R> { | ||
1548 | pub fn borrowed(&self) -> LifetimeParam { | ||
1549 | LifetimeParamNode { syntax: self.syntax.borrowed() } | ||
1550 | } | ||
1551 | pub fn owned(&self) -> LifetimeParamNode { | ||
1552 | LifetimeParamNode { syntax: self.syntax.owned() } | ||
1553 | } | ||
1554 | } | ||
1555 | |||
1556 | |||
1456 | impl<'a> LifetimeParam<'a> { | 1557 | impl<'a> LifetimeParam<'a> { |
1457 | pub fn lifetime(self) -> Option<Lifetime<'a>> { | 1558 | pub fn lifetime(self) -> Option<Lifetime<'a>> { |
1458 | super::child_opt(self) | 1559 | super::child_opt(self) |
@@ -1460,25 +1561,18 @@ impl<'a> LifetimeParam<'a> { | |||
1460 | } | 1561 | } |
1461 | 1562 | ||
1462 | // Literal | 1563 | // Literal |
1463 | 1564 | #[derive(Debug, Clone, Copy,)] | |
1464 | #[derive(Debug, Clone)] | 1565 | pub struct LiteralNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
1465 | pub struct LiteralNode(SyntaxNode); | 1566 | pub(crate) syntax: SyntaxNode<R>, |
1466 | |||
1467 | impl LiteralNode { | ||
1468 | pub fn ast(&self) -> Literal { | ||
1469 | Literal::cast(self.0.borrowed()).unwrap() | ||
1470 | } | ||
1471 | } | 1567 | } |
1568 | pub type Literal<'a> = LiteralNode<RefRoot<'a>>; | ||
1472 | 1569 | ||
1473 | impl<'a> From<Literal<'a>> for LiteralNode { | 1570 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<LiteralNode<R1>> for LiteralNode<R2> { |
1474 | fn from(ast: Literal<'a>) -> LiteralNode { | 1571 | fn eq(&self, other: &LiteralNode<R1>) -> bool { self.syntax == other.syntax } |
1475 | let syntax = ast.syntax().owned(); | ||
1476 | LiteralNode(syntax) | ||
1477 | } | ||
1478 | } | 1572 | } |
1479 | #[derive(Debug, Clone, Copy)] | 1573 | impl<R: TreeRoot<RaTypes>> Eq for LiteralNode<R> {} |
1480 | pub struct Literal<'a> { | 1574 | impl<R: TreeRoot<RaTypes>> Hash for LiteralNode<R> { |
1481 | syntax: SyntaxNodeRef<'a>, | 1575 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } |
1482 | } | 1576 | } |
1483 | 1577 | ||
1484 | impl<'a> AstNode<'a> for Literal<'a> { | 1578 | impl<'a> AstNode<'a> for Literal<'a> { |
@@ -1491,28 +1585,31 @@ impl<'a> AstNode<'a> for Literal<'a> { | |||
1491 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 1585 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
1492 | } | 1586 | } |
1493 | 1587 | ||
1494 | impl<'a> Literal<'a> {} | 1588 | impl<R: TreeRoot<RaTypes>> LiteralNode<R> { |
1589 | pub fn borrowed(&self) -> Literal { | ||
1590 | LiteralNode { syntax: self.syntax.borrowed() } | ||
1591 | } | ||
1592 | pub fn owned(&self) -> LiteralNode { | ||
1593 | LiteralNode { syntax: self.syntax.owned() } | ||
1594 | } | ||
1595 | } | ||
1495 | 1596 | ||
1496 | // LoopExpr | ||
1497 | 1597 | ||
1498 | #[derive(Debug, Clone)] | 1598 | impl<'a> Literal<'a> {} |
1499 | pub struct LoopExprNode(SyntaxNode); | ||
1500 | 1599 | ||
1501 | impl LoopExprNode { | 1600 | // LoopExpr |
1502 | pub fn ast(&self) -> LoopExpr { | 1601 | #[derive(Debug, Clone, Copy,)] |
1503 | LoopExpr::cast(self.0.borrowed()).unwrap() | 1602 | pub struct LoopExprNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
1504 | } | 1603 | pub(crate) syntax: SyntaxNode<R>, |
1505 | } | 1604 | } |
1605 | pub type LoopExpr<'a> = LoopExprNode<RefRoot<'a>>; | ||
1506 | 1606 | ||
1507 | impl<'a> From<LoopExpr<'a>> for LoopExprNode { | 1607 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<LoopExprNode<R1>> for LoopExprNode<R2> { |
1508 | fn from(ast: LoopExpr<'a>) -> LoopExprNode { | 1608 | fn eq(&self, other: &LoopExprNode<R1>) -> bool { self.syntax == other.syntax } |
1509 | let syntax = ast.syntax().owned(); | ||
1510 | LoopExprNode(syntax) | ||
1511 | } | ||
1512 | } | 1609 | } |
1513 | #[derive(Debug, Clone, Copy)] | 1610 | impl<R: TreeRoot<RaTypes>> Eq for LoopExprNode<R> {} |
1514 | pub struct LoopExpr<'a> { | 1611 | impl<R: TreeRoot<RaTypes>> Hash for LoopExprNode<R> { |
1515 | syntax: SyntaxNodeRef<'a>, | 1612 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } |
1516 | } | 1613 | } |
1517 | 1614 | ||
1518 | impl<'a> AstNode<'a> for LoopExpr<'a> { | 1615 | impl<'a> AstNode<'a> for LoopExpr<'a> { |
@@ -1525,29 +1622,32 @@ impl<'a> AstNode<'a> for LoopExpr<'a> { | |||
1525 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 1622 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
1526 | } | 1623 | } |
1527 | 1624 | ||
1625 | impl<R: TreeRoot<RaTypes>> LoopExprNode<R> { | ||
1626 | pub fn borrowed(&self) -> LoopExpr { | ||
1627 | LoopExprNode { syntax: self.syntax.borrowed() } | ||
1628 | } | ||
1629 | pub fn owned(&self) -> LoopExprNode { | ||
1630 | LoopExprNode { syntax: self.syntax.owned() } | ||
1631 | } | ||
1632 | } | ||
1633 | |||
1634 | |||
1528 | impl<'a> ast::LoopBodyOwner<'a> for LoopExpr<'a> {} | 1635 | impl<'a> ast::LoopBodyOwner<'a> for LoopExpr<'a> {} |
1529 | impl<'a> LoopExpr<'a> {} | 1636 | impl<'a> LoopExpr<'a> {} |
1530 | 1637 | ||
1531 | // MatchArm | 1638 | // MatchArm |
1532 | 1639 | #[derive(Debug, Clone, Copy,)] | |
1533 | #[derive(Debug, Clone)] | 1640 | pub struct MatchArmNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
1534 | pub struct MatchArmNode(SyntaxNode); | 1641 | pub(crate) syntax: SyntaxNode<R>, |
1535 | |||
1536 | impl MatchArmNode { | ||
1537 | pub fn ast(&self) -> MatchArm { | ||
1538 | MatchArm::cast(self.0.borrowed()).unwrap() | ||
1539 | } | ||
1540 | } | 1642 | } |
1643 | pub type MatchArm<'a> = MatchArmNode<RefRoot<'a>>; | ||
1541 | 1644 | ||
1542 | impl<'a> From<MatchArm<'a>> for MatchArmNode { | 1645 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<MatchArmNode<R1>> for MatchArmNode<R2> { |
1543 | fn from(ast: MatchArm<'a>) -> MatchArmNode { | 1646 | fn eq(&self, other: &MatchArmNode<R1>) -> bool { self.syntax == other.syntax } |
1544 | let syntax = ast.syntax().owned(); | ||
1545 | MatchArmNode(syntax) | ||
1546 | } | ||
1547 | } | 1647 | } |
1548 | #[derive(Debug, Clone, Copy)] | 1648 | impl<R: TreeRoot<RaTypes>> Eq for MatchArmNode<R> {} |
1549 | pub struct MatchArm<'a> { | 1649 | impl<R: TreeRoot<RaTypes>> Hash for MatchArmNode<R> { |
1550 | syntax: SyntaxNodeRef<'a>, | 1650 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } |
1551 | } | 1651 | } |
1552 | 1652 | ||
1553 | impl<'a> AstNode<'a> for MatchArm<'a> { | 1653 | impl<'a> AstNode<'a> for MatchArm<'a> { |
@@ -1560,6 +1660,16 @@ impl<'a> AstNode<'a> for MatchArm<'a> { | |||
1560 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 1660 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
1561 | } | 1661 | } |
1562 | 1662 | ||
1663 | impl<R: TreeRoot<RaTypes>> MatchArmNode<R> { | ||
1664 | pub fn borrowed(&self) -> MatchArm { | ||
1665 | MatchArmNode { syntax: self.syntax.borrowed() } | ||
1666 | } | ||
1667 | pub fn owned(&self) -> MatchArmNode { | ||
1668 | MatchArmNode { syntax: self.syntax.owned() } | ||
1669 | } | ||
1670 | } | ||
1671 | |||
1672 | |||
1563 | impl<'a> MatchArm<'a> { | 1673 | impl<'a> MatchArm<'a> { |
1564 | pub fn pats(self) -> impl Iterator<Item = Pat<'a>> + 'a { | 1674 | pub fn pats(self) -> impl Iterator<Item = Pat<'a>> + 'a { |
1565 | super::children(self) | 1675 | super::children(self) |
@@ -1575,25 +1685,18 @@ impl<'a> MatchArm<'a> { | |||
1575 | } | 1685 | } |
1576 | 1686 | ||
1577 | // MatchArmList | 1687 | // MatchArmList |
1578 | 1688 | #[derive(Debug, Clone, Copy,)] | |
1579 | #[derive(Debug, Clone)] | 1689 | pub struct MatchArmListNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
1580 | pub struct MatchArmListNode(SyntaxNode); | 1690 | pub(crate) syntax: SyntaxNode<R>, |
1581 | |||
1582 | impl MatchArmListNode { | ||
1583 | pub fn ast(&self) -> MatchArmList { | ||
1584 | MatchArmList::cast(self.0.borrowed()).unwrap() | ||
1585 | } | ||
1586 | } | 1691 | } |
1692 | pub type MatchArmList<'a> = MatchArmListNode<RefRoot<'a>>; | ||
1587 | 1693 | ||
1588 | impl<'a> From<MatchArmList<'a>> for MatchArmListNode { | 1694 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<MatchArmListNode<R1>> for MatchArmListNode<R2> { |
1589 | fn from(ast: MatchArmList<'a>) -> MatchArmListNode { | 1695 | fn eq(&self, other: &MatchArmListNode<R1>) -> bool { self.syntax == other.syntax } |
1590 | let syntax = ast.syntax().owned(); | ||
1591 | MatchArmListNode(syntax) | ||
1592 | } | ||
1593 | } | 1696 | } |
1594 | #[derive(Debug, Clone, Copy)] | 1697 | impl<R: TreeRoot<RaTypes>> Eq for MatchArmListNode<R> {} |
1595 | pub struct MatchArmList<'a> { | 1698 | impl<R: TreeRoot<RaTypes>> Hash for MatchArmListNode<R> { |
1596 | syntax: SyntaxNodeRef<'a>, | 1699 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } |
1597 | } | 1700 | } |
1598 | 1701 | ||
1599 | impl<'a> AstNode<'a> for MatchArmList<'a> { | 1702 | impl<'a> AstNode<'a> for MatchArmList<'a> { |
@@ -1606,6 +1709,16 @@ impl<'a> AstNode<'a> for MatchArmList<'a> { | |||
1606 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 1709 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
1607 | } | 1710 | } |
1608 | 1711 | ||
1712 | impl<R: TreeRoot<RaTypes>> MatchArmListNode<R> { | ||
1713 | pub fn borrowed(&self) -> MatchArmList { | ||
1714 | MatchArmListNode { syntax: self.syntax.borrowed() } | ||
1715 | } | ||
1716 | pub fn owned(&self) -> MatchArmListNode { | ||
1717 | MatchArmListNode { syntax: self.syntax.owned() } | ||
1718 | } | ||
1719 | } | ||
1720 | |||
1721 | |||
1609 | impl<'a> MatchArmList<'a> { | 1722 | impl<'a> MatchArmList<'a> { |
1610 | pub fn arms(self) -> impl Iterator<Item = MatchArm<'a>> + 'a { | 1723 | pub fn arms(self) -> impl Iterator<Item = MatchArm<'a>> + 'a { |
1611 | super::children(self) | 1724 | super::children(self) |
@@ -1613,25 +1726,18 @@ impl<'a> MatchArmList<'a> { | |||
1613 | } | 1726 | } |
1614 | 1727 | ||
1615 | // MatchExpr | 1728 | // MatchExpr |
1616 | 1729 | #[derive(Debug, Clone, Copy,)] | |
1617 | #[derive(Debug, Clone)] | 1730 | pub struct MatchExprNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
1618 | pub struct MatchExprNode(SyntaxNode); | 1731 | pub(crate) syntax: SyntaxNode<R>, |
1619 | |||
1620 | impl MatchExprNode { | ||
1621 | pub fn ast(&self) -> MatchExpr { | ||
1622 | MatchExpr::cast(self.0.borrowed()).unwrap() | ||
1623 | } | ||
1624 | } | 1732 | } |
1733 | pub type MatchExpr<'a> = MatchExprNode<RefRoot<'a>>; | ||
1625 | 1734 | ||
1626 | impl<'a> From<MatchExpr<'a>> for MatchExprNode { | 1735 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<MatchExprNode<R1>> for MatchExprNode<R2> { |
1627 | fn from(ast: MatchExpr<'a>) -> MatchExprNode { | 1736 | fn eq(&self, other: &MatchExprNode<R1>) -> bool { self.syntax == other.syntax } |
1628 | let syntax = ast.syntax().owned(); | ||
1629 | MatchExprNode(syntax) | ||
1630 | } | ||
1631 | } | 1737 | } |
1632 | #[derive(Debug, Clone, Copy)] | 1738 | impl<R: TreeRoot<RaTypes>> Eq for MatchExprNode<R> {} |
1633 | pub struct MatchExpr<'a> { | 1739 | impl<R: TreeRoot<RaTypes>> Hash for MatchExprNode<R> { |
1634 | syntax: SyntaxNodeRef<'a>, | 1740 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } |
1635 | } | 1741 | } |
1636 | 1742 | ||
1637 | impl<'a> AstNode<'a> for MatchExpr<'a> { | 1743 | impl<'a> AstNode<'a> for MatchExpr<'a> { |
@@ -1644,6 +1750,16 @@ impl<'a> AstNode<'a> for MatchExpr<'a> { | |||
1644 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 1750 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
1645 | } | 1751 | } |
1646 | 1752 | ||
1753 | impl<R: TreeRoot<RaTypes>> MatchExprNode<R> { | ||
1754 | pub fn borrowed(&self) -> MatchExpr { | ||
1755 | MatchExprNode { syntax: self.syntax.borrowed() } | ||
1756 | } | ||
1757 | pub fn owned(&self) -> MatchExprNode { | ||
1758 | MatchExprNode { syntax: self.syntax.owned() } | ||
1759 | } | ||
1760 | } | ||
1761 | |||
1762 | |||
1647 | impl<'a> MatchExpr<'a> { | 1763 | impl<'a> MatchExpr<'a> { |
1648 | pub fn expr(self) -> Option<Expr<'a>> { | 1764 | pub fn expr(self) -> Option<Expr<'a>> { |
1649 | super::child_opt(self) | 1765 | super::child_opt(self) |
@@ -1655,25 +1771,18 @@ impl<'a> MatchExpr<'a> { | |||
1655 | } | 1771 | } |
1656 | 1772 | ||
1657 | // MatchGuard | 1773 | // MatchGuard |
1658 | 1774 | #[derive(Debug, Clone, Copy,)] | |
1659 | #[derive(Debug, Clone)] | 1775 | pub struct MatchGuardNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
1660 | pub struct MatchGuardNode(SyntaxNode); | 1776 | pub(crate) syntax: SyntaxNode<R>, |
1661 | |||
1662 | impl MatchGuardNode { | ||
1663 | pub fn ast(&self) -> MatchGuard { | ||
1664 | MatchGuard::cast(self.0.borrowed()).unwrap() | ||
1665 | } | ||
1666 | } | 1777 | } |
1778 | pub type MatchGuard<'a> = MatchGuardNode<RefRoot<'a>>; | ||
1667 | 1779 | ||
1668 | impl<'a> From<MatchGuard<'a>> for MatchGuardNode { | 1780 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<MatchGuardNode<R1>> for MatchGuardNode<R2> { |
1669 | fn from(ast: MatchGuard<'a>) -> MatchGuardNode { | 1781 | fn eq(&self, other: &MatchGuardNode<R1>) -> bool { self.syntax == other.syntax } |
1670 | let syntax = ast.syntax().owned(); | ||
1671 | MatchGuardNode(syntax) | ||
1672 | } | ||
1673 | } | 1782 | } |
1674 | #[derive(Debug, Clone, Copy)] | 1783 | impl<R: TreeRoot<RaTypes>> Eq for MatchGuardNode<R> {} |
1675 | pub struct MatchGuard<'a> { | 1784 | impl<R: TreeRoot<RaTypes>> Hash for MatchGuardNode<R> { |
1676 | syntax: SyntaxNodeRef<'a>, | 1785 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } |
1677 | } | 1786 | } |
1678 | 1787 | ||
1679 | impl<'a> AstNode<'a> for MatchGuard<'a> { | 1788 | impl<'a> AstNode<'a> for MatchGuard<'a> { |
@@ -1686,28 +1795,31 @@ impl<'a> AstNode<'a> for MatchGuard<'a> { | |||
1686 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 1795 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
1687 | } | 1796 | } |
1688 | 1797 | ||
1689 | impl<'a> MatchGuard<'a> {} | 1798 | impl<R: TreeRoot<RaTypes>> MatchGuardNode<R> { |
1799 | pub fn borrowed(&self) -> MatchGuard { | ||
1800 | MatchGuardNode { syntax: self.syntax.borrowed() } | ||
1801 | } | ||
1802 | pub fn owned(&self) -> MatchGuardNode { | ||
1803 | MatchGuardNode { syntax: self.syntax.owned() } | ||
1804 | } | ||
1805 | } | ||
1690 | 1806 | ||
1691 | // MethodCallExpr | ||
1692 | 1807 | ||
1693 | #[derive(Debug, Clone)] | 1808 | impl<'a> MatchGuard<'a> {} |
1694 | pub struct MethodCallExprNode(SyntaxNode); | ||
1695 | 1809 | ||
1696 | impl MethodCallExprNode { | 1810 | // MethodCallExpr |
1697 | pub fn ast(&self) -> MethodCallExpr { | 1811 | #[derive(Debug, Clone, Copy,)] |
1698 | MethodCallExpr::cast(self.0.borrowed()).unwrap() | 1812 | pub struct MethodCallExprNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
1699 | } | 1813 | pub(crate) syntax: SyntaxNode<R>, |
1700 | } | 1814 | } |
1815 | pub type MethodCallExpr<'a> = MethodCallExprNode<RefRoot<'a>>; | ||
1701 | 1816 | ||
1702 | impl<'a> From<MethodCallExpr<'a>> for MethodCallExprNode { | 1817 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<MethodCallExprNode<R1>> for MethodCallExprNode<R2> { |
1703 | fn from(ast: MethodCallExpr<'a>) -> MethodCallExprNode { | 1818 | fn eq(&self, other: &MethodCallExprNode<R1>) -> bool { self.syntax == other.syntax } |
1704 | let syntax = ast.syntax().owned(); | ||
1705 | MethodCallExprNode(syntax) | ||
1706 | } | ||
1707 | } | 1819 | } |
1708 | #[derive(Debug, Clone, Copy)] | 1820 | impl<R: TreeRoot<RaTypes>> Eq for MethodCallExprNode<R> {} |
1709 | pub struct MethodCallExpr<'a> { | 1821 | impl<R: TreeRoot<RaTypes>> Hash for MethodCallExprNode<R> { |
1710 | syntax: SyntaxNodeRef<'a>, | 1822 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } |
1711 | } | 1823 | } |
1712 | 1824 | ||
1713 | impl<'a> AstNode<'a> for MethodCallExpr<'a> { | 1825 | impl<'a> AstNode<'a> for MethodCallExpr<'a> { |
@@ -1720,6 +1832,16 @@ impl<'a> AstNode<'a> for MethodCallExpr<'a> { | |||
1720 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 1832 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
1721 | } | 1833 | } |
1722 | 1834 | ||
1835 | impl<R: TreeRoot<RaTypes>> MethodCallExprNode<R> { | ||
1836 | pub fn borrowed(&self) -> MethodCallExpr { | ||
1837 | MethodCallExprNode { syntax: self.syntax.borrowed() } | ||
1838 | } | ||
1839 | pub fn owned(&self) -> MethodCallExprNode { | ||
1840 | MethodCallExprNode { syntax: self.syntax.owned() } | ||
1841 | } | ||
1842 | } | ||
1843 | |||
1844 | |||
1723 | impl<'a> ast::ArgListOwner<'a> for MethodCallExpr<'a> {} | 1845 | impl<'a> ast::ArgListOwner<'a> for MethodCallExpr<'a> {} |
1724 | impl<'a> MethodCallExpr<'a> { | 1846 | impl<'a> MethodCallExpr<'a> { |
1725 | pub fn expr(self) -> Option<Expr<'a>> { | 1847 | pub fn expr(self) -> Option<Expr<'a>> { |
@@ -1728,25 +1850,18 @@ impl<'a> MethodCallExpr<'a> { | |||
1728 | } | 1850 | } |
1729 | 1851 | ||
1730 | // Module | 1852 | // Module |
1731 | 1853 | #[derive(Debug, Clone, Copy,)] | |
1732 | #[derive(Debug, Clone)] | 1854 | pub struct ModuleNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
1733 | pub struct ModuleNode(SyntaxNode); | 1855 | pub(crate) syntax: SyntaxNode<R>, |
1734 | |||
1735 | impl ModuleNode { | ||
1736 | pub fn ast(&self) -> Module { | ||
1737 | Module::cast(self.0.borrowed()).unwrap() | ||
1738 | } | ||
1739 | } | 1856 | } |
1857 | pub type Module<'a> = ModuleNode<RefRoot<'a>>; | ||
1740 | 1858 | ||
1741 | impl<'a> From<Module<'a>> for ModuleNode { | 1859 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<ModuleNode<R1>> for ModuleNode<R2> { |
1742 | fn from(ast: Module<'a>) -> ModuleNode { | 1860 | fn eq(&self, other: &ModuleNode<R1>) -> bool { self.syntax == other.syntax } |
1743 | let syntax = ast.syntax().owned(); | ||
1744 | ModuleNode(syntax) | ||
1745 | } | ||
1746 | } | 1861 | } |
1747 | #[derive(Debug, Clone, Copy)] | 1862 | impl<R: TreeRoot<RaTypes>> Eq for ModuleNode<R> {} |
1748 | pub struct Module<'a> { | 1863 | impl<R: TreeRoot<RaTypes>> Hash for ModuleNode<R> { |
1749 | syntax: SyntaxNodeRef<'a>, | 1864 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } |
1750 | } | 1865 | } |
1751 | 1866 | ||
1752 | impl<'a> AstNode<'a> for Module<'a> { | 1867 | impl<'a> AstNode<'a> for Module<'a> { |
@@ -1759,6 +1874,16 @@ impl<'a> AstNode<'a> for Module<'a> { | |||
1759 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 1874 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
1760 | } | 1875 | } |
1761 | 1876 | ||
1877 | impl<R: TreeRoot<RaTypes>> ModuleNode<R> { | ||
1878 | pub fn borrowed(&self) -> Module { | ||
1879 | ModuleNode { syntax: self.syntax.borrowed() } | ||
1880 | } | ||
1881 | pub fn owned(&self) -> ModuleNode { | ||
1882 | ModuleNode { syntax: self.syntax.owned() } | ||
1883 | } | ||
1884 | } | ||
1885 | |||
1886 | |||
1762 | impl<'a> ast::NameOwner<'a> for Module<'a> {} | 1887 | impl<'a> ast::NameOwner<'a> for Module<'a> {} |
1763 | impl<'a> ast::AttrsOwner<'a> for Module<'a> {} | 1888 | impl<'a> ast::AttrsOwner<'a> for Module<'a> {} |
1764 | impl<'a> Module<'a> { | 1889 | impl<'a> Module<'a> { |
@@ -1768,23 +1893,7 @@ impl<'a> Module<'a> { | |||
1768 | } | 1893 | } |
1769 | 1894 | ||
1770 | // ModuleItem | 1895 | // ModuleItem |
1771 | 1896 | #[derive(Debug, Clone, Copy, PartialEq, Eq)] | |
1772 | #[derive(Debug, Clone)] | ||
1773 | pub struct ModuleItemNode(SyntaxNode); | ||
1774 | |||
1775 | impl ModuleItemNode { | ||
1776 | pub fn ast(&self) -> ModuleItem { | ||
1777 | ModuleItem::cast(self.0.borrowed()).unwrap() | ||
1778 | } | ||
1779 | } | ||
1780 | |||
1781 | impl<'a> From<ModuleItem<'a>> for ModuleItemNode { | ||
1782 | fn from(ast: ModuleItem<'a>) -> ModuleItemNode { | ||
1783 | let syntax = ast.syntax().owned(); | ||
1784 | ModuleItemNode(syntax) | ||
1785 | } | ||
1786 | } | ||
1787 | #[derive(Debug, Clone, Copy)] | ||
1788 | pub enum ModuleItem<'a> { | 1897 | pub enum ModuleItem<'a> { |
1789 | StructDef(StructDef<'a>), | 1898 | StructDef(StructDef<'a>), |
1790 | EnumDef(EnumDef<'a>), | 1899 | EnumDef(EnumDef<'a>), |
@@ -1836,25 +1945,18 @@ impl<'a> AstNode<'a> for ModuleItem<'a> { | |||
1836 | impl<'a> ModuleItem<'a> {} | 1945 | impl<'a> ModuleItem<'a> {} |
1837 | 1946 | ||
1838 | // Name | 1947 | // Name |
1839 | 1948 | #[derive(Debug, Clone, Copy,)] | |
1840 | #[derive(Debug, Clone)] | 1949 | pub struct NameNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
1841 | pub struct NameNode(SyntaxNode); | 1950 | pub(crate) syntax: SyntaxNode<R>, |
1842 | |||
1843 | impl NameNode { | ||
1844 | pub fn ast(&self) -> Name { | ||
1845 | Name::cast(self.0.borrowed()).unwrap() | ||
1846 | } | ||
1847 | } | 1951 | } |
1952 | pub type Name<'a> = NameNode<RefRoot<'a>>; | ||
1848 | 1953 | ||
1849 | impl<'a> From<Name<'a>> for NameNode { | 1954 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<NameNode<R1>> for NameNode<R2> { |
1850 | fn from(ast: Name<'a>) -> NameNode { | 1955 | fn eq(&self, other: &NameNode<R1>) -> bool { self.syntax == other.syntax } |
1851 | let syntax = ast.syntax().owned(); | ||
1852 | NameNode(syntax) | ||
1853 | } | ||
1854 | } | 1956 | } |
1855 | #[derive(Debug, Clone, Copy)] | 1957 | impl<R: TreeRoot<RaTypes>> Eq for NameNode<R> {} |
1856 | pub struct Name<'a> { | 1958 | impl<R: TreeRoot<RaTypes>> Hash for NameNode<R> { |
1857 | syntax: SyntaxNodeRef<'a>, | 1959 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } |
1858 | } | 1960 | } |
1859 | 1961 | ||
1860 | impl<'a> AstNode<'a> for Name<'a> { | 1962 | impl<'a> AstNode<'a> for Name<'a> { |
@@ -1867,28 +1969,31 @@ impl<'a> AstNode<'a> for Name<'a> { | |||
1867 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 1969 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
1868 | } | 1970 | } |
1869 | 1971 | ||
1870 | impl<'a> Name<'a> {} | 1972 | impl<R: TreeRoot<RaTypes>> NameNode<R> { |
1973 | pub fn borrowed(&self) -> Name { | ||
1974 | NameNode { syntax: self.syntax.borrowed() } | ||
1975 | } | ||
1976 | pub fn owned(&self) -> NameNode { | ||
1977 | NameNode { syntax: self.syntax.owned() } | ||
1978 | } | ||
1979 | } | ||
1871 | 1980 | ||
1872 | // NameRef | ||
1873 | 1981 | ||
1874 | #[derive(Debug, Clone)] | 1982 | impl<'a> Name<'a> {} |
1875 | pub struct NameRefNode(SyntaxNode); | ||
1876 | 1983 | ||
1877 | impl NameRefNode { | 1984 | // NameRef |
1878 | pub fn ast(&self) -> NameRef { | 1985 | #[derive(Debug, Clone, Copy,)] |
1879 | NameRef::cast(self.0.borrowed()).unwrap() | 1986 | pub struct NameRefNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
1880 | } | 1987 | pub(crate) syntax: SyntaxNode<R>, |
1881 | } | 1988 | } |
1989 | pub type NameRef<'a> = NameRefNode<RefRoot<'a>>; | ||
1882 | 1990 | ||
1883 | impl<'a> From<NameRef<'a>> for NameRefNode { | 1991 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<NameRefNode<R1>> for NameRefNode<R2> { |
1884 | fn from(ast: NameRef<'a>) -> NameRefNode { | 1992 | fn eq(&self, other: &NameRefNode<R1>) -> bool { self.syntax == other.syntax } |
1885 | let syntax = ast.syntax().owned(); | ||
1886 | NameRefNode(syntax) | ||
1887 | } | ||
1888 | } | 1993 | } |
1889 | #[derive(Debug, Clone, Copy)] | 1994 | impl<R: TreeRoot<RaTypes>> Eq for NameRefNode<R> {} |
1890 | pub struct NameRef<'a> { | 1995 | impl<R: TreeRoot<RaTypes>> Hash for NameRefNode<R> { |
1891 | syntax: SyntaxNodeRef<'a>, | 1996 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } |
1892 | } | 1997 | } |
1893 | 1998 | ||
1894 | impl<'a> AstNode<'a> for NameRef<'a> { | 1999 | impl<'a> AstNode<'a> for NameRef<'a> { |
@@ -1901,28 +2006,31 @@ impl<'a> AstNode<'a> for NameRef<'a> { | |||
1901 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 2006 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
1902 | } | 2007 | } |
1903 | 2008 | ||
1904 | impl<'a> NameRef<'a> {} | 2009 | impl<R: TreeRoot<RaTypes>> NameRefNode<R> { |
2010 | pub fn borrowed(&self) -> NameRef { | ||
2011 | NameRefNode { syntax: self.syntax.borrowed() } | ||
2012 | } | ||
2013 | pub fn owned(&self) -> NameRefNode { | ||
2014 | NameRefNode { syntax: self.syntax.owned() } | ||
2015 | } | ||
2016 | } | ||
1905 | 2017 | ||
1906 | // NamedField | ||
1907 | 2018 | ||
1908 | #[derive(Debug, Clone)] | 2019 | impl<'a> NameRef<'a> {} |
1909 | pub struct NamedFieldNode(SyntaxNode); | ||
1910 | 2020 | ||
1911 | impl NamedFieldNode { | 2021 | // NamedField |
1912 | pub fn ast(&self) -> NamedField { | 2022 | #[derive(Debug, Clone, Copy,)] |
1913 | NamedField::cast(self.0.borrowed()).unwrap() | 2023 | pub struct NamedFieldNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
1914 | } | 2024 | pub(crate) syntax: SyntaxNode<R>, |
1915 | } | 2025 | } |
2026 | pub type NamedField<'a> = NamedFieldNode<RefRoot<'a>>; | ||
1916 | 2027 | ||
1917 | impl<'a> From<NamedField<'a>> for NamedFieldNode { | 2028 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<NamedFieldNode<R1>> for NamedFieldNode<R2> { |
1918 | fn from(ast: NamedField<'a>) -> NamedFieldNode { | 2029 | fn eq(&self, other: &NamedFieldNode<R1>) -> bool { self.syntax == other.syntax } |
1919 | let syntax = ast.syntax().owned(); | ||
1920 | NamedFieldNode(syntax) | ||
1921 | } | ||
1922 | } | 2030 | } |
1923 | #[derive(Debug, Clone, Copy)] | 2031 | impl<R: TreeRoot<RaTypes>> Eq for NamedFieldNode<R> {} |
1924 | pub struct NamedField<'a> { | 2032 | impl<R: TreeRoot<RaTypes>> Hash for NamedFieldNode<R> { |
1925 | syntax: SyntaxNodeRef<'a>, | 2033 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } |
1926 | } | 2034 | } |
1927 | 2035 | ||
1928 | impl<'a> AstNode<'a> for NamedField<'a> { | 2036 | impl<'a> AstNode<'a> for NamedField<'a> { |
@@ -1935,28 +2043,31 @@ impl<'a> AstNode<'a> for NamedField<'a> { | |||
1935 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 2043 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
1936 | } | 2044 | } |
1937 | 2045 | ||
1938 | impl<'a> NamedField<'a> {} | 2046 | impl<R: TreeRoot<RaTypes>> NamedFieldNode<R> { |
2047 | pub fn borrowed(&self) -> NamedField { | ||
2048 | NamedFieldNode { syntax: self.syntax.borrowed() } | ||
2049 | } | ||
2050 | pub fn owned(&self) -> NamedFieldNode { | ||
2051 | NamedFieldNode { syntax: self.syntax.owned() } | ||
2052 | } | ||
2053 | } | ||
1939 | 2054 | ||
1940 | // NamedFieldDef | ||
1941 | 2055 | ||
1942 | #[derive(Debug, Clone)] | 2056 | impl<'a> NamedField<'a> {} |
1943 | pub struct NamedFieldDefNode(SyntaxNode); | ||
1944 | 2057 | ||
1945 | impl NamedFieldDefNode { | 2058 | // NamedFieldDef |
1946 | pub fn ast(&self) -> NamedFieldDef { | 2059 | #[derive(Debug, Clone, Copy,)] |
1947 | NamedFieldDef::cast(self.0.borrowed()).unwrap() | 2060 | pub struct NamedFieldDefNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
1948 | } | 2061 | pub(crate) syntax: SyntaxNode<R>, |
1949 | } | 2062 | } |
2063 | pub type NamedFieldDef<'a> = NamedFieldDefNode<RefRoot<'a>>; | ||
1950 | 2064 | ||
1951 | impl<'a> From<NamedFieldDef<'a>> for NamedFieldDefNode { | 2065 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<NamedFieldDefNode<R1>> for NamedFieldDefNode<R2> { |
1952 | fn from(ast: NamedFieldDef<'a>) -> NamedFieldDefNode { | 2066 | fn eq(&self, other: &NamedFieldDefNode<R1>) -> bool { self.syntax == other.syntax } |
1953 | let syntax = ast.syntax().owned(); | ||
1954 | NamedFieldDefNode(syntax) | ||
1955 | } | ||
1956 | } | 2067 | } |
1957 | #[derive(Debug, Clone, Copy)] | 2068 | impl<R: TreeRoot<RaTypes>> Eq for NamedFieldDefNode<R> {} |
1958 | pub struct NamedFieldDef<'a> { | 2069 | impl<R: TreeRoot<RaTypes>> Hash for NamedFieldDefNode<R> { |
1959 | syntax: SyntaxNodeRef<'a>, | 2070 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } |
1960 | } | 2071 | } |
1961 | 2072 | ||
1962 | impl<'a> AstNode<'a> for NamedFieldDef<'a> { | 2073 | impl<'a> AstNode<'a> for NamedFieldDef<'a> { |
@@ -1969,30 +2080,33 @@ impl<'a> AstNode<'a> for NamedFieldDef<'a> { | |||
1969 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 2080 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
1970 | } | 2081 | } |
1971 | 2082 | ||
2083 | impl<R: TreeRoot<RaTypes>> NamedFieldDefNode<R> { | ||
2084 | pub fn borrowed(&self) -> NamedFieldDef { | ||
2085 | NamedFieldDefNode { syntax: self.syntax.borrowed() } | ||
2086 | } | ||
2087 | pub fn owned(&self) -> NamedFieldDefNode { | ||
2088 | NamedFieldDefNode { syntax: self.syntax.owned() } | ||
2089 | } | ||
2090 | } | ||
2091 | |||
2092 | |||
1972 | impl<'a> ast::NameOwner<'a> for NamedFieldDef<'a> {} | 2093 | impl<'a> ast::NameOwner<'a> for NamedFieldDef<'a> {} |
1973 | impl<'a> ast::AttrsOwner<'a> for NamedFieldDef<'a> {} | 2094 | impl<'a> ast::AttrsOwner<'a> for NamedFieldDef<'a> {} |
1974 | impl<'a> NamedFieldDef<'a> {} | 2095 | impl<'a> NamedFieldDef<'a> {} |
1975 | 2096 | ||
1976 | // NamedFieldList | 2097 | // NamedFieldList |
1977 | 2098 | #[derive(Debug, Clone, Copy,)] | |
1978 | #[derive(Debug, Clone)] | 2099 | pub struct NamedFieldListNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
1979 | pub struct NamedFieldListNode(SyntaxNode); | 2100 | pub(crate) syntax: SyntaxNode<R>, |
1980 | |||
1981 | impl NamedFieldListNode { | ||
1982 | pub fn ast(&self) -> NamedFieldList { | ||
1983 | NamedFieldList::cast(self.0.borrowed()).unwrap() | ||
1984 | } | ||
1985 | } | 2101 | } |
2102 | pub type NamedFieldList<'a> = NamedFieldListNode<RefRoot<'a>>; | ||
1986 | 2103 | ||
1987 | impl<'a> From<NamedFieldList<'a>> for NamedFieldListNode { | 2104 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<NamedFieldListNode<R1>> for NamedFieldListNode<R2> { |
1988 | fn from(ast: NamedFieldList<'a>) -> NamedFieldListNode { | 2105 | fn eq(&self, other: &NamedFieldListNode<R1>) -> bool { self.syntax == other.syntax } |
1989 | let syntax = ast.syntax().owned(); | ||
1990 | NamedFieldListNode(syntax) | ||
1991 | } | ||
1992 | } | 2106 | } |
1993 | #[derive(Debug, Clone, Copy)] | 2107 | impl<R: TreeRoot<RaTypes>> Eq for NamedFieldListNode<R> {} |
1994 | pub struct NamedFieldList<'a> { | 2108 | impl<R: TreeRoot<RaTypes>> Hash for NamedFieldListNode<R> { |
1995 | syntax: SyntaxNodeRef<'a>, | 2109 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } |
1996 | } | 2110 | } |
1997 | 2111 | ||
1998 | impl<'a> AstNode<'a> for NamedFieldList<'a> { | 2112 | impl<'a> AstNode<'a> for NamedFieldList<'a> { |
@@ -2005,28 +2119,31 @@ impl<'a> AstNode<'a> for NamedFieldList<'a> { | |||
2005 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 2119 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
2006 | } | 2120 | } |
2007 | 2121 | ||
2008 | impl<'a> NamedFieldList<'a> {} | 2122 | impl<R: TreeRoot<RaTypes>> NamedFieldListNode<R> { |
2123 | pub fn borrowed(&self) -> NamedFieldList { | ||
2124 | NamedFieldListNode { syntax: self.syntax.borrowed() } | ||
2125 | } | ||
2126 | pub fn owned(&self) -> NamedFieldListNode { | ||
2127 | NamedFieldListNode { syntax: self.syntax.owned() } | ||
2128 | } | ||
2129 | } | ||
2009 | 2130 | ||
2010 | // NeverType | ||
2011 | 2131 | ||
2012 | #[derive(Debug, Clone)] | 2132 | impl<'a> NamedFieldList<'a> {} |
2013 | pub struct NeverTypeNode(SyntaxNode); | ||
2014 | 2133 | ||
2015 | impl NeverTypeNode { | 2134 | // NeverType |
2016 | pub fn ast(&self) -> NeverType { | 2135 | #[derive(Debug, Clone, Copy,)] |
2017 | NeverType::cast(self.0.borrowed()).unwrap() | 2136 | pub struct NeverTypeNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
2018 | } | 2137 | pub(crate) syntax: SyntaxNode<R>, |
2019 | } | 2138 | } |
2139 | pub type NeverType<'a> = NeverTypeNode<RefRoot<'a>>; | ||
2020 | 2140 | ||
2021 | impl<'a> From<NeverType<'a>> for NeverTypeNode { | 2141 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<NeverTypeNode<R1>> for NeverTypeNode<R2> { |
2022 | fn from(ast: NeverType<'a>) -> NeverTypeNode { | 2142 | fn eq(&self, other: &NeverTypeNode<R1>) -> bool { self.syntax == other.syntax } |
2023 | let syntax = ast.syntax().owned(); | ||
2024 | NeverTypeNode(syntax) | ||
2025 | } | ||
2026 | } | 2143 | } |
2027 | #[derive(Debug, Clone, Copy)] | 2144 | impl<R: TreeRoot<RaTypes>> Eq for NeverTypeNode<R> {} |
2028 | pub struct NeverType<'a> { | 2145 | impl<R: TreeRoot<RaTypes>> Hash for NeverTypeNode<R> { |
2029 | syntax: SyntaxNodeRef<'a>, | 2146 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } |
2030 | } | 2147 | } |
2031 | 2148 | ||
2032 | impl<'a> AstNode<'a> for NeverType<'a> { | 2149 | impl<'a> AstNode<'a> for NeverType<'a> { |
@@ -2039,26 +2156,20 @@ impl<'a> AstNode<'a> for NeverType<'a> { | |||
2039 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 2156 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
2040 | } | 2157 | } |
2041 | 2158 | ||
2042 | impl<'a> NeverType<'a> {} | 2159 | impl<R: TreeRoot<RaTypes>> NeverTypeNode<R> { |
2043 | 2160 | pub fn borrowed(&self) -> NeverType { | |
2044 | // NominalDef | 2161 | NeverTypeNode { syntax: self.syntax.borrowed() } |
2045 | |||
2046 | #[derive(Debug, Clone)] | ||
2047 | pub struct NominalDefNode(SyntaxNode); | ||
2048 | |||
2049 | impl NominalDefNode { | ||
2050 | pub fn ast(&self) -> NominalDef { | ||
2051 | NominalDef::cast(self.0.borrowed()).unwrap() | ||
2052 | } | 2162 | } |
2053 | } | 2163 | pub fn owned(&self) -> NeverTypeNode { |
2054 | 2164 | NeverTypeNode { syntax: self.syntax.owned() } | |
2055 | impl<'a> From<NominalDef<'a>> for NominalDefNode { | ||
2056 | fn from(ast: NominalDef<'a>) -> NominalDefNode { | ||
2057 | let syntax = ast.syntax().owned(); | ||
2058 | NominalDefNode(syntax) | ||
2059 | } | 2165 | } |
2060 | } | 2166 | } |
2061 | #[derive(Debug, Clone, Copy)] | 2167 | |
2168 | |||
2169 | impl<'a> NeverType<'a> {} | ||
2170 | |||
2171 | // NominalDef | ||
2172 | #[derive(Debug, Clone, Copy, PartialEq, Eq)] | ||
2062 | pub enum NominalDef<'a> { | 2173 | pub enum NominalDef<'a> { |
2063 | StructDef(StructDef<'a>), | 2174 | StructDef(StructDef<'a>), |
2064 | EnumDef(EnumDef<'a>), | 2175 | EnumDef(EnumDef<'a>), |
@@ -2086,25 +2197,18 @@ impl<'a> ast::AttrsOwner<'a> for NominalDef<'a> {} | |||
2086 | impl<'a> NominalDef<'a> {} | 2197 | impl<'a> NominalDef<'a> {} |
2087 | 2198 | ||
2088 | // Param | 2199 | // Param |
2089 | 2200 | #[derive(Debug, Clone, Copy,)] | |
2090 | #[derive(Debug, Clone)] | 2201 | pub struct ParamNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
2091 | pub struct ParamNode(SyntaxNode); | 2202 | pub(crate) syntax: SyntaxNode<R>, |
2092 | |||
2093 | impl ParamNode { | ||
2094 | pub fn ast(&self) -> Param { | ||
2095 | Param::cast(self.0.borrowed()).unwrap() | ||
2096 | } | ||
2097 | } | 2203 | } |
2204 | pub type Param<'a> = ParamNode<RefRoot<'a>>; | ||
2098 | 2205 | ||
2099 | impl<'a> From<Param<'a>> for ParamNode { | 2206 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<ParamNode<R1>> for ParamNode<R2> { |
2100 | fn from(ast: Param<'a>) -> ParamNode { | 2207 | fn eq(&self, other: &ParamNode<R1>) -> bool { self.syntax == other.syntax } |
2101 | let syntax = ast.syntax().owned(); | ||
2102 | ParamNode(syntax) | ||
2103 | } | ||
2104 | } | 2208 | } |
2105 | #[derive(Debug, Clone, Copy)] | 2209 | impl<R: TreeRoot<RaTypes>> Eq for ParamNode<R> {} |
2106 | pub struct Param<'a> { | 2210 | impl<R: TreeRoot<RaTypes>> Hash for ParamNode<R> { |
2107 | syntax: SyntaxNodeRef<'a>, | 2211 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } |
2108 | } | 2212 | } |
2109 | 2213 | ||
2110 | impl<'a> AstNode<'a> for Param<'a> { | 2214 | impl<'a> AstNode<'a> for Param<'a> { |
@@ -2117,6 +2221,16 @@ impl<'a> AstNode<'a> for Param<'a> { | |||
2117 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 2221 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
2118 | } | 2222 | } |
2119 | 2223 | ||
2224 | impl<R: TreeRoot<RaTypes>> ParamNode<R> { | ||
2225 | pub fn borrowed(&self) -> Param { | ||
2226 | ParamNode { syntax: self.syntax.borrowed() } | ||
2227 | } | ||
2228 | pub fn owned(&self) -> ParamNode { | ||
2229 | ParamNode { syntax: self.syntax.owned() } | ||
2230 | } | ||
2231 | } | ||
2232 | |||
2233 | |||
2120 | impl<'a> Param<'a> { | 2234 | impl<'a> Param<'a> { |
2121 | pub fn pat(self) -> Option<Pat<'a>> { | 2235 | pub fn pat(self) -> Option<Pat<'a>> { |
2122 | super::child_opt(self) | 2236 | super::child_opt(self) |
@@ -2124,25 +2238,18 @@ impl<'a> Param<'a> { | |||
2124 | } | 2238 | } |
2125 | 2239 | ||
2126 | // ParamList | 2240 | // ParamList |
2127 | 2241 | #[derive(Debug, Clone, Copy,)] | |
2128 | #[derive(Debug, Clone)] | 2242 | pub struct ParamListNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
2129 | pub struct ParamListNode(SyntaxNode); | 2243 | pub(crate) syntax: SyntaxNode<R>, |
2130 | |||
2131 | impl ParamListNode { | ||
2132 | pub fn ast(&self) -> ParamList { | ||
2133 | ParamList::cast(self.0.borrowed()).unwrap() | ||
2134 | } | ||
2135 | } | 2244 | } |
2245 | pub type ParamList<'a> = ParamListNode<RefRoot<'a>>; | ||
2136 | 2246 | ||
2137 | impl<'a> From<ParamList<'a>> for ParamListNode { | 2247 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<ParamListNode<R1>> for ParamListNode<R2> { |
2138 | fn from(ast: ParamList<'a>) -> ParamListNode { | 2248 | fn eq(&self, other: &ParamListNode<R1>) -> bool { self.syntax == other.syntax } |
2139 | let syntax = ast.syntax().owned(); | ||
2140 | ParamListNode(syntax) | ||
2141 | } | ||
2142 | } | 2249 | } |
2143 | #[derive(Debug, Clone, Copy)] | 2250 | impl<R: TreeRoot<RaTypes>> Eq for ParamListNode<R> {} |
2144 | pub struct ParamList<'a> { | 2251 | impl<R: TreeRoot<RaTypes>> Hash for ParamListNode<R> { |
2145 | syntax: SyntaxNodeRef<'a>, | 2252 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } |
2146 | } | 2253 | } |
2147 | 2254 | ||
2148 | impl<'a> AstNode<'a> for ParamList<'a> { | 2255 | impl<'a> AstNode<'a> for ParamList<'a> { |
@@ -2155,6 +2262,16 @@ impl<'a> AstNode<'a> for ParamList<'a> { | |||
2155 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 2262 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
2156 | } | 2263 | } |
2157 | 2264 | ||
2265 | impl<R: TreeRoot<RaTypes>> ParamListNode<R> { | ||
2266 | pub fn borrowed(&self) -> ParamList { | ||
2267 | ParamListNode { syntax: self.syntax.borrowed() } | ||
2268 | } | ||
2269 | pub fn owned(&self) -> ParamListNode { | ||
2270 | ParamListNode { syntax: self.syntax.owned() } | ||
2271 | } | ||
2272 | } | ||
2273 | |||
2274 | |||
2158 | impl<'a> ParamList<'a> { | 2275 | impl<'a> ParamList<'a> { |
2159 | pub fn params(self) -> impl Iterator<Item = Param<'a>> + 'a { | 2276 | pub fn params(self) -> impl Iterator<Item = Param<'a>> + 'a { |
2160 | super::children(self) | 2277 | super::children(self) |
@@ -2166,25 +2283,18 @@ impl<'a> ParamList<'a> { | |||
2166 | } | 2283 | } |
2167 | 2284 | ||
2168 | // ParenExpr | 2285 | // ParenExpr |
2169 | 2286 | #[derive(Debug, Clone, Copy,)] | |
2170 | #[derive(Debug, Clone)] | 2287 | pub struct ParenExprNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
2171 | pub struct ParenExprNode(SyntaxNode); | 2288 | pub(crate) syntax: SyntaxNode<R>, |
2172 | |||
2173 | impl ParenExprNode { | ||
2174 | pub fn ast(&self) -> ParenExpr { | ||
2175 | ParenExpr::cast(self.0.borrowed()).unwrap() | ||
2176 | } | ||
2177 | } | 2289 | } |
2290 | pub type ParenExpr<'a> = ParenExprNode<RefRoot<'a>>; | ||
2178 | 2291 | ||
2179 | impl<'a> From<ParenExpr<'a>> for ParenExprNode { | 2292 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<ParenExprNode<R1>> for ParenExprNode<R2> { |
2180 | fn from(ast: ParenExpr<'a>) -> ParenExprNode { | 2293 | fn eq(&self, other: &ParenExprNode<R1>) -> bool { self.syntax == other.syntax } |
2181 | let syntax = ast.syntax().owned(); | ||
2182 | ParenExprNode(syntax) | ||
2183 | } | ||
2184 | } | 2294 | } |
2185 | #[derive(Debug, Clone, Copy)] | 2295 | impl<R: TreeRoot<RaTypes>> Eq for ParenExprNode<R> {} |
2186 | pub struct ParenExpr<'a> { | 2296 | impl<R: TreeRoot<RaTypes>> Hash for ParenExprNode<R> { |
2187 | syntax: SyntaxNodeRef<'a>, | 2297 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } |
2188 | } | 2298 | } |
2189 | 2299 | ||
2190 | impl<'a> AstNode<'a> for ParenExpr<'a> { | 2300 | impl<'a> AstNode<'a> for ParenExpr<'a> { |
@@ -2197,28 +2307,31 @@ impl<'a> AstNode<'a> for ParenExpr<'a> { | |||
2197 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 2307 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
2198 | } | 2308 | } |
2199 | 2309 | ||
2200 | impl<'a> ParenExpr<'a> {} | 2310 | impl<R: TreeRoot<RaTypes>> ParenExprNode<R> { |
2311 | pub fn borrowed(&self) -> ParenExpr { | ||
2312 | ParenExprNode { syntax: self.syntax.borrowed() } | ||
2313 | } | ||
2314 | pub fn owned(&self) -> ParenExprNode { | ||
2315 | ParenExprNode { syntax: self.syntax.owned() } | ||
2316 | } | ||
2317 | } | ||
2201 | 2318 | ||
2202 | // ParenType | ||
2203 | 2319 | ||
2204 | #[derive(Debug, Clone)] | 2320 | impl<'a> ParenExpr<'a> {} |
2205 | pub struct ParenTypeNode(SyntaxNode); | ||
2206 | 2321 | ||
2207 | impl ParenTypeNode { | 2322 | // ParenType |
2208 | pub fn ast(&self) -> ParenType { | 2323 | #[derive(Debug, Clone, Copy,)] |
2209 | ParenType::cast(self.0.borrowed()).unwrap() | 2324 | pub struct ParenTypeNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
2210 | } | 2325 | pub(crate) syntax: SyntaxNode<R>, |
2211 | } | 2326 | } |
2327 | pub type ParenType<'a> = ParenTypeNode<RefRoot<'a>>; | ||
2212 | 2328 | ||
2213 | impl<'a> From<ParenType<'a>> for ParenTypeNode { | 2329 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<ParenTypeNode<R1>> for ParenTypeNode<R2> { |
2214 | fn from(ast: ParenType<'a>) -> ParenTypeNode { | 2330 | fn eq(&self, other: &ParenTypeNode<R1>) -> bool { self.syntax == other.syntax } |
2215 | let syntax = ast.syntax().owned(); | ||
2216 | ParenTypeNode(syntax) | ||
2217 | } | ||
2218 | } | 2331 | } |
2219 | #[derive(Debug, Clone, Copy)] | 2332 | impl<R: TreeRoot<RaTypes>> Eq for ParenTypeNode<R> {} |
2220 | pub struct ParenType<'a> { | 2333 | impl<R: TreeRoot<RaTypes>> Hash for ParenTypeNode<R> { |
2221 | syntax: SyntaxNodeRef<'a>, | 2334 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } |
2222 | } | 2335 | } |
2223 | 2336 | ||
2224 | impl<'a> AstNode<'a> for ParenType<'a> { | 2337 | impl<'a> AstNode<'a> for ParenType<'a> { |
@@ -2231,26 +2344,20 @@ impl<'a> AstNode<'a> for ParenType<'a> { | |||
2231 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 2344 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
2232 | } | 2345 | } |
2233 | 2346 | ||
2234 | impl<'a> ParenType<'a> {} | 2347 | impl<R: TreeRoot<RaTypes>> ParenTypeNode<R> { |
2235 | 2348 | pub fn borrowed(&self) -> ParenType { | |
2236 | // Pat | 2349 | ParenTypeNode { syntax: self.syntax.borrowed() } |
2237 | |||
2238 | #[derive(Debug, Clone)] | ||
2239 | pub struct PatNode(SyntaxNode); | ||
2240 | |||
2241 | impl PatNode { | ||
2242 | pub fn ast(&self) -> Pat { | ||
2243 | Pat::cast(self.0.borrowed()).unwrap() | ||
2244 | } | 2350 | } |
2245 | } | 2351 | pub fn owned(&self) -> ParenTypeNode { |
2246 | 2352 | ParenTypeNode { syntax: self.syntax.owned() } | |
2247 | impl<'a> From<Pat<'a>> for PatNode { | ||
2248 | fn from(ast: Pat<'a>) -> PatNode { | ||
2249 | let syntax = ast.syntax().owned(); | ||
2250 | PatNode(syntax) | ||
2251 | } | 2353 | } |
2252 | } | 2354 | } |
2253 | #[derive(Debug, Clone, Copy)] | 2355 | |
2356 | |||
2357 | impl<'a> ParenType<'a> {} | ||
2358 | |||
2359 | // Pat | ||
2360 | #[derive(Debug, Clone, Copy, PartialEq, Eq)] | ||
2254 | pub enum Pat<'a> { | 2361 | pub enum Pat<'a> { |
2255 | RefPat(RefPat<'a>), | 2362 | RefPat(RefPat<'a>), |
2256 | BindPat(BindPat<'a>), | 2363 | BindPat(BindPat<'a>), |
@@ -2299,25 +2406,18 @@ impl<'a> AstNode<'a> for Pat<'a> { | |||
2299 | impl<'a> Pat<'a> {} | 2406 | impl<'a> Pat<'a> {} |
2300 | 2407 | ||
2301 | // Path | 2408 | // Path |
2302 | 2409 | #[derive(Debug, Clone, Copy,)] | |
2303 | #[derive(Debug, Clone)] | 2410 | pub struct PathNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
2304 | pub struct PathNode(SyntaxNode); | 2411 | pub(crate) syntax: SyntaxNode<R>, |
2305 | |||
2306 | impl PathNode { | ||
2307 | pub fn ast(&self) -> Path { | ||
2308 | Path::cast(self.0.borrowed()).unwrap() | ||
2309 | } | ||
2310 | } | 2412 | } |
2413 | pub type Path<'a> = PathNode<RefRoot<'a>>; | ||
2311 | 2414 | ||
2312 | impl<'a> From<Path<'a>> for PathNode { | 2415 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<PathNode<R1>> for PathNode<R2> { |
2313 | fn from(ast: Path<'a>) -> PathNode { | 2416 | fn eq(&self, other: &PathNode<R1>) -> bool { self.syntax == other.syntax } |
2314 | let syntax = ast.syntax().owned(); | ||
2315 | PathNode(syntax) | ||
2316 | } | ||
2317 | } | 2417 | } |
2318 | #[derive(Debug, Clone, Copy)] | 2418 | impl<R: TreeRoot<RaTypes>> Eq for PathNode<R> {} |
2319 | pub struct Path<'a> { | 2419 | impl<R: TreeRoot<RaTypes>> Hash for PathNode<R> { |
2320 | syntax: SyntaxNodeRef<'a>, | 2420 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } |
2321 | } | 2421 | } |
2322 | 2422 | ||
2323 | impl<'a> AstNode<'a> for Path<'a> { | 2423 | impl<'a> AstNode<'a> for Path<'a> { |
@@ -2330,6 +2430,16 @@ impl<'a> AstNode<'a> for Path<'a> { | |||
2330 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 2430 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
2331 | } | 2431 | } |
2332 | 2432 | ||
2433 | impl<R: TreeRoot<RaTypes>> PathNode<R> { | ||
2434 | pub fn borrowed(&self) -> Path { | ||
2435 | PathNode { syntax: self.syntax.borrowed() } | ||
2436 | } | ||
2437 | pub fn owned(&self) -> PathNode { | ||
2438 | PathNode { syntax: self.syntax.owned() } | ||
2439 | } | ||
2440 | } | ||
2441 | |||
2442 | |||
2333 | impl<'a> Path<'a> { | 2443 | impl<'a> Path<'a> { |
2334 | pub fn segment(self) -> Option<PathSegment<'a>> { | 2444 | pub fn segment(self) -> Option<PathSegment<'a>> { |
2335 | super::child_opt(self) | 2445 | super::child_opt(self) |
@@ -2341,25 +2451,18 @@ impl<'a> Path<'a> { | |||
2341 | } | 2451 | } |
2342 | 2452 | ||
2343 | // PathExpr | 2453 | // PathExpr |
2344 | 2454 | #[derive(Debug, Clone, Copy,)] | |
2345 | #[derive(Debug, Clone)] | 2455 | pub struct PathExprNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
2346 | pub struct PathExprNode(SyntaxNode); | 2456 | pub(crate) syntax: SyntaxNode<R>, |
2347 | |||
2348 | impl PathExprNode { | ||
2349 | pub fn ast(&self) -> PathExpr { | ||
2350 | PathExpr::cast(self.0.borrowed()).unwrap() | ||
2351 | } | ||
2352 | } | 2457 | } |
2458 | pub type PathExpr<'a> = PathExprNode<RefRoot<'a>>; | ||
2353 | 2459 | ||
2354 | impl<'a> From<PathExpr<'a>> for PathExprNode { | 2460 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<PathExprNode<R1>> for PathExprNode<R2> { |
2355 | fn from(ast: PathExpr<'a>) -> PathExprNode { | 2461 | fn eq(&self, other: &PathExprNode<R1>) -> bool { self.syntax == other.syntax } |
2356 | let syntax = ast.syntax().owned(); | ||
2357 | PathExprNode(syntax) | ||
2358 | } | ||
2359 | } | 2462 | } |
2360 | #[derive(Debug, Clone, Copy)] | 2463 | impl<R: TreeRoot<RaTypes>> Eq for PathExprNode<R> {} |
2361 | pub struct PathExpr<'a> { | 2464 | impl<R: TreeRoot<RaTypes>> Hash for PathExprNode<R> { |
2362 | syntax: SyntaxNodeRef<'a>, | 2465 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } |
2363 | } | 2466 | } |
2364 | 2467 | ||
2365 | impl<'a> AstNode<'a> for PathExpr<'a> { | 2468 | impl<'a> AstNode<'a> for PathExpr<'a> { |
@@ -2372,6 +2475,16 @@ impl<'a> AstNode<'a> for PathExpr<'a> { | |||
2372 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 2475 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
2373 | } | 2476 | } |
2374 | 2477 | ||
2478 | impl<R: TreeRoot<RaTypes>> PathExprNode<R> { | ||
2479 | pub fn borrowed(&self) -> PathExpr { | ||
2480 | PathExprNode { syntax: self.syntax.borrowed() } | ||
2481 | } | ||
2482 | pub fn owned(&self) -> PathExprNode { | ||
2483 | PathExprNode { syntax: self.syntax.owned() } | ||
2484 | } | ||
2485 | } | ||
2486 | |||
2487 | |||
2375 | impl<'a> PathExpr<'a> { | 2488 | impl<'a> PathExpr<'a> { |
2376 | pub fn path(self) -> Option<Path<'a>> { | 2489 | pub fn path(self) -> Option<Path<'a>> { |
2377 | super::child_opt(self) | 2490 | super::child_opt(self) |
@@ -2379,25 +2492,18 @@ impl<'a> PathExpr<'a> { | |||
2379 | } | 2492 | } |
2380 | 2493 | ||
2381 | // PathPat | 2494 | // PathPat |
2382 | 2495 | #[derive(Debug, Clone, Copy,)] | |
2383 | #[derive(Debug, Clone)] | 2496 | pub struct PathPatNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
2384 | pub struct PathPatNode(SyntaxNode); | 2497 | pub(crate) syntax: SyntaxNode<R>, |
2385 | |||
2386 | impl PathPatNode { | ||
2387 | pub fn ast(&self) -> PathPat { | ||
2388 | PathPat::cast(self.0.borrowed()).unwrap() | ||
2389 | } | ||
2390 | } | 2498 | } |
2499 | pub type PathPat<'a> = PathPatNode<RefRoot<'a>>; | ||
2391 | 2500 | ||
2392 | impl<'a> From<PathPat<'a>> for PathPatNode { | 2501 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<PathPatNode<R1>> for PathPatNode<R2> { |
2393 | fn from(ast: PathPat<'a>) -> PathPatNode { | 2502 | fn eq(&self, other: &PathPatNode<R1>) -> bool { self.syntax == other.syntax } |
2394 | let syntax = ast.syntax().owned(); | ||
2395 | PathPatNode(syntax) | ||
2396 | } | ||
2397 | } | 2503 | } |
2398 | #[derive(Debug, Clone, Copy)] | 2504 | impl<R: TreeRoot<RaTypes>> Eq for PathPatNode<R> {} |
2399 | pub struct PathPat<'a> { | 2505 | impl<R: TreeRoot<RaTypes>> Hash for PathPatNode<R> { |
2400 | syntax: SyntaxNodeRef<'a>, | 2506 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } |
2401 | } | 2507 | } |
2402 | 2508 | ||
2403 | impl<'a> AstNode<'a> for PathPat<'a> { | 2509 | impl<'a> AstNode<'a> for PathPat<'a> { |
@@ -2410,28 +2516,31 @@ impl<'a> AstNode<'a> for PathPat<'a> { | |||
2410 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 2516 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
2411 | } | 2517 | } |
2412 | 2518 | ||
2413 | impl<'a> PathPat<'a> {} | 2519 | impl<R: TreeRoot<RaTypes>> PathPatNode<R> { |
2520 | pub fn borrowed(&self) -> PathPat { | ||
2521 | PathPatNode { syntax: self.syntax.borrowed() } | ||
2522 | } | ||
2523 | pub fn owned(&self) -> PathPatNode { | ||
2524 | PathPatNode { syntax: self.syntax.owned() } | ||
2525 | } | ||
2526 | } | ||
2414 | 2527 | ||
2415 | // PathSegment | ||
2416 | 2528 | ||
2417 | #[derive(Debug, Clone)] | 2529 | impl<'a> PathPat<'a> {} |
2418 | pub struct PathSegmentNode(SyntaxNode); | ||
2419 | 2530 | ||
2420 | impl PathSegmentNode { | 2531 | // PathSegment |
2421 | pub fn ast(&self) -> PathSegment { | 2532 | #[derive(Debug, Clone, Copy,)] |
2422 | PathSegment::cast(self.0.borrowed()).unwrap() | 2533 | pub struct PathSegmentNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
2423 | } | 2534 | pub(crate) syntax: SyntaxNode<R>, |
2424 | } | 2535 | } |
2536 | pub type PathSegment<'a> = PathSegmentNode<RefRoot<'a>>; | ||
2425 | 2537 | ||
2426 | impl<'a> From<PathSegment<'a>> for PathSegmentNode { | 2538 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<PathSegmentNode<R1>> for PathSegmentNode<R2> { |
2427 | fn from(ast: PathSegment<'a>) -> PathSegmentNode { | 2539 | fn eq(&self, other: &PathSegmentNode<R1>) -> bool { self.syntax == other.syntax } |
2428 | let syntax = ast.syntax().owned(); | ||
2429 | PathSegmentNode(syntax) | ||
2430 | } | ||
2431 | } | 2540 | } |
2432 | #[derive(Debug, Clone, Copy)] | 2541 | impl<R: TreeRoot<RaTypes>> Eq for PathSegmentNode<R> {} |
2433 | pub struct PathSegment<'a> { | 2542 | impl<R: TreeRoot<RaTypes>> Hash for PathSegmentNode<R> { |
2434 | syntax: SyntaxNodeRef<'a>, | 2543 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } |
2435 | } | 2544 | } |
2436 | 2545 | ||
2437 | impl<'a> AstNode<'a> for PathSegment<'a> { | 2546 | impl<'a> AstNode<'a> for PathSegment<'a> { |
@@ -2444,6 +2553,16 @@ impl<'a> AstNode<'a> for PathSegment<'a> { | |||
2444 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 2553 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
2445 | } | 2554 | } |
2446 | 2555 | ||
2556 | impl<R: TreeRoot<RaTypes>> PathSegmentNode<R> { | ||
2557 | pub fn borrowed(&self) -> PathSegment { | ||
2558 | PathSegmentNode { syntax: self.syntax.borrowed() } | ||
2559 | } | ||
2560 | pub fn owned(&self) -> PathSegmentNode { | ||
2561 | PathSegmentNode { syntax: self.syntax.owned() } | ||
2562 | } | ||
2563 | } | ||
2564 | |||
2565 | |||
2447 | impl<'a> PathSegment<'a> { | 2566 | impl<'a> PathSegment<'a> { |
2448 | pub fn name_ref(self) -> Option<NameRef<'a>> { | 2567 | pub fn name_ref(self) -> Option<NameRef<'a>> { |
2449 | super::child_opt(self) | 2568 | super::child_opt(self) |
@@ -2451,25 +2570,18 @@ impl<'a> PathSegment<'a> { | |||
2451 | } | 2570 | } |
2452 | 2571 | ||
2453 | // PathType | 2572 | // PathType |
2454 | 2573 | #[derive(Debug, Clone, Copy,)] | |
2455 | #[derive(Debug, Clone)] | 2574 | pub struct PathTypeNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
2456 | pub struct PathTypeNode(SyntaxNode); | 2575 | pub(crate) syntax: SyntaxNode<R>, |
2457 | |||
2458 | impl PathTypeNode { | ||
2459 | pub fn ast(&self) -> PathType { | ||
2460 | PathType::cast(self.0.borrowed()).unwrap() | ||
2461 | } | ||
2462 | } | 2576 | } |
2577 | pub type PathType<'a> = PathTypeNode<RefRoot<'a>>; | ||
2463 | 2578 | ||
2464 | impl<'a> From<PathType<'a>> for PathTypeNode { | 2579 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<PathTypeNode<R1>> for PathTypeNode<R2> { |
2465 | fn from(ast: PathType<'a>) -> PathTypeNode { | 2580 | fn eq(&self, other: &PathTypeNode<R1>) -> bool { self.syntax == other.syntax } |
2466 | let syntax = ast.syntax().owned(); | ||
2467 | PathTypeNode(syntax) | ||
2468 | } | ||
2469 | } | 2581 | } |
2470 | #[derive(Debug, Clone, Copy)] | 2582 | impl<R: TreeRoot<RaTypes>> Eq for PathTypeNode<R> {} |
2471 | pub struct PathType<'a> { | 2583 | impl<R: TreeRoot<RaTypes>> Hash for PathTypeNode<R> { |
2472 | syntax: SyntaxNodeRef<'a>, | 2584 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } |
2473 | } | 2585 | } |
2474 | 2586 | ||
2475 | impl<'a> AstNode<'a> for PathType<'a> { | 2587 | impl<'a> AstNode<'a> for PathType<'a> { |
@@ -2482,28 +2594,31 @@ impl<'a> AstNode<'a> for PathType<'a> { | |||
2482 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 2594 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
2483 | } | 2595 | } |
2484 | 2596 | ||
2485 | impl<'a> PathType<'a> {} | 2597 | impl<R: TreeRoot<RaTypes>> PathTypeNode<R> { |
2598 | pub fn borrowed(&self) -> PathType { | ||
2599 | PathTypeNode { syntax: self.syntax.borrowed() } | ||
2600 | } | ||
2601 | pub fn owned(&self) -> PathTypeNode { | ||
2602 | PathTypeNode { syntax: self.syntax.owned() } | ||
2603 | } | ||
2604 | } | ||
2486 | 2605 | ||
2487 | // PlaceholderPat | ||
2488 | 2606 | ||
2489 | #[derive(Debug, Clone)] | 2607 | impl<'a> PathType<'a> {} |
2490 | pub struct PlaceholderPatNode(SyntaxNode); | ||
2491 | 2608 | ||
2492 | impl PlaceholderPatNode { | 2609 | // PlaceholderPat |
2493 | pub fn ast(&self) -> PlaceholderPat { | 2610 | #[derive(Debug, Clone, Copy,)] |
2494 | PlaceholderPat::cast(self.0.borrowed()).unwrap() | 2611 | pub struct PlaceholderPatNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
2495 | } | 2612 | pub(crate) syntax: SyntaxNode<R>, |
2496 | } | 2613 | } |
2614 | pub type PlaceholderPat<'a> = PlaceholderPatNode<RefRoot<'a>>; | ||
2497 | 2615 | ||
2498 | impl<'a> From<PlaceholderPat<'a>> for PlaceholderPatNode { | 2616 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<PlaceholderPatNode<R1>> for PlaceholderPatNode<R2> { |
2499 | fn from(ast: PlaceholderPat<'a>) -> PlaceholderPatNode { | 2617 | fn eq(&self, other: &PlaceholderPatNode<R1>) -> bool { self.syntax == other.syntax } |
2500 | let syntax = ast.syntax().owned(); | ||
2501 | PlaceholderPatNode(syntax) | ||
2502 | } | ||
2503 | } | 2618 | } |
2504 | #[derive(Debug, Clone, Copy)] | 2619 | impl<R: TreeRoot<RaTypes>> Eq for PlaceholderPatNode<R> {} |
2505 | pub struct PlaceholderPat<'a> { | 2620 | impl<R: TreeRoot<RaTypes>> Hash for PlaceholderPatNode<R> { |
2506 | syntax: SyntaxNodeRef<'a>, | 2621 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } |
2507 | } | 2622 | } |
2508 | 2623 | ||
2509 | impl<'a> AstNode<'a> for PlaceholderPat<'a> { | 2624 | impl<'a> AstNode<'a> for PlaceholderPat<'a> { |
@@ -2516,28 +2631,31 @@ impl<'a> AstNode<'a> for PlaceholderPat<'a> { | |||
2516 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 2631 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
2517 | } | 2632 | } |
2518 | 2633 | ||
2519 | impl<'a> PlaceholderPat<'a> {} | 2634 | impl<R: TreeRoot<RaTypes>> PlaceholderPatNode<R> { |
2635 | pub fn borrowed(&self) -> PlaceholderPat { | ||
2636 | PlaceholderPatNode { syntax: self.syntax.borrowed() } | ||
2637 | } | ||
2638 | pub fn owned(&self) -> PlaceholderPatNode { | ||
2639 | PlaceholderPatNode { syntax: self.syntax.owned() } | ||
2640 | } | ||
2641 | } | ||
2520 | 2642 | ||
2521 | // PlaceholderType | ||
2522 | 2643 | ||
2523 | #[derive(Debug, Clone)] | 2644 | impl<'a> PlaceholderPat<'a> {} |
2524 | pub struct PlaceholderTypeNode(SyntaxNode); | ||
2525 | 2645 | ||
2526 | impl PlaceholderTypeNode { | 2646 | // PlaceholderType |
2527 | pub fn ast(&self) -> PlaceholderType { | 2647 | #[derive(Debug, Clone, Copy,)] |
2528 | PlaceholderType::cast(self.0.borrowed()).unwrap() | 2648 | pub struct PlaceholderTypeNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
2529 | } | 2649 | pub(crate) syntax: SyntaxNode<R>, |
2530 | } | 2650 | } |
2651 | pub type PlaceholderType<'a> = PlaceholderTypeNode<RefRoot<'a>>; | ||
2531 | 2652 | ||
2532 | impl<'a> From<PlaceholderType<'a>> for PlaceholderTypeNode { | 2653 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<PlaceholderTypeNode<R1>> for PlaceholderTypeNode<R2> { |
2533 | fn from(ast: PlaceholderType<'a>) -> PlaceholderTypeNode { | 2654 | fn eq(&self, other: &PlaceholderTypeNode<R1>) -> bool { self.syntax == other.syntax } |
2534 | let syntax = ast.syntax().owned(); | ||
2535 | PlaceholderTypeNode(syntax) | ||
2536 | } | ||
2537 | } | 2655 | } |
2538 | #[derive(Debug, Clone, Copy)] | 2656 | impl<R: TreeRoot<RaTypes>> Eq for PlaceholderTypeNode<R> {} |
2539 | pub struct PlaceholderType<'a> { | 2657 | impl<R: TreeRoot<RaTypes>> Hash for PlaceholderTypeNode<R> { |
2540 | syntax: SyntaxNodeRef<'a>, | 2658 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } |
2541 | } | 2659 | } |
2542 | 2660 | ||
2543 | impl<'a> AstNode<'a> for PlaceholderType<'a> { | 2661 | impl<'a> AstNode<'a> for PlaceholderType<'a> { |
@@ -2550,28 +2668,31 @@ impl<'a> AstNode<'a> for PlaceholderType<'a> { | |||
2550 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 2668 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
2551 | } | 2669 | } |
2552 | 2670 | ||
2553 | impl<'a> PlaceholderType<'a> {} | 2671 | impl<R: TreeRoot<RaTypes>> PlaceholderTypeNode<R> { |
2672 | pub fn borrowed(&self) -> PlaceholderType { | ||
2673 | PlaceholderTypeNode { syntax: self.syntax.borrowed() } | ||
2674 | } | ||
2675 | pub fn owned(&self) -> PlaceholderTypeNode { | ||
2676 | PlaceholderTypeNode { syntax: self.syntax.owned() } | ||
2677 | } | ||
2678 | } | ||
2554 | 2679 | ||
2555 | // PointerType | ||
2556 | 2680 | ||
2557 | #[derive(Debug, Clone)] | 2681 | impl<'a> PlaceholderType<'a> {} |
2558 | pub struct PointerTypeNode(SyntaxNode); | ||
2559 | 2682 | ||
2560 | impl PointerTypeNode { | 2683 | // PointerType |
2561 | pub fn ast(&self) -> PointerType { | 2684 | #[derive(Debug, Clone, Copy,)] |
2562 | PointerType::cast(self.0.borrowed()).unwrap() | 2685 | pub struct PointerTypeNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
2563 | } | 2686 | pub(crate) syntax: SyntaxNode<R>, |
2564 | } | 2687 | } |
2688 | pub type PointerType<'a> = PointerTypeNode<RefRoot<'a>>; | ||
2565 | 2689 | ||
2566 | impl<'a> From<PointerType<'a>> for PointerTypeNode { | 2690 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<PointerTypeNode<R1>> for PointerTypeNode<R2> { |
2567 | fn from(ast: PointerType<'a>) -> PointerTypeNode { | 2691 | fn eq(&self, other: &PointerTypeNode<R1>) -> bool { self.syntax == other.syntax } |
2568 | let syntax = ast.syntax().owned(); | ||
2569 | PointerTypeNode(syntax) | ||
2570 | } | ||
2571 | } | 2692 | } |
2572 | #[derive(Debug, Clone, Copy)] | 2693 | impl<R: TreeRoot<RaTypes>> Eq for PointerTypeNode<R> {} |
2573 | pub struct PointerType<'a> { | 2694 | impl<R: TreeRoot<RaTypes>> Hash for PointerTypeNode<R> { |
2574 | syntax: SyntaxNodeRef<'a>, | 2695 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } |
2575 | } | 2696 | } |
2576 | 2697 | ||
2577 | impl<'a> AstNode<'a> for PointerType<'a> { | 2698 | impl<'a> AstNode<'a> for PointerType<'a> { |
@@ -2584,28 +2705,31 @@ impl<'a> AstNode<'a> for PointerType<'a> { | |||
2584 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 2705 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
2585 | } | 2706 | } |
2586 | 2707 | ||
2587 | impl<'a> PointerType<'a> {} | 2708 | impl<R: TreeRoot<RaTypes>> PointerTypeNode<R> { |
2709 | pub fn borrowed(&self) -> PointerType { | ||
2710 | PointerTypeNode { syntax: self.syntax.borrowed() } | ||
2711 | } | ||
2712 | pub fn owned(&self) -> PointerTypeNode { | ||
2713 | PointerTypeNode { syntax: self.syntax.owned() } | ||
2714 | } | ||
2715 | } | ||
2588 | 2716 | ||
2589 | // PrefixExpr | ||
2590 | 2717 | ||
2591 | #[derive(Debug, Clone)] | 2718 | impl<'a> PointerType<'a> {} |
2592 | pub struct PrefixExprNode(SyntaxNode); | ||
2593 | 2719 | ||
2594 | impl PrefixExprNode { | 2720 | // PrefixExpr |
2595 | pub fn ast(&self) -> PrefixExpr { | 2721 | #[derive(Debug, Clone, Copy,)] |
2596 | PrefixExpr::cast(self.0.borrowed()).unwrap() | 2722 | pub struct PrefixExprNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
2597 | } | 2723 | pub(crate) syntax: SyntaxNode<R>, |
2598 | } | 2724 | } |
2725 | pub type PrefixExpr<'a> = PrefixExprNode<RefRoot<'a>>; | ||
2599 | 2726 | ||
2600 | impl<'a> From<PrefixExpr<'a>> for PrefixExprNode { | 2727 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<PrefixExprNode<R1>> for PrefixExprNode<R2> { |
2601 | fn from(ast: PrefixExpr<'a>) -> PrefixExprNode { | 2728 | fn eq(&self, other: &PrefixExprNode<R1>) -> bool { self.syntax == other.syntax } |
2602 | let syntax = ast.syntax().owned(); | ||
2603 | PrefixExprNode(syntax) | ||
2604 | } | ||
2605 | } | 2729 | } |
2606 | #[derive(Debug, Clone, Copy)] | 2730 | impl<R: TreeRoot<RaTypes>> Eq for PrefixExprNode<R> {} |
2607 | pub struct PrefixExpr<'a> { | 2731 | impl<R: TreeRoot<RaTypes>> Hash for PrefixExprNode<R> { |
2608 | syntax: SyntaxNodeRef<'a>, | 2732 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } |
2609 | } | 2733 | } |
2610 | 2734 | ||
2611 | impl<'a> AstNode<'a> for PrefixExpr<'a> { | 2735 | impl<'a> AstNode<'a> for PrefixExpr<'a> { |
@@ -2618,28 +2742,31 @@ impl<'a> AstNode<'a> for PrefixExpr<'a> { | |||
2618 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 2742 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
2619 | } | 2743 | } |
2620 | 2744 | ||
2621 | impl<'a> PrefixExpr<'a> {} | 2745 | impl<R: TreeRoot<RaTypes>> PrefixExprNode<R> { |
2746 | pub fn borrowed(&self) -> PrefixExpr { | ||
2747 | PrefixExprNode { syntax: self.syntax.borrowed() } | ||
2748 | } | ||
2749 | pub fn owned(&self) -> PrefixExprNode { | ||
2750 | PrefixExprNode { syntax: self.syntax.owned() } | ||
2751 | } | ||
2752 | } | ||
2622 | 2753 | ||
2623 | // RangeExpr | ||
2624 | 2754 | ||
2625 | #[derive(Debug, Clone)] | 2755 | impl<'a> PrefixExpr<'a> {} |
2626 | pub struct RangeExprNode(SyntaxNode); | ||
2627 | 2756 | ||
2628 | impl RangeExprNode { | 2757 | // RangeExpr |
2629 | pub fn ast(&self) -> RangeExpr { | 2758 | #[derive(Debug, Clone, Copy,)] |
2630 | RangeExpr::cast(self.0.borrowed()).unwrap() | 2759 | pub struct RangeExprNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
2631 | } | 2760 | pub(crate) syntax: SyntaxNode<R>, |
2632 | } | 2761 | } |
2762 | pub type RangeExpr<'a> = RangeExprNode<RefRoot<'a>>; | ||
2633 | 2763 | ||
2634 | impl<'a> From<RangeExpr<'a>> for RangeExprNode { | 2764 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<RangeExprNode<R1>> for RangeExprNode<R2> { |
2635 | fn from(ast: RangeExpr<'a>) -> RangeExprNode { | 2765 | fn eq(&self, other: &RangeExprNode<R1>) -> bool { self.syntax == other.syntax } |
2636 | let syntax = ast.syntax().owned(); | ||
2637 | RangeExprNode(syntax) | ||
2638 | } | ||
2639 | } | 2766 | } |
2640 | #[derive(Debug, Clone, Copy)] | 2767 | impl<R: TreeRoot<RaTypes>> Eq for RangeExprNode<R> {} |
2641 | pub struct RangeExpr<'a> { | 2768 | impl<R: TreeRoot<RaTypes>> Hash for RangeExprNode<R> { |
2642 | syntax: SyntaxNodeRef<'a>, | 2769 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } |
2643 | } | 2770 | } |
2644 | 2771 | ||
2645 | impl<'a> AstNode<'a> for RangeExpr<'a> { | 2772 | impl<'a> AstNode<'a> for RangeExpr<'a> { |
@@ -2652,28 +2779,31 @@ impl<'a> AstNode<'a> for RangeExpr<'a> { | |||
2652 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 2779 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
2653 | } | 2780 | } |
2654 | 2781 | ||
2655 | impl<'a> RangeExpr<'a> {} | 2782 | impl<R: TreeRoot<RaTypes>> RangeExprNode<R> { |
2783 | pub fn borrowed(&self) -> RangeExpr { | ||
2784 | RangeExprNode { syntax: self.syntax.borrowed() } | ||
2785 | } | ||
2786 | pub fn owned(&self) -> RangeExprNode { | ||
2787 | RangeExprNode { syntax: self.syntax.owned() } | ||
2788 | } | ||
2789 | } | ||
2656 | 2790 | ||
2657 | // RangePat | ||
2658 | 2791 | ||
2659 | #[derive(Debug, Clone)] | 2792 | impl<'a> RangeExpr<'a> {} |
2660 | pub struct RangePatNode(SyntaxNode); | ||
2661 | 2793 | ||
2662 | impl RangePatNode { | 2794 | // RangePat |
2663 | pub fn ast(&self) -> RangePat { | 2795 | #[derive(Debug, Clone, Copy,)] |
2664 | RangePat::cast(self.0.borrowed()).unwrap() | 2796 | pub struct RangePatNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
2665 | } | 2797 | pub(crate) syntax: SyntaxNode<R>, |
2666 | } | 2798 | } |
2799 | pub type RangePat<'a> = RangePatNode<RefRoot<'a>>; | ||
2667 | 2800 | ||
2668 | impl<'a> From<RangePat<'a>> for RangePatNode { | 2801 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<RangePatNode<R1>> for RangePatNode<R2> { |
2669 | fn from(ast: RangePat<'a>) -> RangePatNode { | 2802 | fn eq(&self, other: &RangePatNode<R1>) -> bool { self.syntax == other.syntax } |
2670 | let syntax = ast.syntax().owned(); | ||
2671 | RangePatNode(syntax) | ||
2672 | } | ||
2673 | } | 2803 | } |
2674 | #[derive(Debug, Clone, Copy)] | 2804 | impl<R: TreeRoot<RaTypes>> Eq for RangePatNode<R> {} |
2675 | pub struct RangePat<'a> { | 2805 | impl<R: TreeRoot<RaTypes>> Hash for RangePatNode<R> { |
2676 | syntax: SyntaxNodeRef<'a>, | 2806 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } |
2677 | } | 2807 | } |
2678 | 2808 | ||
2679 | impl<'a> AstNode<'a> for RangePat<'a> { | 2809 | impl<'a> AstNode<'a> for RangePat<'a> { |
@@ -2686,28 +2816,31 @@ impl<'a> AstNode<'a> for RangePat<'a> { | |||
2686 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 2816 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
2687 | } | 2817 | } |
2688 | 2818 | ||
2689 | impl<'a> RangePat<'a> {} | 2819 | impl<R: TreeRoot<RaTypes>> RangePatNode<R> { |
2820 | pub fn borrowed(&self) -> RangePat { | ||
2821 | RangePatNode { syntax: self.syntax.borrowed() } | ||
2822 | } | ||
2823 | pub fn owned(&self) -> RangePatNode { | ||
2824 | RangePatNode { syntax: self.syntax.owned() } | ||
2825 | } | ||
2826 | } | ||
2690 | 2827 | ||
2691 | // RefExpr | ||
2692 | 2828 | ||
2693 | #[derive(Debug, Clone)] | 2829 | impl<'a> RangePat<'a> {} |
2694 | pub struct RefExprNode(SyntaxNode); | ||
2695 | 2830 | ||
2696 | impl RefExprNode { | 2831 | // RefExpr |
2697 | pub fn ast(&self) -> RefExpr { | 2832 | #[derive(Debug, Clone, Copy,)] |
2698 | RefExpr::cast(self.0.borrowed()).unwrap() | 2833 | pub struct RefExprNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
2699 | } | 2834 | pub(crate) syntax: SyntaxNode<R>, |
2700 | } | 2835 | } |
2836 | pub type RefExpr<'a> = RefExprNode<RefRoot<'a>>; | ||
2701 | 2837 | ||
2702 | impl<'a> From<RefExpr<'a>> for RefExprNode { | 2838 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<RefExprNode<R1>> for RefExprNode<R2> { |
2703 | fn from(ast: RefExpr<'a>) -> RefExprNode { | 2839 | fn eq(&self, other: &RefExprNode<R1>) -> bool { self.syntax == other.syntax } |
2704 | let syntax = ast.syntax().owned(); | ||
2705 | RefExprNode(syntax) | ||
2706 | } | ||
2707 | } | 2840 | } |
2708 | #[derive(Debug, Clone, Copy)] | 2841 | impl<R: TreeRoot<RaTypes>> Eq for RefExprNode<R> {} |
2709 | pub struct RefExpr<'a> { | 2842 | impl<R: TreeRoot<RaTypes>> Hash for RefExprNode<R> { |
2710 | syntax: SyntaxNodeRef<'a>, | 2843 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } |
2711 | } | 2844 | } |
2712 | 2845 | ||
2713 | impl<'a> AstNode<'a> for RefExpr<'a> { | 2846 | impl<'a> AstNode<'a> for RefExpr<'a> { |
@@ -2720,28 +2853,31 @@ impl<'a> AstNode<'a> for RefExpr<'a> { | |||
2720 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 2853 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
2721 | } | 2854 | } |
2722 | 2855 | ||
2723 | impl<'a> RefExpr<'a> {} | 2856 | impl<R: TreeRoot<RaTypes>> RefExprNode<R> { |
2857 | pub fn borrowed(&self) -> RefExpr { | ||
2858 | RefExprNode { syntax: self.syntax.borrowed() } | ||
2859 | } | ||
2860 | pub fn owned(&self) -> RefExprNode { | ||
2861 | RefExprNode { syntax: self.syntax.owned() } | ||
2862 | } | ||
2863 | } | ||
2724 | 2864 | ||
2725 | // RefPat | ||
2726 | 2865 | ||
2727 | #[derive(Debug, Clone)] | 2866 | impl<'a> RefExpr<'a> {} |
2728 | pub struct RefPatNode(SyntaxNode); | ||
2729 | 2867 | ||
2730 | impl RefPatNode { | 2868 | // RefPat |
2731 | pub fn ast(&self) -> RefPat { | 2869 | #[derive(Debug, Clone, Copy,)] |
2732 | RefPat::cast(self.0.borrowed()).unwrap() | 2870 | pub struct RefPatNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
2733 | } | 2871 | pub(crate) syntax: SyntaxNode<R>, |
2734 | } | 2872 | } |
2873 | pub type RefPat<'a> = RefPatNode<RefRoot<'a>>; | ||
2735 | 2874 | ||
2736 | impl<'a> From<RefPat<'a>> for RefPatNode { | 2875 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<RefPatNode<R1>> for RefPatNode<R2> { |
2737 | fn from(ast: RefPat<'a>) -> RefPatNode { | 2876 | fn eq(&self, other: &RefPatNode<R1>) -> bool { self.syntax == other.syntax } |
2738 | let syntax = ast.syntax().owned(); | ||
2739 | RefPatNode(syntax) | ||
2740 | } | ||
2741 | } | 2877 | } |
2742 | #[derive(Debug, Clone, Copy)] | 2878 | impl<R: TreeRoot<RaTypes>> Eq for RefPatNode<R> {} |
2743 | pub struct RefPat<'a> { | 2879 | impl<R: TreeRoot<RaTypes>> Hash for RefPatNode<R> { |
2744 | syntax: SyntaxNodeRef<'a>, | 2880 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } |
2745 | } | 2881 | } |
2746 | 2882 | ||
2747 | impl<'a> AstNode<'a> for RefPat<'a> { | 2883 | impl<'a> AstNode<'a> for RefPat<'a> { |
@@ -2754,28 +2890,31 @@ impl<'a> AstNode<'a> for RefPat<'a> { | |||
2754 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 2890 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
2755 | } | 2891 | } |
2756 | 2892 | ||
2757 | impl<'a> RefPat<'a> {} | 2893 | impl<R: TreeRoot<RaTypes>> RefPatNode<R> { |
2894 | pub fn borrowed(&self) -> RefPat { | ||
2895 | RefPatNode { syntax: self.syntax.borrowed() } | ||
2896 | } | ||
2897 | pub fn owned(&self) -> RefPatNode { | ||
2898 | RefPatNode { syntax: self.syntax.owned() } | ||
2899 | } | ||
2900 | } | ||
2758 | 2901 | ||
2759 | // ReferenceType | ||
2760 | 2902 | ||
2761 | #[derive(Debug, Clone)] | 2903 | impl<'a> RefPat<'a> {} |
2762 | pub struct ReferenceTypeNode(SyntaxNode); | ||
2763 | 2904 | ||
2764 | impl ReferenceTypeNode { | 2905 | // ReferenceType |
2765 | pub fn ast(&self) -> ReferenceType { | 2906 | #[derive(Debug, Clone, Copy,)] |
2766 | ReferenceType::cast(self.0.borrowed()).unwrap() | 2907 | pub struct ReferenceTypeNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
2767 | } | 2908 | pub(crate) syntax: SyntaxNode<R>, |
2768 | } | 2909 | } |
2910 | pub type ReferenceType<'a> = ReferenceTypeNode<RefRoot<'a>>; | ||
2769 | 2911 | ||
2770 | impl<'a> From<ReferenceType<'a>> for ReferenceTypeNode { | 2912 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<ReferenceTypeNode<R1>> for ReferenceTypeNode<R2> { |
2771 | fn from(ast: ReferenceType<'a>) -> ReferenceTypeNode { | 2913 | fn eq(&self, other: &ReferenceTypeNode<R1>) -> bool { self.syntax == other.syntax } |
2772 | let syntax = ast.syntax().owned(); | ||
2773 | ReferenceTypeNode(syntax) | ||
2774 | } | ||
2775 | } | 2914 | } |
2776 | #[derive(Debug, Clone, Copy)] | 2915 | impl<R: TreeRoot<RaTypes>> Eq for ReferenceTypeNode<R> {} |
2777 | pub struct ReferenceType<'a> { | 2916 | impl<R: TreeRoot<RaTypes>> Hash for ReferenceTypeNode<R> { |
2778 | syntax: SyntaxNodeRef<'a>, | 2917 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } |
2779 | } | 2918 | } |
2780 | 2919 | ||
2781 | impl<'a> AstNode<'a> for ReferenceType<'a> { | 2920 | impl<'a> AstNode<'a> for ReferenceType<'a> { |
@@ -2788,28 +2927,31 @@ impl<'a> AstNode<'a> for ReferenceType<'a> { | |||
2788 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 2927 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
2789 | } | 2928 | } |
2790 | 2929 | ||
2791 | impl<'a> ReferenceType<'a> {} | 2930 | impl<R: TreeRoot<RaTypes>> ReferenceTypeNode<R> { |
2931 | pub fn borrowed(&self) -> ReferenceType { | ||
2932 | ReferenceTypeNode { syntax: self.syntax.borrowed() } | ||
2933 | } | ||
2934 | pub fn owned(&self) -> ReferenceTypeNode { | ||
2935 | ReferenceTypeNode { syntax: self.syntax.owned() } | ||
2936 | } | ||
2937 | } | ||
2792 | 2938 | ||
2793 | // RetType | ||
2794 | 2939 | ||
2795 | #[derive(Debug, Clone)] | 2940 | impl<'a> ReferenceType<'a> {} |
2796 | pub struct RetTypeNode(SyntaxNode); | ||
2797 | 2941 | ||
2798 | impl RetTypeNode { | 2942 | // RetType |
2799 | pub fn ast(&self) -> RetType { | 2943 | #[derive(Debug, Clone, Copy,)] |
2800 | RetType::cast(self.0.borrowed()).unwrap() | 2944 | pub struct RetTypeNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
2801 | } | 2945 | pub(crate) syntax: SyntaxNode<R>, |
2802 | } | 2946 | } |
2947 | pub type RetType<'a> = RetTypeNode<RefRoot<'a>>; | ||
2803 | 2948 | ||
2804 | impl<'a> From<RetType<'a>> for RetTypeNode { | 2949 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<RetTypeNode<R1>> for RetTypeNode<R2> { |
2805 | fn from(ast: RetType<'a>) -> RetTypeNode { | 2950 | fn eq(&self, other: &RetTypeNode<R1>) -> bool { self.syntax == other.syntax } |
2806 | let syntax = ast.syntax().owned(); | ||
2807 | RetTypeNode(syntax) | ||
2808 | } | ||
2809 | } | 2951 | } |
2810 | #[derive(Debug, Clone, Copy)] | 2952 | impl<R: TreeRoot<RaTypes>> Eq for RetTypeNode<R> {} |
2811 | pub struct RetType<'a> { | 2953 | impl<R: TreeRoot<RaTypes>> Hash for RetTypeNode<R> { |
2812 | syntax: SyntaxNodeRef<'a>, | 2954 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } |
2813 | } | 2955 | } |
2814 | 2956 | ||
2815 | impl<'a> AstNode<'a> for RetType<'a> { | 2957 | impl<'a> AstNode<'a> for RetType<'a> { |
@@ -2822,28 +2964,31 @@ impl<'a> AstNode<'a> for RetType<'a> { | |||
2822 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 2964 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
2823 | } | 2965 | } |
2824 | 2966 | ||
2825 | impl<'a> RetType<'a> {} | 2967 | impl<R: TreeRoot<RaTypes>> RetTypeNode<R> { |
2968 | pub fn borrowed(&self) -> RetType { | ||
2969 | RetTypeNode { syntax: self.syntax.borrowed() } | ||
2970 | } | ||
2971 | pub fn owned(&self) -> RetTypeNode { | ||
2972 | RetTypeNode { syntax: self.syntax.owned() } | ||
2973 | } | ||
2974 | } | ||
2826 | 2975 | ||
2827 | // ReturnExpr | ||
2828 | 2976 | ||
2829 | #[derive(Debug, Clone)] | 2977 | impl<'a> RetType<'a> {} |
2830 | pub struct ReturnExprNode(SyntaxNode); | ||
2831 | 2978 | ||
2832 | impl ReturnExprNode { | 2979 | // ReturnExpr |
2833 | pub fn ast(&self) -> ReturnExpr { | 2980 | #[derive(Debug, Clone, Copy,)] |
2834 | ReturnExpr::cast(self.0.borrowed()).unwrap() | 2981 | pub struct ReturnExprNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
2835 | } | 2982 | pub(crate) syntax: SyntaxNode<R>, |
2836 | } | 2983 | } |
2984 | pub type ReturnExpr<'a> = ReturnExprNode<RefRoot<'a>>; | ||
2837 | 2985 | ||
2838 | impl<'a> From<ReturnExpr<'a>> for ReturnExprNode { | 2986 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<ReturnExprNode<R1>> for ReturnExprNode<R2> { |
2839 | fn from(ast: ReturnExpr<'a>) -> ReturnExprNode { | 2987 | fn eq(&self, other: &ReturnExprNode<R1>) -> bool { self.syntax == other.syntax } |
2840 | let syntax = ast.syntax().owned(); | ||
2841 | ReturnExprNode(syntax) | ||
2842 | } | ||
2843 | } | 2988 | } |
2844 | #[derive(Debug, Clone, Copy)] | 2989 | impl<R: TreeRoot<RaTypes>> Eq for ReturnExprNode<R> {} |
2845 | pub struct ReturnExpr<'a> { | 2990 | impl<R: TreeRoot<RaTypes>> Hash for ReturnExprNode<R> { |
2846 | syntax: SyntaxNodeRef<'a>, | 2991 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } |
2847 | } | 2992 | } |
2848 | 2993 | ||
2849 | impl<'a> AstNode<'a> for ReturnExpr<'a> { | 2994 | impl<'a> AstNode<'a> for ReturnExpr<'a> { |
@@ -2856,28 +3001,31 @@ impl<'a> AstNode<'a> for ReturnExpr<'a> { | |||
2856 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 3001 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
2857 | } | 3002 | } |
2858 | 3003 | ||
2859 | impl<'a> ReturnExpr<'a> {} | 3004 | impl<R: TreeRoot<RaTypes>> ReturnExprNode<R> { |
3005 | pub fn borrowed(&self) -> ReturnExpr { | ||
3006 | ReturnExprNode { syntax: self.syntax.borrowed() } | ||
3007 | } | ||
3008 | pub fn owned(&self) -> ReturnExprNode { | ||
3009 | ReturnExprNode { syntax: self.syntax.owned() } | ||
3010 | } | ||
3011 | } | ||
2860 | 3012 | ||
2861 | // Root | ||
2862 | 3013 | ||
2863 | #[derive(Debug, Clone)] | 3014 | impl<'a> ReturnExpr<'a> {} |
2864 | pub struct RootNode(SyntaxNode); | ||
2865 | 3015 | ||
2866 | impl RootNode { | 3016 | // Root |
2867 | pub fn ast(&self) -> Root { | 3017 | #[derive(Debug, Clone, Copy,)] |
2868 | Root::cast(self.0.borrowed()).unwrap() | 3018 | pub struct RootNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
2869 | } | 3019 | pub(crate) syntax: SyntaxNode<R>, |
2870 | } | 3020 | } |
3021 | pub type Root<'a> = RootNode<RefRoot<'a>>; | ||
2871 | 3022 | ||
2872 | impl<'a> From<Root<'a>> for RootNode { | 3023 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<RootNode<R1>> for RootNode<R2> { |
2873 | fn from(ast: Root<'a>) -> RootNode { | 3024 | fn eq(&self, other: &RootNode<R1>) -> bool { self.syntax == other.syntax } |
2874 | let syntax = ast.syntax().owned(); | ||
2875 | RootNode(syntax) | ||
2876 | } | ||
2877 | } | 3025 | } |
2878 | #[derive(Debug, Clone, Copy)] | 3026 | impl<R: TreeRoot<RaTypes>> Eq for RootNode<R> {} |
2879 | pub struct Root<'a> { | 3027 | impl<R: TreeRoot<RaTypes>> Hash for RootNode<R> { |
2880 | syntax: SyntaxNodeRef<'a>, | 3028 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } |
2881 | } | 3029 | } |
2882 | 3030 | ||
2883 | impl<'a> AstNode<'a> for Root<'a> { | 3031 | impl<'a> AstNode<'a> for Root<'a> { |
@@ -2890,6 +3038,16 @@ impl<'a> AstNode<'a> for Root<'a> { | |||
2890 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 3038 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
2891 | } | 3039 | } |
2892 | 3040 | ||
3041 | impl<R: TreeRoot<RaTypes>> RootNode<R> { | ||
3042 | pub fn borrowed(&self) -> Root { | ||
3043 | RootNode { syntax: self.syntax.borrowed() } | ||
3044 | } | ||
3045 | pub fn owned(&self) -> RootNode { | ||
3046 | RootNode { syntax: self.syntax.owned() } | ||
3047 | } | ||
3048 | } | ||
3049 | |||
3050 | |||
2893 | impl<'a> ast::ModuleItemOwner<'a> for Root<'a> {} | 3051 | impl<'a> ast::ModuleItemOwner<'a> for Root<'a> {} |
2894 | impl<'a> ast::FnDefOwner<'a> for Root<'a> {} | 3052 | impl<'a> ast::FnDefOwner<'a> for Root<'a> {} |
2895 | impl<'a> Root<'a> { | 3053 | impl<'a> Root<'a> { |
@@ -2899,25 +3057,18 @@ impl<'a> Root<'a> { | |||
2899 | } | 3057 | } |
2900 | 3058 | ||
2901 | // SelfParam | 3059 | // SelfParam |
2902 | 3060 | #[derive(Debug, Clone, Copy,)] | |
2903 | #[derive(Debug, Clone)] | 3061 | pub struct SelfParamNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
2904 | pub struct SelfParamNode(SyntaxNode); | 3062 | pub(crate) syntax: SyntaxNode<R>, |
2905 | |||
2906 | impl SelfParamNode { | ||
2907 | pub fn ast(&self) -> SelfParam { | ||
2908 | SelfParam::cast(self.0.borrowed()).unwrap() | ||
2909 | } | ||
2910 | } | 3063 | } |
3064 | pub type SelfParam<'a> = SelfParamNode<RefRoot<'a>>; | ||
2911 | 3065 | ||
2912 | impl<'a> From<SelfParam<'a>> for SelfParamNode { | 3066 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<SelfParamNode<R1>> for SelfParamNode<R2> { |
2913 | fn from(ast: SelfParam<'a>) -> SelfParamNode { | 3067 | fn eq(&self, other: &SelfParamNode<R1>) -> bool { self.syntax == other.syntax } |
2914 | let syntax = ast.syntax().owned(); | ||
2915 | SelfParamNode(syntax) | ||
2916 | } | ||
2917 | } | 3068 | } |
2918 | #[derive(Debug, Clone, Copy)] | 3069 | impl<R: TreeRoot<RaTypes>> Eq for SelfParamNode<R> {} |
2919 | pub struct SelfParam<'a> { | 3070 | impl<R: TreeRoot<RaTypes>> Hash for SelfParamNode<R> { |
2920 | syntax: SyntaxNodeRef<'a>, | 3071 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } |
2921 | } | 3072 | } |
2922 | 3073 | ||
2923 | impl<'a> AstNode<'a> for SelfParam<'a> { | 3074 | impl<'a> AstNode<'a> for SelfParam<'a> { |
@@ -2930,28 +3081,31 @@ impl<'a> AstNode<'a> for SelfParam<'a> { | |||
2930 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 3081 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
2931 | } | 3082 | } |
2932 | 3083 | ||
2933 | impl<'a> SelfParam<'a> {} | 3084 | impl<R: TreeRoot<RaTypes>> SelfParamNode<R> { |
3085 | pub fn borrowed(&self) -> SelfParam { | ||
3086 | SelfParamNode { syntax: self.syntax.borrowed() } | ||
3087 | } | ||
3088 | pub fn owned(&self) -> SelfParamNode { | ||
3089 | SelfParamNode { syntax: self.syntax.owned() } | ||
3090 | } | ||
3091 | } | ||
2934 | 3092 | ||
2935 | // SlicePat | ||
2936 | 3093 | ||
2937 | #[derive(Debug, Clone)] | 3094 | impl<'a> SelfParam<'a> {} |
2938 | pub struct SlicePatNode(SyntaxNode); | ||
2939 | 3095 | ||
2940 | impl SlicePatNode { | 3096 | // SlicePat |
2941 | pub fn ast(&self) -> SlicePat { | 3097 | #[derive(Debug, Clone, Copy,)] |
2942 | SlicePat::cast(self.0.borrowed()).unwrap() | 3098 | pub struct SlicePatNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
2943 | } | 3099 | pub(crate) syntax: SyntaxNode<R>, |
2944 | } | 3100 | } |
3101 | pub type SlicePat<'a> = SlicePatNode<RefRoot<'a>>; | ||
2945 | 3102 | ||
2946 | impl<'a> From<SlicePat<'a>> for SlicePatNode { | 3103 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<SlicePatNode<R1>> for SlicePatNode<R2> { |
2947 | fn from(ast: SlicePat<'a>) -> SlicePatNode { | 3104 | fn eq(&self, other: &SlicePatNode<R1>) -> bool { self.syntax == other.syntax } |
2948 | let syntax = ast.syntax().owned(); | ||
2949 | SlicePatNode(syntax) | ||
2950 | } | ||
2951 | } | 3105 | } |
2952 | #[derive(Debug, Clone, Copy)] | 3106 | impl<R: TreeRoot<RaTypes>> Eq for SlicePatNode<R> {} |
2953 | pub struct SlicePat<'a> { | 3107 | impl<R: TreeRoot<RaTypes>> Hash for SlicePatNode<R> { |
2954 | syntax: SyntaxNodeRef<'a>, | 3108 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } |
2955 | } | 3109 | } |
2956 | 3110 | ||
2957 | impl<'a> AstNode<'a> for SlicePat<'a> { | 3111 | impl<'a> AstNode<'a> for SlicePat<'a> { |
@@ -2964,28 +3118,31 @@ impl<'a> AstNode<'a> for SlicePat<'a> { | |||
2964 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 3118 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
2965 | } | 3119 | } |
2966 | 3120 | ||
2967 | impl<'a> SlicePat<'a> {} | 3121 | impl<R: TreeRoot<RaTypes>> SlicePatNode<R> { |
3122 | pub fn borrowed(&self) -> SlicePat { | ||
3123 | SlicePatNode { syntax: self.syntax.borrowed() } | ||
3124 | } | ||
3125 | pub fn owned(&self) -> SlicePatNode { | ||
3126 | SlicePatNode { syntax: self.syntax.owned() } | ||
3127 | } | ||
3128 | } | ||
2968 | 3129 | ||
2969 | // SliceType | ||
2970 | 3130 | ||
2971 | #[derive(Debug, Clone)] | 3131 | impl<'a> SlicePat<'a> {} |
2972 | pub struct SliceTypeNode(SyntaxNode); | ||
2973 | 3132 | ||
2974 | impl SliceTypeNode { | 3133 | // SliceType |
2975 | pub fn ast(&self) -> SliceType { | 3134 | #[derive(Debug, Clone, Copy,)] |
2976 | SliceType::cast(self.0.borrowed()).unwrap() | 3135 | pub struct SliceTypeNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
2977 | } | 3136 | pub(crate) syntax: SyntaxNode<R>, |
2978 | } | 3137 | } |
3138 | pub type SliceType<'a> = SliceTypeNode<RefRoot<'a>>; | ||
2979 | 3139 | ||
2980 | impl<'a> From<SliceType<'a>> for SliceTypeNode { | 3140 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<SliceTypeNode<R1>> for SliceTypeNode<R2> { |
2981 | fn from(ast: SliceType<'a>) -> SliceTypeNode { | 3141 | fn eq(&self, other: &SliceTypeNode<R1>) -> bool { self.syntax == other.syntax } |
2982 | let syntax = ast.syntax().owned(); | ||
2983 | SliceTypeNode(syntax) | ||
2984 | } | ||
2985 | } | 3142 | } |
2986 | #[derive(Debug, Clone, Copy)] | 3143 | impl<R: TreeRoot<RaTypes>> Eq for SliceTypeNode<R> {} |
2987 | pub struct SliceType<'a> { | 3144 | impl<R: TreeRoot<RaTypes>> Hash for SliceTypeNode<R> { |
2988 | syntax: SyntaxNodeRef<'a>, | 3145 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } |
2989 | } | 3146 | } |
2990 | 3147 | ||
2991 | impl<'a> AstNode<'a> for SliceType<'a> { | 3148 | impl<'a> AstNode<'a> for SliceType<'a> { |
@@ -2998,28 +3155,31 @@ impl<'a> AstNode<'a> for SliceType<'a> { | |||
2998 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 3155 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
2999 | } | 3156 | } |
3000 | 3157 | ||
3001 | impl<'a> SliceType<'a> {} | 3158 | impl<R: TreeRoot<RaTypes>> SliceTypeNode<R> { |
3159 | pub fn borrowed(&self) -> SliceType { | ||
3160 | SliceTypeNode { syntax: self.syntax.borrowed() } | ||
3161 | } | ||
3162 | pub fn owned(&self) -> SliceTypeNode { | ||
3163 | SliceTypeNode { syntax: self.syntax.owned() } | ||
3164 | } | ||
3165 | } | ||
3002 | 3166 | ||
3003 | // StaticDef | ||
3004 | 3167 | ||
3005 | #[derive(Debug, Clone)] | 3168 | impl<'a> SliceType<'a> {} |
3006 | pub struct StaticDefNode(SyntaxNode); | ||
3007 | 3169 | ||
3008 | impl StaticDefNode { | 3170 | // StaticDef |
3009 | pub fn ast(&self) -> StaticDef { | 3171 | #[derive(Debug, Clone, Copy,)] |
3010 | StaticDef::cast(self.0.borrowed()).unwrap() | 3172 | pub struct StaticDefNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
3011 | } | 3173 | pub(crate) syntax: SyntaxNode<R>, |
3012 | } | 3174 | } |
3175 | pub type StaticDef<'a> = StaticDefNode<RefRoot<'a>>; | ||
3013 | 3176 | ||
3014 | impl<'a> From<StaticDef<'a>> for StaticDefNode { | 3177 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<StaticDefNode<R1>> for StaticDefNode<R2> { |
3015 | fn from(ast: StaticDef<'a>) -> StaticDefNode { | 3178 | fn eq(&self, other: &StaticDefNode<R1>) -> bool { self.syntax == other.syntax } |
3016 | let syntax = ast.syntax().owned(); | ||
3017 | StaticDefNode(syntax) | ||
3018 | } | ||
3019 | } | 3179 | } |
3020 | #[derive(Debug, Clone, Copy)] | 3180 | impl<R: TreeRoot<RaTypes>> Eq for StaticDefNode<R> {} |
3021 | pub struct StaticDef<'a> { | 3181 | impl<R: TreeRoot<RaTypes>> Hash for StaticDefNode<R> { |
3022 | syntax: SyntaxNodeRef<'a>, | 3182 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } |
3023 | } | 3183 | } |
3024 | 3184 | ||
3025 | impl<'a> AstNode<'a> for StaticDef<'a> { | 3185 | impl<'a> AstNode<'a> for StaticDef<'a> { |
@@ -3032,29 +3192,23 @@ impl<'a> AstNode<'a> for StaticDef<'a> { | |||
3032 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 3192 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
3033 | } | 3193 | } |
3034 | 3194 | ||
3195 | impl<R: TreeRoot<RaTypes>> StaticDefNode<R> { | ||
3196 | pub fn borrowed(&self) -> StaticDef { | ||
3197 | StaticDefNode { syntax: self.syntax.borrowed() } | ||
3198 | } | ||
3199 | pub fn owned(&self) -> StaticDefNode { | ||
3200 | StaticDefNode { syntax: self.syntax.owned() } | ||
3201 | } | ||
3202 | } | ||
3203 | |||
3204 | |||
3035 | impl<'a> ast::NameOwner<'a> for StaticDef<'a> {} | 3205 | impl<'a> ast::NameOwner<'a> for StaticDef<'a> {} |
3036 | impl<'a> ast::TypeParamsOwner<'a> for StaticDef<'a> {} | 3206 | impl<'a> ast::TypeParamsOwner<'a> for StaticDef<'a> {} |
3037 | impl<'a> ast::AttrsOwner<'a> for StaticDef<'a> {} | 3207 | impl<'a> ast::AttrsOwner<'a> for StaticDef<'a> {} |
3038 | impl<'a> StaticDef<'a> {} | 3208 | impl<'a> StaticDef<'a> {} |
3039 | 3209 | ||
3040 | // Stmt | 3210 | // Stmt |
3041 | 3211 | #[derive(Debug, Clone, Copy, PartialEq, Eq)] | |
3042 | #[derive(Debug, Clone)] | ||
3043 | pub struct StmtNode(SyntaxNode); | ||
3044 | |||
3045 | impl StmtNode { | ||
3046 | pub fn ast(&self) -> Stmt { | ||
3047 | Stmt::cast(self.0.borrowed()).unwrap() | ||
3048 | } | ||
3049 | } | ||
3050 | |||
3051 | impl<'a> From<Stmt<'a>> for StmtNode { | ||
3052 | fn from(ast: Stmt<'a>) -> StmtNode { | ||
3053 | let syntax = ast.syntax().owned(); | ||
3054 | StmtNode(syntax) | ||
3055 | } | ||
3056 | } | ||
3057 | #[derive(Debug, Clone, Copy)] | ||
3058 | pub enum Stmt<'a> { | 3212 | pub enum Stmt<'a> { |
3059 | ExprStmt(ExprStmt<'a>), | 3213 | ExprStmt(ExprStmt<'a>), |
3060 | LetStmt(LetStmt<'a>), | 3214 | LetStmt(LetStmt<'a>), |
@@ -3079,25 +3233,18 @@ impl<'a> AstNode<'a> for Stmt<'a> { | |||
3079 | impl<'a> Stmt<'a> {} | 3233 | impl<'a> Stmt<'a> {} |
3080 | 3234 | ||
3081 | // StructDef | 3235 | // StructDef |
3082 | 3236 | #[derive(Debug, Clone, Copy,)] | |
3083 | #[derive(Debug, Clone)] | 3237 | pub struct StructDefNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
3084 | pub struct StructDefNode(SyntaxNode); | 3238 | pub(crate) syntax: SyntaxNode<R>, |
3085 | |||
3086 | impl StructDefNode { | ||
3087 | pub fn ast(&self) -> StructDef { | ||
3088 | StructDef::cast(self.0.borrowed()).unwrap() | ||
3089 | } | ||
3090 | } | 3239 | } |
3240 | pub type StructDef<'a> = StructDefNode<RefRoot<'a>>; | ||
3091 | 3241 | ||
3092 | impl<'a> From<StructDef<'a>> for StructDefNode { | 3242 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<StructDefNode<R1>> for StructDefNode<R2> { |
3093 | fn from(ast: StructDef<'a>) -> StructDefNode { | 3243 | fn eq(&self, other: &StructDefNode<R1>) -> bool { self.syntax == other.syntax } |
3094 | let syntax = ast.syntax().owned(); | ||
3095 | StructDefNode(syntax) | ||
3096 | } | ||
3097 | } | 3244 | } |
3098 | #[derive(Debug, Clone, Copy)] | 3245 | impl<R: TreeRoot<RaTypes>> Eq for StructDefNode<R> {} |
3099 | pub struct StructDef<'a> { | 3246 | impl<R: TreeRoot<RaTypes>> Hash for StructDefNode<R> { |
3100 | syntax: SyntaxNodeRef<'a>, | 3247 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } |
3101 | } | 3248 | } |
3102 | 3249 | ||
3103 | impl<'a> AstNode<'a> for StructDef<'a> { | 3250 | impl<'a> AstNode<'a> for StructDef<'a> { |
@@ -3110,6 +3257,16 @@ impl<'a> AstNode<'a> for StructDef<'a> { | |||
3110 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 3257 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
3111 | } | 3258 | } |
3112 | 3259 | ||
3260 | impl<R: TreeRoot<RaTypes>> StructDefNode<R> { | ||
3261 | pub fn borrowed(&self) -> StructDef { | ||
3262 | StructDefNode { syntax: self.syntax.borrowed() } | ||
3263 | } | ||
3264 | pub fn owned(&self) -> StructDefNode { | ||
3265 | StructDefNode { syntax: self.syntax.owned() } | ||
3266 | } | ||
3267 | } | ||
3268 | |||
3269 | |||
3113 | impl<'a> ast::NameOwner<'a> for StructDef<'a> {} | 3270 | impl<'a> ast::NameOwner<'a> for StructDef<'a> {} |
3114 | impl<'a> ast::TypeParamsOwner<'a> for StructDef<'a> {} | 3271 | impl<'a> ast::TypeParamsOwner<'a> for StructDef<'a> {} |
3115 | impl<'a> ast::AttrsOwner<'a> for StructDef<'a> {} | 3272 | impl<'a> ast::AttrsOwner<'a> for StructDef<'a> {} |
@@ -3120,25 +3277,18 @@ impl<'a> StructDef<'a> { | |||
3120 | } | 3277 | } |
3121 | 3278 | ||
3122 | // StructLit | 3279 | // StructLit |
3123 | 3280 | #[derive(Debug, Clone, Copy,)] | |
3124 | #[derive(Debug, Clone)] | 3281 | pub struct StructLitNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
3125 | pub struct StructLitNode(SyntaxNode); | 3282 | pub(crate) syntax: SyntaxNode<R>, |
3126 | |||
3127 | impl StructLitNode { | ||
3128 | pub fn ast(&self) -> StructLit { | ||
3129 | StructLit::cast(self.0.borrowed()).unwrap() | ||
3130 | } | ||
3131 | } | 3283 | } |
3284 | pub type StructLit<'a> = StructLitNode<RefRoot<'a>>; | ||
3132 | 3285 | ||
3133 | impl<'a> From<StructLit<'a>> for StructLitNode { | 3286 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<StructLitNode<R1>> for StructLitNode<R2> { |
3134 | fn from(ast: StructLit<'a>) -> StructLitNode { | 3287 | fn eq(&self, other: &StructLitNode<R1>) -> bool { self.syntax == other.syntax } |
3135 | let syntax = ast.syntax().owned(); | ||
3136 | StructLitNode(syntax) | ||
3137 | } | ||
3138 | } | 3288 | } |
3139 | #[derive(Debug, Clone, Copy)] | 3289 | impl<R: TreeRoot<RaTypes>> Eq for StructLitNode<R> {} |
3140 | pub struct StructLit<'a> { | 3290 | impl<R: TreeRoot<RaTypes>> Hash for StructLitNode<R> { |
3141 | syntax: SyntaxNodeRef<'a>, | 3291 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } |
3142 | } | 3292 | } |
3143 | 3293 | ||
3144 | impl<'a> AstNode<'a> for StructLit<'a> { | 3294 | impl<'a> AstNode<'a> for StructLit<'a> { |
@@ -3151,28 +3301,31 @@ impl<'a> AstNode<'a> for StructLit<'a> { | |||
3151 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 3301 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
3152 | } | 3302 | } |
3153 | 3303 | ||
3154 | impl<'a> StructLit<'a> {} | 3304 | impl<R: TreeRoot<RaTypes>> StructLitNode<R> { |
3305 | pub fn borrowed(&self) -> StructLit { | ||
3306 | StructLitNode { syntax: self.syntax.borrowed() } | ||
3307 | } | ||
3308 | pub fn owned(&self) -> StructLitNode { | ||
3309 | StructLitNode { syntax: self.syntax.owned() } | ||
3310 | } | ||
3311 | } | ||
3155 | 3312 | ||
3156 | // StructPat | ||
3157 | 3313 | ||
3158 | #[derive(Debug, Clone)] | 3314 | impl<'a> StructLit<'a> {} |
3159 | pub struct StructPatNode(SyntaxNode); | ||
3160 | 3315 | ||
3161 | impl StructPatNode { | 3316 | // StructPat |
3162 | pub fn ast(&self) -> StructPat { | 3317 | #[derive(Debug, Clone, Copy,)] |
3163 | StructPat::cast(self.0.borrowed()).unwrap() | 3318 | pub struct StructPatNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
3164 | } | 3319 | pub(crate) syntax: SyntaxNode<R>, |
3165 | } | 3320 | } |
3321 | pub type StructPat<'a> = StructPatNode<RefRoot<'a>>; | ||
3166 | 3322 | ||
3167 | impl<'a> From<StructPat<'a>> for StructPatNode { | 3323 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<StructPatNode<R1>> for StructPatNode<R2> { |
3168 | fn from(ast: StructPat<'a>) -> StructPatNode { | 3324 | fn eq(&self, other: &StructPatNode<R1>) -> bool { self.syntax == other.syntax } |
3169 | let syntax = ast.syntax().owned(); | ||
3170 | StructPatNode(syntax) | ||
3171 | } | ||
3172 | } | 3325 | } |
3173 | #[derive(Debug, Clone, Copy)] | 3326 | impl<R: TreeRoot<RaTypes>> Eq for StructPatNode<R> {} |
3174 | pub struct StructPat<'a> { | 3327 | impl<R: TreeRoot<RaTypes>> Hash for StructPatNode<R> { |
3175 | syntax: SyntaxNodeRef<'a>, | 3328 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } |
3176 | } | 3329 | } |
3177 | 3330 | ||
3178 | impl<'a> AstNode<'a> for StructPat<'a> { | 3331 | impl<'a> AstNode<'a> for StructPat<'a> { |
@@ -3185,28 +3338,31 @@ impl<'a> AstNode<'a> for StructPat<'a> { | |||
3185 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 3338 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
3186 | } | 3339 | } |
3187 | 3340 | ||
3188 | impl<'a> StructPat<'a> {} | 3341 | impl<R: TreeRoot<RaTypes>> StructPatNode<R> { |
3342 | pub fn borrowed(&self) -> StructPat { | ||
3343 | StructPatNode { syntax: self.syntax.borrowed() } | ||
3344 | } | ||
3345 | pub fn owned(&self) -> StructPatNode { | ||
3346 | StructPatNode { syntax: self.syntax.owned() } | ||
3347 | } | ||
3348 | } | ||
3189 | 3349 | ||
3190 | // TokenTree | ||
3191 | 3350 | ||
3192 | #[derive(Debug, Clone)] | 3351 | impl<'a> StructPat<'a> {} |
3193 | pub struct TokenTreeNode(SyntaxNode); | ||
3194 | 3352 | ||
3195 | impl TokenTreeNode { | 3353 | // TokenTree |
3196 | pub fn ast(&self) -> TokenTree { | 3354 | #[derive(Debug, Clone, Copy,)] |
3197 | TokenTree::cast(self.0.borrowed()).unwrap() | 3355 | pub struct TokenTreeNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
3198 | } | 3356 | pub(crate) syntax: SyntaxNode<R>, |
3199 | } | 3357 | } |
3358 | pub type TokenTree<'a> = TokenTreeNode<RefRoot<'a>>; | ||
3200 | 3359 | ||
3201 | impl<'a> From<TokenTree<'a>> for TokenTreeNode { | 3360 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<TokenTreeNode<R1>> for TokenTreeNode<R2> { |
3202 | fn from(ast: TokenTree<'a>) -> TokenTreeNode { | 3361 | fn eq(&self, other: &TokenTreeNode<R1>) -> bool { self.syntax == other.syntax } |
3203 | let syntax = ast.syntax().owned(); | ||
3204 | TokenTreeNode(syntax) | ||
3205 | } | ||
3206 | } | 3362 | } |
3207 | #[derive(Debug, Clone, Copy)] | 3363 | impl<R: TreeRoot<RaTypes>> Eq for TokenTreeNode<R> {} |
3208 | pub struct TokenTree<'a> { | 3364 | impl<R: TreeRoot<RaTypes>> Hash for TokenTreeNode<R> { |
3209 | syntax: SyntaxNodeRef<'a>, | 3365 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } |
3210 | } | 3366 | } |
3211 | 3367 | ||
3212 | impl<'a> AstNode<'a> for TokenTree<'a> { | 3368 | impl<'a> AstNode<'a> for TokenTree<'a> { |
@@ -3219,28 +3375,31 @@ impl<'a> AstNode<'a> for TokenTree<'a> { | |||
3219 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 3375 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
3220 | } | 3376 | } |
3221 | 3377 | ||
3222 | impl<'a> TokenTree<'a> {} | 3378 | impl<R: TreeRoot<RaTypes>> TokenTreeNode<R> { |
3379 | pub fn borrowed(&self) -> TokenTree { | ||
3380 | TokenTreeNode { syntax: self.syntax.borrowed() } | ||
3381 | } | ||
3382 | pub fn owned(&self) -> TokenTreeNode { | ||
3383 | TokenTreeNode { syntax: self.syntax.owned() } | ||
3384 | } | ||
3385 | } | ||
3223 | 3386 | ||
3224 | // TraitDef | ||
3225 | 3387 | ||
3226 | #[derive(Debug, Clone)] | 3388 | impl<'a> TokenTree<'a> {} |
3227 | pub struct TraitDefNode(SyntaxNode); | ||
3228 | 3389 | ||
3229 | impl TraitDefNode { | 3390 | // TraitDef |
3230 | pub fn ast(&self) -> TraitDef { | 3391 | #[derive(Debug, Clone, Copy,)] |
3231 | TraitDef::cast(self.0.borrowed()).unwrap() | 3392 | pub struct TraitDefNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
3232 | } | 3393 | pub(crate) syntax: SyntaxNode<R>, |
3233 | } | 3394 | } |
3395 | pub type TraitDef<'a> = TraitDefNode<RefRoot<'a>>; | ||
3234 | 3396 | ||
3235 | impl<'a> From<TraitDef<'a>> for TraitDefNode { | 3397 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<TraitDefNode<R1>> for TraitDefNode<R2> { |
3236 | fn from(ast: TraitDef<'a>) -> TraitDefNode { | 3398 | fn eq(&self, other: &TraitDefNode<R1>) -> bool { self.syntax == other.syntax } |
3237 | let syntax = ast.syntax().owned(); | ||
3238 | TraitDefNode(syntax) | ||
3239 | } | ||
3240 | } | 3399 | } |
3241 | #[derive(Debug, Clone, Copy)] | 3400 | impl<R: TreeRoot<RaTypes>> Eq for TraitDefNode<R> {} |
3242 | pub struct TraitDef<'a> { | 3401 | impl<R: TreeRoot<RaTypes>> Hash for TraitDefNode<R> { |
3243 | syntax: SyntaxNodeRef<'a>, | 3402 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } |
3244 | } | 3403 | } |
3245 | 3404 | ||
3246 | impl<'a> AstNode<'a> for TraitDef<'a> { | 3405 | impl<'a> AstNode<'a> for TraitDef<'a> { |
@@ -3253,30 +3412,33 @@ impl<'a> AstNode<'a> for TraitDef<'a> { | |||
3253 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 3412 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
3254 | } | 3413 | } |
3255 | 3414 | ||
3415 | impl<R: TreeRoot<RaTypes>> TraitDefNode<R> { | ||
3416 | pub fn borrowed(&self) -> TraitDef { | ||
3417 | TraitDefNode { syntax: self.syntax.borrowed() } | ||
3418 | } | ||
3419 | pub fn owned(&self) -> TraitDefNode { | ||
3420 | TraitDefNode { syntax: self.syntax.owned() } | ||
3421 | } | ||
3422 | } | ||
3423 | |||
3424 | |||
3256 | impl<'a> ast::NameOwner<'a> for TraitDef<'a> {} | 3425 | impl<'a> ast::NameOwner<'a> for TraitDef<'a> {} |
3257 | impl<'a> ast::AttrsOwner<'a> for TraitDef<'a> {} | 3426 | impl<'a> ast::AttrsOwner<'a> for TraitDef<'a> {} |
3258 | impl<'a> TraitDef<'a> {} | 3427 | impl<'a> TraitDef<'a> {} |
3259 | 3428 | ||
3260 | // TryExpr | 3429 | // TryExpr |
3261 | 3430 | #[derive(Debug, Clone, Copy,)] | |
3262 | #[derive(Debug, Clone)] | 3431 | pub struct TryExprNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
3263 | pub struct TryExprNode(SyntaxNode); | 3432 | pub(crate) syntax: SyntaxNode<R>, |
3264 | |||
3265 | impl TryExprNode { | ||
3266 | pub fn ast(&self) -> TryExpr { | ||
3267 | TryExpr::cast(self.0.borrowed()).unwrap() | ||
3268 | } | ||
3269 | } | 3433 | } |
3434 | pub type TryExpr<'a> = TryExprNode<RefRoot<'a>>; | ||
3270 | 3435 | ||
3271 | impl<'a> From<TryExpr<'a>> for TryExprNode { | 3436 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<TryExprNode<R1>> for TryExprNode<R2> { |
3272 | fn from(ast: TryExpr<'a>) -> TryExprNode { | 3437 | fn eq(&self, other: &TryExprNode<R1>) -> bool { self.syntax == other.syntax } |
3273 | let syntax = ast.syntax().owned(); | ||
3274 | TryExprNode(syntax) | ||
3275 | } | ||
3276 | } | 3438 | } |
3277 | #[derive(Debug, Clone, Copy)] | 3439 | impl<R: TreeRoot<RaTypes>> Eq for TryExprNode<R> {} |
3278 | pub struct TryExpr<'a> { | 3440 | impl<R: TreeRoot<RaTypes>> Hash for TryExprNode<R> { |
3279 | syntax: SyntaxNodeRef<'a>, | 3441 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } |
3280 | } | 3442 | } |
3281 | 3443 | ||
3282 | impl<'a> AstNode<'a> for TryExpr<'a> { | 3444 | impl<'a> AstNode<'a> for TryExpr<'a> { |
@@ -3289,28 +3451,31 @@ impl<'a> AstNode<'a> for TryExpr<'a> { | |||
3289 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 3451 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
3290 | } | 3452 | } |
3291 | 3453 | ||
3292 | impl<'a> TryExpr<'a> {} | 3454 | impl<R: TreeRoot<RaTypes>> TryExprNode<R> { |
3455 | pub fn borrowed(&self) -> TryExpr { | ||
3456 | TryExprNode { syntax: self.syntax.borrowed() } | ||
3457 | } | ||
3458 | pub fn owned(&self) -> TryExprNode { | ||
3459 | TryExprNode { syntax: self.syntax.owned() } | ||
3460 | } | ||
3461 | } | ||
3293 | 3462 | ||
3294 | // TupleExpr | ||
3295 | 3463 | ||
3296 | #[derive(Debug, Clone)] | 3464 | impl<'a> TryExpr<'a> {} |
3297 | pub struct TupleExprNode(SyntaxNode); | ||
3298 | 3465 | ||
3299 | impl TupleExprNode { | 3466 | // TupleExpr |
3300 | pub fn ast(&self) -> TupleExpr { | 3467 | #[derive(Debug, Clone, Copy,)] |
3301 | TupleExpr::cast(self.0.borrowed()).unwrap() | 3468 | pub struct TupleExprNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
3302 | } | 3469 | pub(crate) syntax: SyntaxNode<R>, |
3303 | } | 3470 | } |
3471 | pub type TupleExpr<'a> = TupleExprNode<RefRoot<'a>>; | ||
3304 | 3472 | ||
3305 | impl<'a> From<TupleExpr<'a>> for TupleExprNode { | 3473 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<TupleExprNode<R1>> for TupleExprNode<R2> { |
3306 | fn from(ast: TupleExpr<'a>) -> TupleExprNode { | 3474 | fn eq(&self, other: &TupleExprNode<R1>) -> bool { self.syntax == other.syntax } |
3307 | let syntax = ast.syntax().owned(); | ||
3308 | TupleExprNode(syntax) | ||
3309 | } | ||
3310 | } | 3475 | } |
3311 | #[derive(Debug, Clone, Copy)] | 3476 | impl<R: TreeRoot<RaTypes>> Eq for TupleExprNode<R> {} |
3312 | pub struct TupleExpr<'a> { | 3477 | impl<R: TreeRoot<RaTypes>> Hash for TupleExprNode<R> { |
3313 | syntax: SyntaxNodeRef<'a>, | 3478 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } |
3314 | } | 3479 | } |
3315 | 3480 | ||
3316 | impl<'a> AstNode<'a> for TupleExpr<'a> { | 3481 | impl<'a> AstNode<'a> for TupleExpr<'a> { |
@@ -3323,28 +3488,31 @@ impl<'a> AstNode<'a> for TupleExpr<'a> { | |||
3323 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 3488 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
3324 | } | 3489 | } |
3325 | 3490 | ||
3326 | impl<'a> TupleExpr<'a> {} | 3491 | impl<R: TreeRoot<RaTypes>> TupleExprNode<R> { |
3492 | pub fn borrowed(&self) -> TupleExpr { | ||
3493 | TupleExprNode { syntax: self.syntax.borrowed() } | ||
3494 | } | ||
3495 | pub fn owned(&self) -> TupleExprNode { | ||
3496 | TupleExprNode { syntax: self.syntax.owned() } | ||
3497 | } | ||
3498 | } | ||
3327 | 3499 | ||
3328 | // TuplePat | ||
3329 | 3500 | ||
3330 | #[derive(Debug, Clone)] | 3501 | impl<'a> TupleExpr<'a> {} |
3331 | pub struct TuplePatNode(SyntaxNode); | ||
3332 | 3502 | ||
3333 | impl TuplePatNode { | 3503 | // TuplePat |
3334 | pub fn ast(&self) -> TuplePat { | 3504 | #[derive(Debug, Clone, Copy,)] |
3335 | TuplePat::cast(self.0.borrowed()).unwrap() | 3505 | pub struct TuplePatNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
3336 | } | 3506 | pub(crate) syntax: SyntaxNode<R>, |
3337 | } | 3507 | } |
3508 | pub type TuplePat<'a> = TuplePatNode<RefRoot<'a>>; | ||
3338 | 3509 | ||
3339 | impl<'a> From<TuplePat<'a>> for TuplePatNode { | 3510 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<TuplePatNode<R1>> for TuplePatNode<R2> { |
3340 | fn from(ast: TuplePat<'a>) -> TuplePatNode { | 3511 | fn eq(&self, other: &TuplePatNode<R1>) -> bool { self.syntax == other.syntax } |
3341 | let syntax = ast.syntax().owned(); | ||
3342 | TuplePatNode(syntax) | ||
3343 | } | ||
3344 | } | 3512 | } |
3345 | #[derive(Debug, Clone, Copy)] | 3513 | impl<R: TreeRoot<RaTypes>> Eq for TuplePatNode<R> {} |
3346 | pub struct TuplePat<'a> { | 3514 | impl<R: TreeRoot<RaTypes>> Hash for TuplePatNode<R> { |
3347 | syntax: SyntaxNodeRef<'a>, | 3515 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } |
3348 | } | 3516 | } |
3349 | 3517 | ||
3350 | impl<'a> AstNode<'a> for TuplePat<'a> { | 3518 | impl<'a> AstNode<'a> for TuplePat<'a> { |
@@ -3357,28 +3525,31 @@ impl<'a> AstNode<'a> for TuplePat<'a> { | |||
3357 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 3525 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
3358 | } | 3526 | } |
3359 | 3527 | ||
3360 | impl<'a> TuplePat<'a> {} | 3528 | impl<R: TreeRoot<RaTypes>> TuplePatNode<R> { |
3529 | pub fn borrowed(&self) -> TuplePat { | ||
3530 | TuplePatNode { syntax: self.syntax.borrowed() } | ||
3531 | } | ||
3532 | pub fn owned(&self) -> TuplePatNode { | ||
3533 | TuplePatNode { syntax: self.syntax.owned() } | ||
3534 | } | ||
3535 | } | ||
3361 | 3536 | ||
3362 | // TupleStructPat | ||
3363 | 3537 | ||
3364 | #[derive(Debug, Clone)] | 3538 | impl<'a> TuplePat<'a> {} |
3365 | pub struct TupleStructPatNode(SyntaxNode); | ||
3366 | 3539 | ||
3367 | impl TupleStructPatNode { | 3540 | // TupleStructPat |
3368 | pub fn ast(&self) -> TupleStructPat { | 3541 | #[derive(Debug, Clone, Copy,)] |
3369 | TupleStructPat::cast(self.0.borrowed()).unwrap() | 3542 | pub struct TupleStructPatNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
3370 | } | 3543 | pub(crate) syntax: SyntaxNode<R>, |
3371 | } | 3544 | } |
3545 | pub type TupleStructPat<'a> = TupleStructPatNode<RefRoot<'a>>; | ||
3372 | 3546 | ||
3373 | impl<'a> From<TupleStructPat<'a>> for TupleStructPatNode { | 3547 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<TupleStructPatNode<R1>> for TupleStructPatNode<R2> { |
3374 | fn from(ast: TupleStructPat<'a>) -> TupleStructPatNode { | 3548 | fn eq(&self, other: &TupleStructPatNode<R1>) -> bool { self.syntax == other.syntax } |
3375 | let syntax = ast.syntax().owned(); | ||
3376 | TupleStructPatNode(syntax) | ||
3377 | } | ||
3378 | } | 3549 | } |
3379 | #[derive(Debug, Clone, Copy)] | 3550 | impl<R: TreeRoot<RaTypes>> Eq for TupleStructPatNode<R> {} |
3380 | pub struct TupleStructPat<'a> { | 3551 | impl<R: TreeRoot<RaTypes>> Hash for TupleStructPatNode<R> { |
3381 | syntax: SyntaxNodeRef<'a>, | 3552 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } |
3382 | } | 3553 | } |
3383 | 3554 | ||
3384 | impl<'a> AstNode<'a> for TupleStructPat<'a> { | 3555 | impl<'a> AstNode<'a> for TupleStructPat<'a> { |
@@ -3391,28 +3562,31 @@ impl<'a> AstNode<'a> for TupleStructPat<'a> { | |||
3391 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 3562 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
3392 | } | 3563 | } |
3393 | 3564 | ||
3394 | impl<'a> TupleStructPat<'a> {} | 3565 | impl<R: TreeRoot<RaTypes>> TupleStructPatNode<R> { |
3566 | pub fn borrowed(&self) -> TupleStructPat { | ||
3567 | TupleStructPatNode { syntax: self.syntax.borrowed() } | ||
3568 | } | ||
3569 | pub fn owned(&self) -> TupleStructPatNode { | ||
3570 | TupleStructPatNode { syntax: self.syntax.owned() } | ||
3571 | } | ||
3572 | } | ||
3395 | 3573 | ||
3396 | // TupleType | ||
3397 | 3574 | ||
3398 | #[derive(Debug, Clone)] | 3575 | impl<'a> TupleStructPat<'a> {} |
3399 | pub struct TupleTypeNode(SyntaxNode); | ||
3400 | 3576 | ||
3401 | impl TupleTypeNode { | 3577 | // TupleType |
3402 | pub fn ast(&self) -> TupleType { | 3578 | #[derive(Debug, Clone, Copy,)] |
3403 | TupleType::cast(self.0.borrowed()).unwrap() | 3579 | pub struct TupleTypeNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
3404 | } | 3580 | pub(crate) syntax: SyntaxNode<R>, |
3405 | } | 3581 | } |
3582 | pub type TupleType<'a> = TupleTypeNode<RefRoot<'a>>; | ||
3406 | 3583 | ||
3407 | impl<'a> From<TupleType<'a>> for TupleTypeNode { | 3584 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<TupleTypeNode<R1>> for TupleTypeNode<R2> { |
3408 | fn from(ast: TupleType<'a>) -> TupleTypeNode { | 3585 | fn eq(&self, other: &TupleTypeNode<R1>) -> bool { self.syntax == other.syntax } |
3409 | let syntax = ast.syntax().owned(); | ||
3410 | TupleTypeNode(syntax) | ||
3411 | } | ||
3412 | } | 3586 | } |
3413 | #[derive(Debug, Clone, Copy)] | 3587 | impl<R: TreeRoot<RaTypes>> Eq for TupleTypeNode<R> {} |
3414 | pub struct TupleType<'a> { | 3588 | impl<R: TreeRoot<RaTypes>> Hash for TupleTypeNode<R> { |
3415 | syntax: SyntaxNodeRef<'a>, | 3589 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } |
3416 | } | 3590 | } |
3417 | 3591 | ||
3418 | impl<'a> AstNode<'a> for TupleType<'a> { | 3592 | impl<'a> AstNode<'a> for TupleType<'a> { |
@@ -3425,28 +3599,31 @@ impl<'a> AstNode<'a> for TupleType<'a> { | |||
3425 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 3599 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
3426 | } | 3600 | } |
3427 | 3601 | ||
3428 | impl<'a> TupleType<'a> {} | 3602 | impl<R: TreeRoot<RaTypes>> TupleTypeNode<R> { |
3603 | pub fn borrowed(&self) -> TupleType { | ||
3604 | TupleTypeNode { syntax: self.syntax.borrowed() } | ||
3605 | } | ||
3606 | pub fn owned(&self) -> TupleTypeNode { | ||
3607 | TupleTypeNode { syntax: self.syntax.owned() } | ||
3608 | } | ||
3609 | } | ||
3429 | 3610 | ||
3430 | // TypeDef | ||
3431 | 3611 | ||
3432 | #[derive(Debug, Clone)] | 3612 | impl<'a> TupleType<'a> {} |
3433 | pub struct TypeDefNode(SyntaxNode); | ||
3434 | 3613 | ||
3435 | impl TypeDefNode { | 3614 | // TypeDef |
3436 | pub fn ast(&self) -> TypeDef { | 3615 | #[derive(Debug, Clone, Copy,)] |
3437 | TypeDef::cast(self.0.borrowed()).unwrap() | 3616 | pub struct TypeDefNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
3438 | } | 3617 | pub(crate) syntax: SyntaxNode<R>, |
3439 | } | 3618 | } |
3619 | pub type TypeDef<'a> = TypeDefNode<RefRoot<'a>>; | ||
3440 | 3620 | ||
3441 | impl<'a> From<TypeDef<'a>> for TypeDefNode { | 3621 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<TypeDefNode<R1>> for TypeDefNode<R2> { |
3442 | fn from(ast: TypeDef<'a>) -> TypeDefNode { | 3622 | fn eq(&self, other: &TypeDefNode<R1>) -> bool { self.syntax == other.syntax } |
3443 | let syntax = ast.syntax().owned(); | ||
3444 | TypeDefNode(syntax) | ||
3445 | } | ||
3446 | } | 3623 | } |
3447 | #[derive(Debug, Clone, Copy)] | 3624 | impl<R: TreeRoot<RaTypes>> Eq for TypeDefNode<R> {} |
3448 | pub struct TypeDef<'a> { | 3625 | impl<R: TreeRoot<RaTypes>> Hash for TypeDefNode<R> { |
3449 | syntax: SyntaxNodeRef<'a>, | 3626 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } |
3450 | } | 3627 | } |
3451 | 3628 | ||
3452 | impl<'a> AstNode<'a> for TypeDef<'a> { | 3629 | impl<'a> AstNode<'a> for TypeDef<'a> { |
@@ -3459,31 +3636,34 @@ impl<'a> AstNode<'a> for TypeDef<'a> { | |||
3459 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 3636 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
3460 | } | 3637 | } |
3461 | 3638 | ||
3639 | impl<R: TreeRoot<RaTypes>> TypeDefNode<R> { | ||
3640 | pub fn borrowed(&self) -> TypeDef { | ||
3641 | TypeDefNode { syntax: self.syntax.borrowed() } | ||
3642 | } | ||
3643 | pub fn owned(&self) -> TypeDefNode { | ||
3644 | TypeDefNode { syntax: self.syntax.owned() } | ||
3645 | } | ||
3646 | } | ||
3647 | |||
3648 | |||
3462 | impl<'a> ast::NameOwner<'a> for TypeDef<'a> {} | 3649 | impl<'a> ast::NameOwner<'a> for TypeDef<'a> {} |
3463 | impl<'a> ast::TypeParamsOwner<'a> for TypeDef<'a> {} | 3650 | impl<'a> ast::TypeParamsOwner<'a> for TypeDef<'a> {} |
3464 | impl<'a> ast::AttrsOwner<'a> for TypeDef<'a> {} | 3651 | impl<'a> ast::AttrsOwner<'a> for TypeDef<'a> {} |
3465 | impl<'a> TypeDef<'a> {} | 3652 | impl<'a> TypeDef<'a> {} |
3466 | 3653 | ||
3467 | // TypeParam | 3654 | // TypeParam |
3468 | 3655 | #[derive(Debug, Clone, Copy,)] | |
3469 | #[derive(Debug, Clone)] | 3656 | pub struct TypeParamNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
3470 | pub struct TypeParamNode(SyntaxNode); | 3657 | pub(crate) syntax: SyntaxNode<R>, |
3471 | |||
3472 | impl TypeParamNode { | ||
3473 | pub fn ast(&self) -> TypeParam { | ||
3474 | TypeParam::cast(self.0.borrowed()).unwrap() | ||
3475 | } | ||
3476 | } | 3658 | } |
3659 | pub type TypeParam<'a> = TypeParamNode<RefRoot<'a>>; | ||
3477 | 3660 | ||
3478 | impl<'a> From<TypeParam<'a>> for TypeParamNode { | 3661 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<TypeParamNode<R1>> for TypeParamNode<R2> { |
3479 | fn from(ast: TypeParam<'a>) -> TypeParamNode { | 3662 | fn eq(&self, other: &TypeParamNode<R1>) -> bool { self.syntax == other.syntax } |
3480 | let syntax = ast.syntax().owned(); | ||
3481 | TypeParamNode(syntax) | ||
3482 | } | ||
3483 | } | 3663 | } |
3484 | #[derive(Debug, Clone, Copy)] | 3664 | impl<R: TreeRoot<RaTypes>> Eq for TypeParamNode<R> {} |
3485 | pub struct TypeParam<'a> { | 3665 | impl<R: TreeRoot<RaTypes>> Hash for TypeParamNode<R> { |
3486 | syntax: SyntaxNodeRef<'a>, | 3666 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } |
3487 | } | 3667 | } |
3488 | 3668 | ||
3489 | impl<'a> AstNode<'a> for TypeParam<'a> { | 3669 | impl<'a> AstNode<'a> for TypeParam<'a> { |
@@ -3496,29 +3676,32 @@ impl<'a> AstNode<'a> for TypeParam<'a> { | |||
3496 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 3676 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
3497 | } | 3677 | } |
3498 | 3678 | ||
3679 | impl<R: TreeRoot<RaTypes>> TypeParamNode<R> { | ||
3680 | pub fn borrowed(&self) -> TypeParam { | ||
3681 | TypeParamNode { syntax: self.syntax.borrowed() } | ||
3682 | } | ||
3683 | pub fn owned(&self) -> TypeParamNode { | ||
3684 | TypeParamNode { syntax: self.syntax.owned() } | ||
3685 | } | ||
3686 | } | ||
3687 | |||
3688 | |||
3499 | impl<'a> ast::NameOwner<'a> for TypeParam<'a> {} | 3689 | impl<'a> ast::NameOwner<'a> for TypeParam<'a> {} |
3500 | impl<'a> TypeParam<'a> {} | 3690 | impl<'a> TypeParam<'a> {} |
3501 | 3691 | ||
3502 | // TypeParamList | 3692 | // TypeParamList |
3503 | 3693 | #[derive(Debug, Clone, Copy,)] | |
3504 | #[derive(Debug, Clone)] | 3694 | pub struct TypeParamListNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
3505 | pub struct TypeParamListNode(SyntaxNode); | 3695 | pub(crate) syntax: SyntaxNode<R>, |
3506 | |||
3507 | impl TypeParamListNode { | ||
3508 | pub fn ast(&self) -> TypeParamList { | ||
3509 | TypeParamList::cast(self.0.borrowed()).unwrap() | ||
3510 | } | ||
3511 | } | 3696 | } |
3697 | pub type TypeParamList<'a> = TypeParamListNode<RefRoot<'a>>; | ||
3512 | 3698 | ||
3513 | impl<'a> From<TypeParamList<'a>> for TypeParamListNode { | 3699 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<TypeParamListNode<R1>> for TypeParamListNode<R2> { |
3514 | fn from(ast: TypeParamList<'a>) -> TypeParamListNode { | 3700 | fn eq(&self, other: &TypeParamListNode<R1>) -> bool { self.syntax == other.syntax } |
3515 | let syntax = ast.syntax().owned(); | ||
3516 | TypeParamListNode(syntax) | ||
3517 | } | ||
3518 | } | 3701 | } |
3519 | #[derive(Debug, Clone, Copy)] | 3702 | impl<R: TreeRoot<RaTypes>> Eq for TypeParamListNode<R> {} |
3520 | pub struct TypeParamList<'a> { | 3703 | impl<R: TreeRoot<RaTypes>> Hash for TypeParamListNode<R> { |
3521 | syntax: SyntaxNodeRef<'a>, | 3704 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } |
3522 | } | 3705 | } |
3523 | 3706 | ||
3524 | impl<'a> AstNode<'a> for TypeParamList<'a> { | 3707 | impl<'a> AstNode<'a> for TypeParamList<'a> { |
@@ -3531,6 +3714,16 @@ impl<'a> AstNode<'a> for TypeParamList<'a> { | |||
3531 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 3714 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
3532 | } | 3715 | } |
3533 | 3716 | ||
3717 | impl<R: TreeRoot<RaTypes>> TypeParamListNode<R> { | ||
3718 | pub fn borrowed(&self) -> TypeParamList { | ||
3719 | TypeParamListNode { syntax: self.syntax.borrowed() } | ||
3720 | } | ||
3721 | pub fn owned(&self) -> TypeParamListNode { | ||
3722 | TypeParamListNode { syntax: self.syntax.owned() } | ||
3723 | } | ||
3724 | } | ||
3725 | |||
3726 | |||
3534 | impl<'a> TypeParamList<'a> { | 3727 | impl<'a> TypeParamList<'a> { |
3535 | pub fn type_params(self) -> impl Iterator<Item = TypeParam<'a>> + 'a { | 3728 | pub fn type_params(self) -> impl Iterator<Item = TypeParam<'a>> + 'a { |
3536 | super::children(self) | 3729 | super::children(self) |
@@ -3542,23 +3735,7 @@ impl<'a> TypeParamList<'a> { | |||
3542 | } | 3735 | } |
3543 | 3736 | ||
3544 | // TypeRef | 3737 | // TypeRef |
3545 | 3738 | #[derive(Debug, Clone, Copy, PartialEq, Eq)] | |
3546 | #[derive(Debug, Clone)] | ||
3547 | pub struct TypeRefNode(SyntaxNode); | ||
3548 | |||
3549 | impl TypeRefNode { | ||
3550 | pub fn ast(&self) -> TypeRef { | ||
3551 | TypeRef::cast(self.0.borrowed()).unwrap() | ||
3552 | } | ||
3553 | } | ||
3554 | |||
3555 | impl<'a> From<TypeRef<'a>> for TypeRefNode { | ||
3556 | fn from(ast: TypeRef<'a>) -> TypeRefNode { | ||
3557 | let syntax = ast.syntax().owned(); | ||
3558 | TypeRefNode(syntax) | ||
3559 | } | ||
3560 | } | ||
3561 | #[derive(Debug, Clone, Copy)] | ||
3562 | pub enum TypeRef<'a> { | 3739 | pub enum TypeRef<'a> { |
3563 | ParenType(ParenType<'a>), | 3740 | ParenType(ParenType<'a>), |
3564 | TupleType(TupleType<'a>), | 3741 | TupleType(TupleType<'a>), |
@@ -3616,25 +3793,18 @@ impl<'a> AstNode<'a> for TypeRef<'a> { | |||
3616 | impl<'a> TypeRef<'a> {} | 3793 | impl<'a> TypeRef<'a> {} |
3617 | 3794 | ||
3618 | // UseItem | 3795 | // UseItem |
3619 | 3796 | #[derive(Debug, Clone, Copy,)] | |
3620 | #[derive(Debug, Clone)] | 3797 | pub struct UseItemNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
3621 | pub struct UseItemNode(SyntaxNode); | 3798 | pub(crate) syntax: SyntaxNode<R>, |
3622 | |||
3623 | impl UseItemNode { | ||
3624 | pub fn ast(&self) -> UseItem { | ||
3625 | UseItem::cast(self.0.borrowed()).unwrap() | ||
3626 | } | ||
3627 | } | 3799 | } |
3800 | pub type UseItem<'a> = UseItemNode<RefRoot<'a>>; | ||
3628 | 3801 | ||
3629 | impl<'a> From<UseItem<'a>> for UseItemNode { | 3802 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<UseItemNode<R1>> for UseItemNode<R2> { |
3630 | fn from(ast: UseItem<'a>) -> UseItemNode { | 3803 | fn eq(&self, other: &UseItemNode<R1>) -> bool { self.syntax == other.syntax } |
3631 | let syntax = ast.syntax().owned(); | ||
3632 | UseItemNode(syntax) | ||
3633 | } | ||
3634 | } | 3804 | } |
3635 | #[derive(Debug, Clone, Copy)] | 3805 | impl<R: TreeRoot<RaTypes>> Eq for UseItemNode<R> {} |
3636 | pub struct UseItem<'a> { | 3806 | impl<R: TreeRoot<RaTypes>> Hash for UseItemNode<R> { |
3637 | syntax: SyntaxNodeRef<'a>, | 3807 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } |
3638 | } | 3808 | } |
3639 | 3809 | ||
3640 | impl<'a> AstNode<'a> for UseItem<'a> { | 3810 | impl<'a> AstNode<'a> for UseItem<'a> { |
@@ -3647,6 +3817,16 @@ impl<'a> AstNode<'a> for UseItem<'a> { | |||
3647 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 3817 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
3648 | } | 3818 | } |
3649 | 3819 | ||
3820 | impl<R: TreeRoot<RaTypes>> UseItemNode<R> { | ||
3821 | pub fn borrowed(&self) -> UseItem { | ||
3822 | UseItemNode { syntax: self.syntax.borrowed() } | ||
3823 | } | ||
3824 | pub fn owned(&self) -> UseItemNode { | ||
3825 | UseItemNode { syntax: self.syntax.owned() } | ||
3826 | } | ||
3827 | } | ||
3828 | |||
3829 | |||
3650 | impl<'a> UseItem<'a> { | 3830 | impl<'a> UseItem<'a> { |
3651 | pub fn use_tree(self) -> Option<UseTree<'a>> { | 3831 | pub fn use_tree(self) -> Option<UseTree<'a>> { |
3652 | super::child_opt(self) | 3832 | super::child_opt(self) |
@@ -3654,25 +3834,18 @@ impl<'a> UseItem<'a> { | |||
3654 | } | 3834 | } |
3655 | 3835 | ||
3656 | // UseTree | 3836 | // UseTree |
3657 | 3837 | #[derive(Debug, Clone, Copy,)] | |
3658 | #[derive(Debug, Clone)] | 3838 | pub struct UseTreeNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
3659 | pub struct UseTreeNode(SyntaxNode); | 3839 | pub(crate) syntax: SyntaxNode<R>, |
3660 | |||
3661 | impl UseTreeNode { | ||
3662 | pub fn ast(&self) -> UseTree { | ||
3663 | UseTree::cast(self.0.borrowed()).unwrap() | ||
3664 | } | ||
3665 | } | 3840 | } |
3841 | pub type UseTree<'a> = UseTreeNode<RefRoot<'a>>; | ||
3666 | 3842 | ||
3667 | impl<'a> From<UseTree<'a>> for UseTreeNode { | 3843 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<UseTreeNode<R1>> for UseTreeNode<R2> { |
3668 | fn from(ast: UseTree<'a>) -> UseTreeNode { | 3844 | fn eq(&self, other: &UseTreeNode<R1>) -> bool { self.syntax == other.syntax } |
3669 | let syntax = ast.syntax().owned(); | ||
3670 | UseTreeNode(syntax) | ||
3671 | } | ||
3672 | } | 3845 | } |
3673 | #[derive(Debug, Clone, Copy)] | 3846 | impl<R: TreeRoot<RaTypes>> Eq for UseTreeNode<R> {} |
3674 | pub struct UseTree<'a> { | 3847 | impl<R: TreeRoot<RaTypes>> Hash for UseTreeNode<R> { |
3675 | syntax: SyntaxNodeRef<'a>, | 3848 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } |
3676 | } | 3849 | } |
3677 | 3850 | ||
3678 | impl<'a> AstNode<'a> for UseTree<'a> { | 3851 | impl<'a> AstNode<'a> for UseTree<'a> { |
@@ -3685,6 +3858,16 @@ impl<'a> AstNode<'a> for UseTree<'a> { | |||
3685 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 3858 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
3686 | } | 3859 | } |
3687 | 3860 | ||
3861 | impl<R: TreeRoot<RaTypes>> UseTreeNode<R> { | ||
3862 | pub fn borrowed(&self) -> UseTree { | ||
3863 | UseTreeNode { syntax: self.syntax.borrowed() } | ||
3864 | } | ||
3865 | pub fn owned(&self) -> UseTreeNode { | ||
3866 | UseTreeNode { syntax: self.syntax.owned() } | ||
3867 | } | ||
3868 | } | ||
3869 | |||
3870 | |||
3688 | impl<'a> UseTree<'a> { | 3871 | impl<'a> UseTree<'a> { |
3689 | pub fn path(self) -> Option<Path<'a>> { | 3872 | pub fn path(self) -> Option<Path<'a>> { |
3690 | super::child_opt(self) | 3873 | super::child_opt(self) |
@@ -3696,25 +3879,18 @@ impl<'a> UseTree<'a> { | |||
3696 | } | 3879 | } |
3697 | 3880 | ||
3698 | // UseTreeList | 3881 | // UseTreeList |
3699 | 3882 | #[derive(Debug, Clone, Copy,)] | |
3700 | #[derive(Debug, Clone)] | 3883 | pub struct UseTreeListNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
3701 | pub struct UseTreeListNode(SyntaxNode); | 3884 | pub(crate) syntax: SyntaxNode<R>, |
3702 | |||
3703 | impl UseTreeListNode { | ||
3704 | pub fn ast(&self) -> UseTreeList { | ||
3705 | UseTreeList::cast(self.0.borrowed()).unwrap() | ||
3706 | } | ||
3707 | } | 3885 | } |
3886 | pub type UseTreeList<'a> = UseTreeListNode<RefRoot<'a>>; | ||
3708 | 3887 | ||
3709 | impl<'a> From<UseTreeList<'a>> for UseTreeListNode { | 3888 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<UseTreeListNode<R1>> for UseTreeListNode<R2> { |
3710 | fn from(ast: UseTreeList<'a>) -> UseTreeListNode { | 3889 | fn eq(&self, other: &UseTreeListNode<R1>) -> bool { self.syntax == other.syntax } |
3711 | let syntax = ast.syntax().owned(); | ||
3712 | UseTreeListNode(syntax) | ||
3713 | } | ||
3714 | } | 3890 | } |
3715 | #[derive(Debug, Clone, Copy)] | 3891 | impl<R: TreeRoot<RaTypes>> Eq for UseTreeListNode<R> {} |
3716 | pub struct UseTreeList<'a> { | 3892 | impl<R: TreeRoot<RaTypes>> Hash for UseTreeListNode<R> { |
3717 | syntax: SyntaxNodeRef<'a>, | 3893 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } |
3718 | } | 3894 | } |
3719 | 3895 | ||
3720 | impl<'a> AstNode<'a> for UseTreeList<'a> { | 3896 | impl<'a> AstNode<'a> for UseTreeList<'a> { |
@@ -3727,6 +3903,16 @@ impl<'a> AstNode<'a> for UseTreeList<'a> { | |||
3727 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 3903 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
3728 | } | 3904 | } |
3729 | 3905 | ||
3906 | impl<R: TreeRoot<RaTypes>> UseTreeListNode<R> { | ||
3907 | pub fn borrowed(&self) -> UseTreeList { | ||
3908 | UseTreeListNode { syntax: self.syntax.borrowed() } | ||
3909 | } | ||
3910 | pub fn owned(&self) -> UseTreeListNode { | ||
3911 | UseTreeListNode { syntax: self.syntax.owned() } | ||
3912 | } | ||
3913 | } | ||
3914 | |||
3915 | |||
3730 | impl<'a> UseTreeList<'a> { | 3916 | impl<'a> UseTreeList<'a> { |
3731 | pub fn use_trees(self) -> impl Iterator<Item = UseTree<'a>> + 'a { | 3917 | pub fn use_trees(self) -> impl Iterator<Item = UseTree<'a>> + 'a { |
3732 | super::children(self) | 3918 | super::children(self) |
@@ -3734,25 +3920,18 @@ impl<'a> UseTreeList<'a> { | |||
3734 | } | 3920 | } |
3735 | 3921 | ||
3736 | // WhereClause | 3922 | // WhereClause |
3737 | 3923 | #[derive(Debug, Clone, Copy,)] | |
3738 | #[derive(Debug, Clone)] | 3924 | pub struct WhereClauseNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
3739 | pub struct WhereClauseNode(SyntaxNode); | 3925 | pub(crate) syntax: SyntaxNode<R>, |
3740 | |||
3741 | impl WhereClauseNode { | ||
3742 | pub fn ast(&self) -> WhereClause { | ||
3743 | WhereClause::cast(self.0.borrowed()).unwrap() | ||
3744 | } | ||
3745 | } | 3926 | } |
3927 | pub type WhereClause<'a> = WhereClauseNode<RefRoot<'a>>; | ||
3746 | 3928 | ||
3747 | impl<'a> From<WhereClause<'a>> for WhereClauseNode { | 3929 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<WhereClauseNode<R1>> for WhereClauseNode<R2> { |
3748 | fn from(ast: WhereClause<'a>) -> WhereClauseNode { | 3930 | fn eq(&self, other: &WhereClauseNode<R1>) -> bool { self.syntax == other.syntax } |
3749 | let syntax = ast.syntax().owned(); | ||
3750 | WhereClauseNode(syntax) | ||
3751 | } | ||
3752 | } | 3931 | } |
3753 | #[derive(Debug, Clone, Copy)] | 3932 | impl<R: TreeRoot<RaTypes>> Eq for WhereClauseNode<R> {} |
3754 | pub struct WhereClause<'a> { | 3933 | impl<R: TreeRoot<RaTypes>> Hash for WhereClauseNode<R> { |
3755 | syntax: SyntaxNodeRef<'a>, | 3934 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } |
3756 | } | 3935 | } |
3757 | 3936 | ||
3758 | impl<'a> AstNode<'a> for WhereClause<'a> { | 3937 | impl<'a> AstNode<'a> for WhereClause<'a> { |
@@ -3765,28 +3944,31 @@ impl<'a> AstNode<'a> for WhereClause<'a> { | |||
3765 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 3944 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
3766 | } | 3945 | } |
3767 | 3946 | ||
3768 | impl<'a> WhereClause<'a> {} | 3947 | impl<R: TreeRoot<RaTypes>> WhereClauseNode<R> { |
3948 | pub fn borrowed(&self) -> WhereClause { | ||
3949 | WhereClauseNode { syntax: self.syntax.borrowed() } | ||
3950 | } | ||
3951 | pub fn owned(&self) -> WhereClauseNode { | ||
3952 | WhereClauseNode { syntax: self.syntax.owned() } | ||
3953 | } | ||
3954 | } | ||
3769 | 3955 | ||
3770 | // WhileExpr | ||
3771 | 3956 | ||
3772 | #[derive(Debug, Clone)] | 3957 | impl<'a> WhereClause<'a> {} |
3773 | pub struct WhileExprNode(SyntaxNode); | ||
3774 | 3958 | ||
3775 | impl WhileExprNode { | 3959 | // WhileExpr |
3776 | pub fn ast(&self) -> WhileExpr { | 3960 | #[derive(Debug, Clone, Copy,)] |
3777 | WhileExpr::cast(self.0.borrowed()).unwrap() | 3961 | pub struct WhileExprNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
3778 | } | 3962 | pub(crate) syntax: SyntaxNode<R>, |
3779 | } | 3963 | } |
3964 | pub type WhileExpr<'a> = WhileExprNode<RefRoot<'a>>; | ||
3780 | 3965 | ||
3781 | impl<'a> From<WhileExpr<'a>> for WhileExprNode { | 3966 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<WhileExprNode<R1>> for WhileExprNode<R2> { |
3782 | fn from(ast: WhileExpr<'a>) -> WhileExprNode { | 3967 | fn eq(&self, other: &WhileExprNode<R1>) -> bool { self.syntax == other.syntax } |
3783 | let syntax = ast.syntax().owned(); | ||
3784 | WhileExprNode(syntax) | ||
3785 | } | ||
3786 | } | 3968 | } |
3787 | #[derive(Debug, Clone, Copy)] | 3969 | impl<R: TreeRoot<RaTypes>> Eq for WhileExprNode<R> {} |
3788 | pub struct WhileExpr<'a> { | 3970 | impl<R: TreeRoot<RaTypes>> Hash for WhileExprNode<R> { |
3789 | syntax: SyntaxNodeRef<'a>, | 3971 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } |
3790 | } | 3972 | } |
3791 | 3973 | ||
3792 | impl<'a> AstNode<'a> for WhileExpr<'a> { | 3974 | impl<'a> AstNode<'a> for WhileExpr<'a> { |
@@ -3799,6 +3981,16 @@ impl<'a> AstNode<'a> for WhileExpr<'a> { | |||
3799 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 3981 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
3800 | } | 3982 | } |
3801 | 3983 | ||
3984 | impl<R: TreeRoot<RaTypes>> WhileExprNode<R> { | ||
3985 | pub fn borrowed(&self) -> WhileExpr { | ||
3986 | WhileExprNode { syntax: self.syntax.borrowed() } | ||
3987 | } | ||
3988 | pub fn owned(&self) -> WhileExprNode { | ||
3989 | WhileExprNode { syntax: self.syntax.owned() } | ||
3990 | } | ||
3991 | } | ||
3992 | |||
3993 | |||
3802 | impl<'a> ast::LoopBodyOwner<'a> for WhileExpr<'a> {} | 3994 | impl<'a> ast::LoopBodyOwner<'a> for WhileExpr<'a> {} |
3803 | impl<'a> WhileExpr<'a> { | 3995 | impl<'a> WhileExpr<'a> { |
3804 | pub fn condition(self) -> Option<Condition<'a>> { | 3996 | pub fn condition(self) -> Option<Condition<'a>> { |
@@ -3807,25 +3999,18 @@ impl<'a> WhileExpr<'a> { | |||
3807 | } | 3999 | } |
3808 | 4000 | ||
3809 | // Whitespace | 4001 | // Whitespace |
3810 | 4002 | #[derive(Debug, Clone, Copy,)] | |
3811 | #[derive(Debug, Clone)] | 4003 | pub struct WhitespaceNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
3812 | pub struct WhitespaceNode(SyntaxNode); | 4004 | pub(crate) syntax: SyntaxNode<R>, |
3813 | |||
3814 | impl WhitespaceNode { | ||
3815 | pub fn ast(&self) -> Whitespace { | ||
3816 | Whitespace::cast(self.0.borrowed()).unwrap() | ||
3817 | } | ||
3818 | } | 4005 | } |
4006 | pub type Whitespace<'a> = WhitespaceNode<RefRoot<'a>>; | ||
3819 | 4007 | ||
3820 | impl<'a> From<Whitespace<'a>> for WhitespaceNode { | 4008 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<WhitespaceNode<R1>> for WhitespaceNode<R2> { |
3821 | fn from(ast: Whitespace<'a>) -> WhitespaceNode { | 4009 | fn eq(&self, other: &WhitespaceNode<R1>) -> bool { self.syntax == other.syntax } |
3822 | let syntax = ast.syntax().owned(); | ||
3823 | WhitespaceNode(syntax) | ||
3824 | } | ||
3825 | } | 4010 | } |
3826 | #[derive(Debug, Clone, Copy)] | 4011 | impl<R: TreeRoot<RaTypes>> Eq for WhitespaceNode<R> {} |
3827 | pub struct Whitespace<'a> { | 4012 | impl<R: TreeRoot<RaTypes>> Hash for WhitespaceNode<R> { |
3828 | syntax: SyntaxNodeRef<'a>, | 4013 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } |
3829 | } | 4014 | } |
3830 | 4015 | ||
3831 | impl<'a> AstNode<'a> for Whitespace<'a> { | 4016 | impl<'a> AstNode<'a> for Whitespace<'a> { |
@@ -3838,5 +4023,15 @@ impl<'a> AstNode<'a> for Whitespace<'a> { | |||
3838 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 4023 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
3839 | } | 4024 | } |
3840 | 4025 | ||
4026 | impl<R: TreeRoot<RaTypes>> WhitespaceNode<R> { | ||
4027 | pub fn borrowed(&self) -> Whitespace { | ||
4028 | WhitespaceNode { syntax: self.syntax.borrowed() } | ||
4029 | } | ||
4030 | pub fn owned(&self) -> WhitespaceNode { | ||
4031 | WhitespaceNode { syntax: self.syntax.owned() } | ||
4032 | } | ||
4033 | } | ||
4034 | |||
4035 | |||
3841 | impl<'a> Whitespace<'a> {} | 4036 | impl<'a> Whitespace<'a> {} |
3842 | 4037 | ||
diff --git a/crates/ra_syntax/src/ast/generated.rs.tera b/crates/ra_syntax/src/ast/generated.rs.tera index 1321f0def..131ee09ec 100644 --- a/crates/ra_syntax/src/ast/generated.rs.tera +++ b/crates/ra_syntax/src/ast/generated.rs.tera | |||
@@ -3,34 +3,27 @@ the below applies to the result of this template | |||
3 | #}// This file is automatically generated based on the file `./generated.rs.tera` when `cargo gen-syntax` is run | 3 | #}// This file is automatically generated based on the file `./generated.rs.tera` when `cargo gen-syntax` is run |
4 | // Do not edit manually | 4 | // Do not edit manually |
5 | 5 | ||
6 | //! This module contains auto-generated Rust AST. Like `SyntaxNode`s, AST nodes | ||
7 | //! are generic over ownership: `X<'a>` things are `Copy` references, `XNode` | ||
8 | //! are Arc-based. You can switch between the two variants using `.owned` and | ||
9 | //! `.borrowed` functions. Most of the code works with borowed mode, and only | ||
10 | //! this mode has all AST accessors. | ||
11 | |||
6 | #![cfg_attr(rustfmt, rustfmt_skip)] | 12 | #![cfg_attr(rustfmt, rustfmt_skip)] |
7 | 13 | ||
14 | use std::hash::{Hash, Hasher}; | ||
15 | |||
8 | use crate::{ | 16 | use crate::{ |
9 | ast, | 17 | ast, |
10 | SyntaxNode, SyntaxNodeRef, AstNode, | 18 | SyntaxNode, SyntaxNodeRef, AstNode, |
19 | yellow::{TreeRoot, RaTypes, OwnedRoot, RefRoot}, | ||
11 | SyntaxKind::*, | 20 | SyntaxKind::*, |
12 | }; | 21 | }; |
13 | {% for node, methods in ast %} | 22 | {% for node, methods in ast %} |
14 | // {{ node }} | 23 | // {{ node }} |
15 | 24 | ||
16 | #[derive(Debug, Clone)] | ||
17 | pub struct {{ node }}Node(SyntaxNode); | ||
18 | |||
19 | impl {{ node }}Node { | ||
20 | pub fn ast(&self) -> {{ node }} { | ||
21 | {{ node }}::cast(self.0.borrowed()).unwrap() | ||
22 | } | ||
23 | } | ||
24 | |||
25 | impl<'a> From<{{ node }}<'a>> for {{ node }}Node { | ||
26 | fn from(ast: {{ node}}<'a>) -> {{ node }}Node { | ||
27 | let syntax = ast.syntax().owned(); | ||
28 | {{ node }}Node(syntax) | ||
29 | } | ||
30 | } | ||
31 | |||
32 | {%- if methods.enum %} | 25 | {%- if methods.enum %} |
33 | #[derive(Debug, Clone, Copy)] | 26 | #[derive(Debug, Clone, Copy, PartialEq, Eq)] |
34 | pub enum {{ node }}<'a> { | 27 | pub enum {{ node }}<'a> { |
35 | {%- for kind in methods.enum %} | 28 | {%- for kind in methods.enum %} |
36 | {{ kind }}({{ kind }}<'a>), | 29 | {{ kind }}({{ kind }}<'a>), |
@@ -55,9 +48,18 @@ impl<'a> AstNode<'a> for {{ node }}<'a> { | |||
55 | } | 48 | } |
56 | } | 49 | } |
57 | {% else %} | 50 | {% else %} |
58 | #[derive(Debug, Clone, Copy)] | 51 | #[derive(Debug, Clone, Copy,)] |
59 | pub struct {{ node }}<'a> { | 52 | pub struct {{ node }}Node<R: TreeRoot<RaTypes> = OwnedRoot> { |
60 | syntax: SyntaxNodeRef<'a>, | 53 | pub(crate) syntax: SyntaxNode<R>, |
54 | } | ||
55 | pub type {{ node }}<'a> = {{ node }}Node<RefRoot<'a>>; | ||
56 | |||
57 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<{{node}}Node<R1>> for {{node}}Node<R2> { | ||
58 | fn eq(&self, other: &{{node}}Node<R1>) -> bool { self.syntax == other.syntax } | ||
59 | } | ||
60 | impl<R: TreeRoot<RaTypes>> Eq for {{node}}Node<R> {} | ||
61 | impl<R: TreeRoot<RaTypes>> Hash for {{node}}Node<R> { | ||
62 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } | ||
61 | } | 63 | } |
62 | 64 | ||
63 | impl<'a> AstNode<'a> for {{ node }}<'a> { | 65 | impl<'a> AstNode<'a> for {{ node }}<'a> { |
@@ -69,6 +71,16 @@ impl<'a> AstNode<'a> for {{ node }}<'a> { | |||
69 | } | 71 | } |
70 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 72 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
71 | } | 73 | } |
74 | |||
75 | impl<R: TreeRoot<RaTypes>> {{ node }}Node<R> { | ||
76 | pub fn borrowed(&self) -> {{ node }} { | ||
77 | {{ node }}Node { syntax: self.syntax.borrowed() } | ||
78 | } | ||
79 | pub fn owned(&self) -> {{ node }}Node { | ||
80 | {{ node }}Node { syntax: self.syntax.owned() } | ||
81 | } | ||
82 | } | ||
83 | |||
72 | {% endif %} | 84 | {% endif %} |
73 | {% if methods.traits -%} | 85 | {% if methods.traits -%} |
74 | {%- for t in methods.traits -%} | 86 | {%- for t in methods.traits -%} |
diff --git a/crates/ra_syntax/src/ast/mod.rs b/crates/ra_syntax/src/ast/mod.rs index 4355531d0..d93f92672 100644 --- a/crates/ra_syntax/src/ast/mod.rs +++ b/crates/ra_syntax/src/ast/mod.rs | |||
@@ -12,6 +12,10 @@ use crate::{ | |||
12 | SyntaxNodeRef, | 12 | SyntaxNodeRef, |
13 | }; | 13 | }; |
14 | 14 | ||
15 | /// The main trait to go from untyped `SyntaxNode` to a typed ast. The | ||
16 | /// conversion itself has zero runtime cost: ast and syntax nodes have exactly | ||
17 | /// the same representation: a pointer to the tree root and a pointer to the | ||
18 | /// node itself. | ||
15 | pub trait AstNode<'a>: Clone + Copy + 'a { | 19 | pub trait AstNode<'a>: Clone + Copy + 'a { |
16 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> | 20 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> |
17 | where | 21 | where |
diff --git a/crates/ra_syntax/src/grammar/type_params.rs b/crates/ra_syntax/src/grammar/type_params.rs index 68eca0ce8..f4c98675c 100644 --- a/crates/ra_syntax/src/grammar/type_params.rs +++ b/crates/ra_syntax/src/grammar/type_params.rs | |||
@@ -135,7 +135,11 @@ fn where_predicate(p: &mut Parser) { | |||
135 | if p.at(FOR_KW) { | 135 | if p.at(FOR_KW) { |
136 | types::for_binder(p); | 136 | types::for_binder(p); |
137 | } | 137 | } |
138 | types::path_type(p); | 138 | if paths::is_path_start(p) || p.at(L_ANGLE) { |
139 | types::path_type_(p, false); | ||
140 | } else { | ||
141 | p.error("expected a type"); | ||
142 | } | ||
139 | if p.at(COLON) { | 143 | if p.at(COLON) { |
140 | bounds(p); | 144 | bounds(p); |
141 | } else { | 145 | } else { |
diff --git a/crates/ra_syntax/src/lib.rs b/crates/ra_syntax/src/lib.rs index 319fb947d..54012b7b6 100644 --- a/crates/ra_syntax/src/lib.rs +++ b/crates/ra_syntax/src/lib.rs | |||
@@ -61,11 +61,9 @@ pub use crate::{ | |||
61 | 61 | ||
62 | use crate::yellow::GreenNode; | 62 | use crate::yellow::GreenNode; |
63 | 63 | ||
64 | // TODO: pick a single name for everything. SourceFile maybe? | ||
64 | /// File represents a parse tree for a single Rust file. | 65 | /// File represents a parse tree for a single Rust file. |
65 | #[derive(Clone, Debug, Hash, PartialEq, Eq)] | 66 | pub type File = ast::RootNode; |
66 | pub struct File { | ||
67 | root: SyntaxNode, | ||
68 | } | ||
69 | 67 | ||
70 | impl File { | 68 | impl File { |
71 | fn new(green: GreenNode, errors: Vec<SyntaxError>) -> File { | 69 | fn new(green: GreenNode, errors: Vec<SyntaxError>) -> File { |
@@ -73,7 +71,8 @@ impl File { | |||
73 | if cfg!(debug_assertions) { | 71 | if cfg!(debug_assertions) { |
74 | utils::validate_block_structure(root.borrowed()); | 72 | utils::validate_block_structure(root.borrowed()); |
75 | } | 73 | } |
76 | File { root } | 74 | assert_eq!(root.kind(), SyntaxKind::ROOT); |
75 | ast::RootNode { syntax: root } | ||
77 | } | 76 | } |
78 | pub fn parse(text: &str) -> File { | 77 | pub fn parse(text: &str) -> File { |
79 | let tokens = tokenize(&text); | 78 | let tokens = tokenize(&text); |
@@ -96,14 +95,14 @@ impl File { | |||
96 | } | 95 | } |
97 | /// Typed AST representation of the parse tree. | 96 | /// Typed AST representation of the parse tree. |
98 | pub fn ast(&self) -> ast::Root { | 97 | pub fn ast(&self) -> ast::Root { |
99 | ast::Root::cast(self.syntax()).unwrap() | 98 | self.borrowed() |
100 | } | 99 | } |
101 | /// Untyped homogeneous representation of the parse tree. | 100 | /// Untyped homogeneous representation of the parse tree. |
102 | pub fn syntax(&self) -> SyntaxNodeRef { | 101 | pub fn syntax(&self) -> SyntaxNodeRef { |
103 | self.root.borrowed() | 102 | self.syntax.borrowed() |
104 | } | 103 | } |
105 | pub fn errors(&self) -> Vec<SyntaxError> { | 104 | pub fn errors(&self) -> Vec<SyntaxError> { |
106 | let mut errors = self.root.root_data().clone(); | 105 | let mut errors = self.syntax.root_data().clone(); |
107 | errors.extend(validation::validate(self)); | 106 | errors.extend(validation::validate(self)); |
108 | errors | 107 | errors |
109 | } | 108 | } |
diff --git a/crates/ra_syntax/src/validation.rs b/crates/ra_syntax/src/validation.rs index 9cb9ccc41..f345dbd6e 100644 --- a/crates/ra_syntax/src/validation.rs +++ b/crates/ra_syntax/src/validation.rs | |||
@@ -15,7 +15,7 @@ use crate::{ | |||
15 | 15 | ||
16 | pub(crate) fn validate(file: &File) -> Vec<SyntaxError> { | 16 | pub(crate) fn validate(file: &File) -> Vec<SyntaxError> { |
17 | let mut errors = Vec::new(); | 17 | let mut errors = Vec::new(); |
18 | for node in file.root.borrowed().descendants() { | 18 | for node in file.syntax().descendants() { |
19 | let _ = visitor_ctx(&mut errors) | 19 | let _ = visitor_ctx(&mut errors) |
20 | .visit::<ast::Char, _>(validate_char) | 20 | .visit::<ast::Char, _>(validate_char) |
21 | .accept(node); | 21 | .accept(node); |
diff --git a/crates/ra_syntax/src/yellow/mod.rs b/crates/ra_syntax/src/yellow/mod.rs index 6da948648..cacd89dc8 100644 --- a/crates/ra_syntax/src/yellow/mod.rs +++ b/crates/ra_syntax/src/yellow/mod.rs | |||
@@ -27,7 +27,7 @@ pub type RefRoot<'a> = ::rowan::RefRoot<'a, RaTypes>; | |||
27 | pub type GreenNode = ::rowan::GreenNode<RaTypes>; | 27 | pub type GreenNode = ::rowan::GreenNode<RaTypes>; |
28 | 28 | ||
29 | #[derive(Clone, Copy)] | 29 | #[derive(Clone, Copy)] |
30 | pub struct SyntaxNode<R: TreeRoot<RaTypes> = OwnedRoot>(::rowan::SyntaxNode<RaTypes, R>); | 30 | pub struct SyntaxNode<R: TreeRoot<RaTypes> = OwnedRoot>(pub(crate) ::rowan::SyntaxNode<RaTypes, R>); |
31 | pub type SyntaxNodeRef<'a> = SyntaxNode<RefRoot<'a>>; | 31 | pub type SyntaxNodeRef<'a> = SyntaxNode<RefRoot<'a>>; |
32 | 32 | ||
33 | impl<R1, R2> PartialEq<SyntaxNode<R1>> for SyntaxNode<R2> | 33 | impl<R1, R2> PartialEq<SyntaxNode<R1>> for SyntaxNode<R2> |
diff --git a/crates/ra_syntax/tests/data/parser/err/0027_incomplere_where_for.rs b/crates/ra_syntax/tests/data/parser/err/0027_incomplere_where_for.rs new file mode 100644 index 000000000..2792c2084 --- /dev/null +++ b/crates/ra_syntax/tests/data/parser/err/0027_incomplere_where_for.rs | |||
@@ -0,0 +1,3 @@ | |||
1 | fn foo() | ||
2 | where for<'a> | ||
3 | {} | ||
diff --git a/crates/ra_syntax/tests/data/parser/err/0027_incomplere_where_for.txt b/crates/ra_syntax/tests/data/parser/err/0027_incomplere_where_for.txt new file mode 100644 index 000000000..94b75a656 --- /dev/null +++ b/crates/ra_syntax/tests/data/parser/err/0027_incomplere_where_for.txt | |||
@@ -0,0 +1,27 @@ | |||
1 | ROOT@[0; 30) | ||
2 | FN_DEF@[0; 29) | ||
3 | FN_KW@[0; 2) | ||
4 | WHITESPACE@[2; 3) | ||
5 | NAME@[3; 6) | ||
6 | IDENT@[3; 6) "foo" | ||
7 | PARAM_LIST@[6; 8) | ||
8 | L_PAREN@[6; 7) | ||
9 | R_PAREN@[7; 8) | ||
10 | WHITESPACE@[8; 13) | ||
11 | WHERE_CLAUSE@[13; 26) | ||
12 | WHERE_KW@[13; 18) | ||
13 | WHITESPACE@[18; 19) | ||
14 | WHERE_PRED@[19; 26) | ||
15 | FOR_KW@[19; 22) | ||
16 | TYPE_PARAM_LIST@[22; 26) | ||
17 | L_ANGLE@[22; 23) | ||
18 | LIFETIME_PARAM@[23; 25) | ||
19 | LIFETIME@[23; 25) "'a" | ||
20 | R_ANGLE@[25; 26) | ||
21 | err: `expected a type` | ||
22 | err: `expected colon` | ||
23 | WHITESPACE@[26; 27) | ||
24 | BLOCK@[27; 29) | ||
25 | L_CURLY@[27; 28) | ||
26 | R_CURLY@[28; 29) | ||
27 | WHITESPACE@[29; 30) | ||