diff options
Diffstat (limited to 'crates/libsyntax2/src/ast')
-rw-r--r-- | crates/libsyntax2/src/ast/generated.rs | 63 | ||||
-rw-r--r-- | crates/libsyntax2/src/ast/mod.rs | 8 |
2 files changed, 34 insertions, 37 deletions
diff --git a/crates/libsyntax2/src/ast/generated.rs b/crates/libsyntax2/src/ast/generated.rs index be3f73f7e..4fc405c8a 100644 --- a/crates/libsyntax2/src/ast/generated.rs +++ b/crates/libsyntax2/src/ast/generated.rs | |||
@@ -1,13 +1,12 @@ | |||
1 | use std::sync::Arc; | ||
2 | use { | 1 | use { |
3 | ast, | 2 | ast, |
4 | SyntaxNode, SyntaxRoot, TreeRoot, AstNode, | 3 | SyntaxNode, OwnedRoot, TreeRoot, AstNode, |
5 | SyntaxKind::*, | 4 | SyntaxKind::*, |
6 | }; | 5 | }; |
7 | 6 | ||
8 | // ArrayType | 7 | // ArrayType |
9 | #[derive(Debug, Clone, Copy)] | 8 | #[derive(Debug, Clone, Copy)] |
10 | pub struct ArrayType<R: TreeRoot = Arc<SyntaxRoot>> { | 9 | pub struct ArrayType<R: TreeRoot = OwnedRoot> { |
11 | syntax: SyntaxNode<R>, | 10 | syntax: SyntaxNode<R>, |
12 | } | 11 | } |
13 | 12 | ||
@@ -25,7 +24,7 @@ impl<R: TreeRoot> ArrayType<R> {} | |||
25 | 24 | ||
26 | // Attr | 25 | // Attr |
27 | #[derive(Debug, Clone, Copy)] | 26 | #[derive(Debug, Clone, Copy)] |
28 | pub struct Attr<R: TreeRoot = Arc<SyntaxRoot>> { | 27 | pub struct Attr<R: TreeRoot = OwnedRoot> { |
29 | syntax: SyntaxNode<R>, | 28 | syntax: SyntaxNode<R>, |
30 | } | 29 | } |
31 | 30 | ||
@@ -50,7 +49,7 @@ impl<R: TreeRoot> Attr<R> { | |||
50 | 49 | ||
51 | // ConstDef | 50 | // ConstDef |
52 | #[derive(Debug, Clone, Copy)] | 51 | #[derive(Debug, Clone, Copy)] |
53 | pub struct ConstDef<R: TreeRoot = Arc<SyntaxRoot>> { | 52 | pub struct ConstDef<R: TreeRoot = OwnedRoot> { |
54 | syntax: SyntaxNode<R>, | 53 | syntax: SyntaxNode<R>, |
55 | } | 54 | } |
56 | 55 | ||
@@ -70,7 +69,7 @@ impl<R: TreeRoot> ConstDef<R> {} | |||
70 | 69 | ||
71 | // DynTraitType | 70 | // DynTraitType |
72 | #[derive(Debug, Clone, Copy)] | 71 | #[derive(Debug, Clone, Copy)] |
73 | pub struct DynTraitType<R: TreeRoot = Arc<SyntaxRoot>> { | 72 | pub struct DynTraitType<R: TreeRoot = OwnedRoot> { |
74 | syntax: SyntaxNode<R>, | 73 | syntax: SyntaxNode<R>, |
75 | } | 74 | } |
76 | 75 | ||
@@ -88,7 +87,7 @@ impl<R: TreeRoot> DynTraitType<R> {} | |||
88 | 87 | ||
89 | // EnumDef | 88 | // EnumDef |
90 | #[derive(Debug, Clone, Copy)] | 89 | #[derive(Debug, Clone, Copy)] |
91 | pub struct EnumDef<R: TreeRoot = Arc<SyntaxRoot>> { | 90 | pub struct EnumDef<R: TreeRoot = OwnedRoot> { |
92 | syntax: SyntaxNode<R>, | 91 | syntax: SyntaxNode<R>, |
93 | } | 92 | } |
94 | 93 | ||
@@ -108,7 +107,7 @@ impl<R: TreeRoot> EnumDef<R> {} | |||
108 | 107 | ||
109 | // File | 108 | // File |
110 | #[derive(Debug, Clone, Copy)] | 109 | #[derive(Debug, Clone, Copy)] |
111 | pub struct File<R: TreeRoot = Arc<SyntaxRoot>> { | 110 | pub struct File<R: TreeRoot = OwnedRoot> { |
112 | syntax: SyntaxNode<R>, | 111 | syntax: SyntaxNode<R>, |
113 | } | 112 | } |
114 | 113 | ||
@@ -132,7 +131,7 @@ impl<R: TreeRoot> File<R> { | |||
132 | 131 | ||
133 | // FnDef | 132 | // FnDef |
134 | #[derive(Debug, Clone, Copy)] | 133 | #[derive(Debug, Clone, Copy)] |
135 | pub struct FnDef<R: TreeRoot = Arc<SyntaxRoot>> { | 134 | pub struct FnDef<R: TreeRoot = OwnedRoot> { |
136 | syntax: SyntaxNode<R>, | 135 | syntax: SyntaxNode<R>, |
137 | } | 136 | } |
138 | 137 | ||
@@ -152,7 +151,7 @@ impl<R: TreeRoot> FnDef<R> {} | |||
152 | 151 | ||
153 | // FnPointerType | 152 | // FnPointerType |
154 | #[derive(Debug, Clone, Copy)] | 153 | #[derive(Debug, Clone, Copy)] |
155 | pub struct FnPointerType<R: TreeRoot = Arc<SyntaxRoot>> { | 154 | pub struct FnPointerType<R: TreeRoot = OwnedRoot> { |
156 | syntax: SyntaxNode<R>, | 155 | syntax: SyntaxNode<R>, |
157 | } | 156 | } |
158 | 157 | ||
@@ -170,7 +169,7 @@ impl<R: TreeRoot> FnPointerType<R> {} | |||
170 | 169 | ||
171 | // ForType | 170 | // ForType |
172 | #[derive(Debug, Clone, Copy)] | 171 | #[derive(Debug, Clone, Copy)] |
173 | pub struct ForType<R: TreeRoot = Arc<SyntaxRoot>> { | 172 | pub struct ForType<R: TreeRoot = OwnedRoot> { |
174 | syntax: SyntaxNode<R>, | 173 | syntax: SyntaxNode<R>, |
175 | } | 174 | } |
176 | 175 | ||
@@ -188,7 +187,7 @@ impl<R: TreeRoot> ForType<R> {} | |||
188 | 187 | ||
189 | // ImplItem | 188 | // ImplItem |
190 | #[derive(Debug, Clone, Copy)] | 189 | #[derive(Debug, Clone, Copy)] |
191 | pub struct ImplItem<R: TreeRoot = Arc<SyntaxRoot>> { | 190 | pub struct ImplItem<R: TreeRoot = OwnedRoot> { |
192 | syntax: SyntaxNode<R>, | 191 | syntax: SyntaxNode<R>, |
193 | } | 192 | } |
194 | 193 | ||
@@ -206,7 +205,7 @@ impl<R: TreeRoot> ImplItem<R> {} | |||
206 | 205 | ||
207 | // ImplTraitType | 206 | // ImplTraitType |
208 | #[derive(Debug, Clone, Copy)] | 207 | #[derive(Debug, Clone, Copy)] |
209 | pub struct ImplTraitType<R: TreeRoot = Arc<SyntaxRoot>> { | 208 | pub struct ImplTraitType<R: TreeRoot = OwnedRoot> { |
210 | syntax: SyntaxNode<R>, | 209 | syntax: SyntaxNode<R>, |
211 | } | 210 | } |
212 | 211 | ||
@@ -224,7 +223,7 @@ impl<R: TreeRoot> ImplTraitType<R> {} | |||
224 | 223 | ||
225 | // Module | 224 | // Module |
226 | #[derive(Debug, Clone, Copy)] | 225 | #[derive(Debug, Clone, Copy)] |
227 | pub struct Module<R: TreeRoot = Arc<SyntaxRoot>> { | 226 | pub struct Module<R: TreeRoot = OwnedRoot> { |
228 | syntax: SyntaxNode<R>, | 227 | syntax: SyntaxNode<R>, |
229 | } | 228 | } |
230 | 229 | ||
@@ -244,7 +243,7 @@ impl<R: TreeRoot> Module<R> {} | |||
244 | 243 | ||
245 | // Name | 244 | // Name |
246 | #[derive(Debug, Clone, Copy)] | 245 | #[derive(Debug, Clone, Copy)] |
247 | pub struct Name<R: TreeRoot = Arc<SyntaxRoot>> { | 246 | pub struct Name<R: TreeRoot = OwnedRoot> { |
248 | syntax: SyntaxNode<R>, | 247 | syntax: SyntaxNode<R>, |
249 | } | 248 | } |
250 | 249 | ||
@@ -262,7 +261,7 @@ impl<R: TreeRoot> Name<R> {} | |||
262 | 261 | ||
263 | // NameRef | 262 | // NameRef |
264 | #[derive(Debug, Clone, Copy)] | 263 | #[derive(Debug, Clone, Copy)] |
265 | pub struct NameRef<R: TreeRoot = Arc<SyntaxRoot>> { | 264 | pub struct NameRef<R: TreeRoot = OwnedRoot> { |
266 | syntax: SyntaxNode<R>, | 265 | syntax: SyntaxNode<R>, |
267 | } | 266 | } |
268 | 267 | ||
@@ -280,7 +279,7 @@ impl<R: TreeRoot> NameRef<R> {} | |||
280 | 279 | ||
281 | // NamedField | 280 | // NamedField |
282 | #[derive(Debug, Clone, Copy)] | 281 | #[derive(Debug, Clone, Copy)] |
283 | pub struct NamedField<R: TreeRoot = Arc<SyntaxRoot>> { | 282 | pub struct NamedField<R: TreeRoot = OwnedRoot> { |
284 | syntax: SyntaxNode<R>, | 283 | syntax: SyntaxNode<R>, |
285 | } | 284 | } |
286 | 285 | ||
@@ -300,7 +299,7 @@ impl<R: TreeRoot> NamedField<R> {} | |||
300 | 299 | ||
301 | // NeverType | 300 | // NeverType |
302 | #[derive(Debug, Clone, Copy)] | 301 | #[derive(Debug, Clone, Copy)] |
303 | pub struct NeverType<R: TreeRoot = Arc<SyntaxRoot>> { | 302 | pub struct NeverType<R: TreeRoot = OwnedRoot> { |
304 | syntax: SyntaxNode<R>, | 303 | syntax: SyntaxNode<R>, |
305 | } | 304 | } |
306 | 305 | ||
@@ -318,7 +317,7 @@ impl<R: TreeRoot> NeverType<R> {} | |||
318 | 317 | ||
319 | // NominalDef | 318 | // NominalDef |
320 | #[derive(Debug, Clone, Copy)] | 319 | #[derive(Debug, Clone, Copy)] |
321 | pub enum NominalDef<R: TreeRoot = Arc<SyntaxRoot>> { | 320 | pub enum NominalDef<R: TreeRoot = OwnedRoot> { |
322 | StructDef(StructDef<R>), | 321 | StructDef(StructDef<R>), |
323 | EnumDef(EnumDef<R>), | 322 | EnumDef(EnumDef<R>), |
324 | } | 323 | } |
@@ -344,7 +343,7 @@ impl<R: TreeRoot> NominalDef<R> {} | |||
344 | 343 | ||
345 | // ParenType | 344 | // ParenType |
346 | #[derive(Debug, Clone, Copy)] | 345 | #[derive(Debug, Clone, Copy)] |
347 | pub struct ParenType<R: TreeRoot = Arc<SyntaxRoot>> { | 346 | pub struct ParenType<R: TreeRoot = OwnedRoot> { |
348 | syntax: SyntaxNode<R>, | 347 | syntax: SyntaxNode<R>, |
349 | } | 348 | } |
350 | 349 | ||
@@ -362,7 +361,7 @@ impl<R: TreeRoot> ParenType<R> {} | |||
362 | 361 | ||
363 | // PathType | 362 | // PathType |
364 | #[derive(Debug, Clone, Copy)] | 363 | #[derive(Debug, Clone, Copy)] |
365 | pub struct PathType<R: TreeRoot = Arc<SyntaxRoot>> { | 364 | pub struct PathType<R: TreeRoot = OwnedRoot> { |
366 | syntax: SyntaxNode<R>, | 365 | syntax: SyntaxNode<R>, |
367 | } | 366 | } |
368 | 367 | ||
@@ -380,7 +379,7 @@ impl<R: TreeRoot> PathType<R> {} | |||
380 | 379 | ||
381 | // PlaceholderType | 380 | // PlaceholderType |
382 | #[derive(Debug, Clone, Copy)] | 381 | #[derive(Debug, Clone, Copy)] |
383 | pub struct PlaceholderType<R: TreeRoot = Arc<SyntaxRoot>> { | 382 | pub struct PlaceholderType<R: TreeRoot = OwnedRoot> { |
384 | syntax: SyntaxNode<R>, | 383 | syntax: SyntaxNode<R>, |
385 | } | 384 | } |
386 | 385 | ||
@@ -398,7 +397,7 @@ impl<R: TreeRoot> PlaceholderType<R> {} | |||
398 | 397 | ||
399 | // PointerType | 398 | // PointerType |
400 | #[derive(Debug, Clone, Copy)] | 399 | #[derive(Debug, Clone, Copy)] |
401 | pub struct PointerType<R: TreeRoot = Arc<SyntaxRoot>> { | 400 | pub struct PointerType<R: TreeRoot = OwnedRoot> { |
402 | syntax: SyntaxNode<R>, | 401 | syntax: SyntaxNode<R>, |
403 | } | 402 | } |
404 | 403 | ||
@@ -416,7 +415,7 @@ impl<R: TreeRoot> PointerType<R> {} | |||
416 | 415 | ||
417 | // ReferenceType | 416 | // ReferenceType |
418 | #[derive(Debug, Clone, Copy)] | 417 | #[derive(Debug, Clone, Copy)] |
419 | pub struct ReferenceType<R: TreeRoot = Arc<SyntaxRoot>> { | 418 | pub struct ReferenceType<R: TreeRoot = OwnedRoot> { |
420 | syntax: SyntaxNode<R>, | 419 | syntax: SyntaxNode<R>, |
421 | } | 420 | } |
422 | 421 | ||
@@ -434,7 +433,7 @@ impl<R: TreeRoot> ReferenceType<R> {} | |||
434 | 433 | ||
435 | // SliceType | 434 | // SliceType |
436 | #[derive(Debug, Clone, Copy)] | 435 | #[derive(Debug, Clone, Copy)] |
437 | pub struct SliceType<R: TreeRoot = Arc<SyntaxRoot>> { | 436 | pub struct SliceType<R: TreeRoot = OwnedRoot> { |
438 | syntax: SyntaxNode<R>, | 437 | syntax: SyntaxNode<R>, |
439 | } | 438 | } |
440 | 439 | ||
@@ -452,7 +451,7 @@ impl<R: TreeRoot> SliceType<R> {} | |||
452 | 451 | ||
453 | // StaticDef | 452 | // StaticDef |
454 | #[derive(Debug, Clone, Copy)] | 453 | #[derive(Debug, Clone, Copy)] |
455 | pub struct StaticDef<R: TreeRoot = Arc<SyntaxRoot>> { | 454 | pub struct StaticDef<R: TreeRoot = OwnedRoot> { |
456 | syntax: SyntaxNode<R>, | 455 | syntax: SyntaxNode<R>, |
457 | } | 456 | } |
458 | 457 | ||
@@ -472,7 +471,7 @@ impl<R: TreeRoot> StaticDef<R> {} | |||
472 | 471 | ||
473 | // StructDef | 472 | // StructDef |
474 | #[derive(Debug, Clone, Copy)] | 473 | #[derive(Debug, Clone, Copy)] |
475 | pub struct StructDef<R: TreeRoot = Arc<SyntaxRoot>> { | 474 | pub struct StructDef<R: TreeRoot = OwnedRoot> { |
476 | syntax: SyntaxNode<R>, | 475 | syntax: SyntaxNode<R>, |
477 | } | 476 | } |
478 | 477 | ||
@@ -498,7 +497,7 @@ impl<R: TreeRoot> StructDef<R> { | |||
498 | 497 | ||
499 | // TokenTree | 498 | // TokenTree |
500 | #[derive(Debug, Clone, Copy)] | 499 | #[derive(Debug, Clone, Copy)] |
501 | pub struct TokenTree<R: TreeRoot = Arc<SyntaxRoot>> { | 500 | pub struct TokenTree<R: TreeRoot = OwnedRoot> { |
502 | syntax: SyntaxNode<R>, | 501 | syntax: SyntaxNode<R>, |
503 | } | 502 | } |
504 | 503 | ||
@@ -516,7 +515,7 @@ impl<R: TreeRoot> TokenTree<R> {} | |||
516 | 515 | ||
517 | // TraitDef | 516 | // TraitDef |
518 | #[derive(Debug, Clone, Copy)] | 517 | #[derive(Debug, Clone, Copy)] |
519 | pub struct TraitDef<R: TreeRoot = Arc<SyntaxRoot>> { | 518 | pub struct TraitDef<R: TreeRoot = OwnedRoot> { |
520 | syntax: SyntaxNode<R>, | 519 | syntax: SyntaxNode<R>, |
521 | } | 520 | } |
522 | 521 | ||
@@ -536,7 +535,7 @@ impl<R: TreeRoot> TraitDef<R> {} | |||
536 | 535 | ||
537 | // TupleType | 536 | // TupleType |
538 | #[derive(Debug, Clone, Copy)] | 537 | #[derive(Debug, Clone, Copy)] |
539 | pub struct TupleType<R: TreeRoot = Arc<SyntaxRoot>> { | 538 | pub struct TupleType<R: TreeRoot = OwnedRoot> { |
540 | syntax: SyntaxNode<R>, | 539 | syntax: SyntaxNode<R>, |
541 | } | 540 | } |
542 | 541 | ||
@@ -554,7 +553,7 @@ impl<R: TreeRoot> TupleType<R> {} | |||
554 | 553 | ||
555 | // TypeDef | 554 | // TypeDef |
556 | #[derive(Debug, Clone, Copy)] | 555 | #[derive(Debug, Clone, Copy)] |
557 | pub struct TypeDef<R: TreeRoot = Arc<SyntaxRoot>> { | 556 | pub struct TypeDef<R: TreeRoot = OwnedRoot> { |
558 | syntax: SyntaxNode<R>, | 557 | syntax: SyntaxNode<R>, |
559 | } | 558 | } |
560 | 559 | ||
@@ -574,7 +573,7 @@ impl<R: TreeRoot> TypeDef<R> {} | |||
574 | 573 | ||
575 | // TypeRef | 574 | // TypeRef |
576 | #[derive(Debug, Clone, Copy)] | 575 | #[derive(Debug, Clone, Copy)] |
577 | pub enum TypeRef<R: TreeRoot = Arc<SyntaxRoot>> { | 576 | pub enum TypeRef<R: TreeRoot = OwnedRoot> { |
578 | ParenType(ParenType<R>), | 577 | ParenType(ParenType<R>), |
579 | TupleType(TupleType<R>), | 578 | TupleType(TupleType<R>), |
580 | NeverType(NeverType<R>), | 579 | NeverType(NeverType<R>), |
diff --git a/crates/libsyntax2/src/ast/mod.rs b/crates/libsyntax2/src/ast/mod.rs index 9b9200f99..b52230e9c 100644 --- a/crates/libsyntax2/src/ast/mod.rs +++ b/crates/libsyntax2/src/ast/mod.rs | |||
@@ -1,12 +1,10 @@ | |||
1 | mod generated; | 1 | mod generated; |
2 | 2 | ||
3 | use std::sync::Arc; | ||
4 | |||
5 | use itertools::Itertools; | 3 | use itertools::Itertools; |
6 | use smol_str::SmolStr; | 4 | use smol_str::SmolStr; |
7 | 5 | ||
8 | use { | 6 | use { |
9 | SyntaxNode, SyntaxNodeRef, SyntaxRoot, TreeRoot, SyntaxError, | 7 | SyntaxNode, SyntaxNodeRef, OwnedRoot, TreeRoot, SyntaxError, |
10 | SyntaxKind::*, | 8 | SyntaxKind::*, |
11 | }; | 9 | }; |
12 | pub use self::generated::*; | 10 | pub use self::generated::*; |
@@ -37,7 +35,7 @@ pub trait AttrsOwner<R: TreeRoot>: AstNode<R> { | |||
37 | } | 35 | } |
38 | } | 36 | } |
39 | 37 | ||
40 | impl File<Arc<SyntaxRoot>> { | 38 | impl File<OwnedRoot> { |
41 | pub fn parse(text: &str) -> Self { | 39 | pub fn parse(text: &str) -> Self { |
42 | File::cast(::parse(text)).unwrap() | 40 | File::cast(::parse(text)).unwrap() |
43 | } | 41 | } |
@@ -45,7 +43,7 @@ impl File<Arc<SyntaxRoot>> { | |||
45 | 43 | ||
46 | impl<R: TreeRoot> File<R> { | 44 | impl<R: TreeRoot> File<R> { |
47 | pub fn errors(&self) -> Vec<SyntaxError> { | 45 | pub fn errors(&self) -> Vec<SyntaxError> { |
48 | self.syntax().root.errors.clone() | 46 | self.syntax().root.syntax_root().errors.clone() |
49 | } | 47 | } |
50 | } | 48 | } |
51 | 49 | ||