diff options
Diffstat (limited to 'crates/ra_syntax')
-rw-r--r-- | crates/ra_syntax/src/ast.rs | 10 | ||||
-rw-r--r-- | crates/ra_syntax/src/ast/generated/nodes.rs | 254 | ||||
-rw-r--r-- | crates/ra_syntax/src/ast/make.rs | 4 | ||||
-rw-r--r-- | crates/ra_syntax/src/ast/node_ext.rs | 12 | ||||
-rw-r--r-- | crates/ra_syntax/src/lib.rs | 2 | ||||
-rw-r--r-- | crates/ra_syntax/src/tests.rs | 2 |
6 files changed, 142 insertions, 142 deletions
diff --git a/crates/ra_syntax/src/ast.rs b/crates/ra_syntax/src/ast.rs index fd426ece9..8a0e3d27b 100644 --- a/crates/ra_syntax/src/ast.rs +++ b/crates/ra_syntax/src/ast.rs | |||
@@ -287,7 +287,7 @@ where | |||
287 | 287 | ||
288 | assert!(pred.for_token().is_none()); | 288 | assert!(pred.for_token().is_none()); |
289 | assert!(pred.generic_param_list().is_none()); | 289 | assert!(pred.generic_param_list().is_none()); |
290 | assert_eq!("T", pred.type_ref().unwrap().syntax().text().to_string()); | 290 | assert_eq!("T", pred.ty().unwrap().syntax().text().to_string()); |
291 | assert_bound("Clone", bounds.next()); | 291 | assert_bound("Clone", bounds.next()); |
292 | assert_bound("Copy", bounds.next()); | 292 | assert_bound("Copy", bounds.next()); |
293 | assert_bound("Debug", bounds.next()); | 293 | assert_bound("Debug", bounds.next()); |
@@ -304,20 +304,20 @@ where | |||
304 | let pred = predicates.next().unwrap(); | 304 | let pred = predicates.next().unwrap(); |
305 | let mut bounds = pred.type_bound_list().unwrap().bounds(); | 305 | let mut bounds = pred.type_bound_list().unwrap().bounds(); |
306 | 306 | ||
307 | assert_eq!("Iterator::Item", pred.type_ref().unwrap().syntax().text().to_string()); | 307 | assert_eq!("Iterator::Item", pred.ty().unwrap().syntax().text().to_string()); |
308 | assert_bound("'a", bounds.next()); | 308 | assert_bound("'a", bounds.next()); |
309 | 309 | ||
310 | let pred = predicates.next().unwrap(); | 310 | let pred = predicates.next().unwrap(); |
311 | let mut bounds = pred.type_bound_list().unwrap().bounds(); | 311 | let mut bounds = pred.type_bound_list().unwrap().bounds(); |
312 | 312 | ||
313 | assert_eq!("Iterator::Item", pred.type_ref().unwrap().syntax().text().to_string()); | 313 | assert_eq!("Iterator::Item", pred.ty().unwrap().syntax().text().to_string()); |
314 | assert_bound("Debug", bounds.next()); | 314 | assert_bound("Debug", bounds.next()); |
315 | assert_bound("'a", bounds.next()); | 315 | assert_bound("'a", bounds.next()); |
316 | 316 | ||
317 | let pred = predicates.next().unwrap(); | 317 | let pred = predicates.next().unwrap(); |
318 | let mut bounds = pred.type_bound_list().unwrap().bounds(); | 318 | let mut bounds = pred.type_bound_list().unwrap().bounds(); |
319 | 319 | ||
320 | assert_eq!("<T as Iterator>::Item", pred.type_ref().unwrap().syntax().text().to_string()); | 320 | assert_eq!("<T as Iterator>::Item", pred.ty().unwrap().syntax().text().to_string()); |
321 | assert_bound("Debug", bounds.next()); | 321 | assert_bound("Debug", bounds.next()); |
322 | assert_bound("'a", bounds.next()); | 322 | assert_bound("'a", bounds.next()); |
323 | 323 | ||
@@ -326,6 +326,6 @@ where | |||
326 | 326 | ||
327 | assert!(pred.for_token().is_some()); | 327 | assert!(pred.for_token().is_some()); |
328 | assert_eq!("<'a>", pred.generic_param_list().unwrap().syntax().text().to_string()); | 328 | assert_eq!("<'a>", pred.generic_param_list().unwrap().syntax().text().to_string()); |
329 | assert_eq!("F", pred.type_ref().unwrap().syntax().text().to_string()); | 329 | assert_eq!("F", pred.ty().unwrap().syntax().text().to_string()); |
330 | assert_bound("Fn(&'a str)", bounds.next()); | 330 | assert_bound("Fn(&'a str)", bounds.next()); |
331 | } | 331 | } |
diff --git a/crates/ra_syntax/src/ast/generated/nodes.rs b/crates/ra_syntax/src/ast/generated/nodes.rs index 4306efe13..9cfd5d017 100644 --- a/crates/ra_syntax/src/ast/generated/nodes.rs +++ b/crates/ra_syntax/src/ast/generated/nodes.rs | |||
@@ -40,7 +40,7 @@ impl Const { | |||
40 | pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) } | 40 | pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) } |
41 | pub fn underscore_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![_]) } | 41 | pub fn underscore_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![_]) } |
42 | pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) } | 42 | pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) } |
43 | pub fn ty(&self) -> Option<TypeRef> { support::child(&self.syntax) } | 43 | pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) } |
44 | pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) } | 44 | pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) } |
45 | pub fn body(&self) -> Option<Expr> { support::child(&self.syntax) } | 45 | pub fn body(&self) -> Option<Expr> { support::child(&self.syntax) } |
46 | pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } | 46 | pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } |
@@ -112,7 +112,7 @@ impl Impl { | |||
112 | pub fn unsafe_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![unsafe]) } | 112 | pub fn unsafe_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![unsafe]) } |
113 | pub fn impl_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![impl]) } | 113 | pub fn impl_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![impl]) } |
114 | pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) } | 114 | pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) } |
115 | pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } | 115 | pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) } |
116 | pub fn excl_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![!]) } | 116 | pub fn excl_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![!]) } |
117 | pub fn for_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![for]) } | 117 | pub fn for_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![for]) } |
118 | pub fn assoc_item_list(&self) -> Option<AssocItemList> { support::child(&self.syntax) } | 118 | pub fn assoc_item_list(&self) -> Option<AssocItemList> { support::child(&self.syntax) } |
@@ -152,7 +152,7 @@ impl Static { | |||
152 | pub fn static_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![static]) } | 152 | pub fn static_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![static]) } |
153 | pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) } | 153 | pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) } |
154 | pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) } | 154 | pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) } |
155 | pub fn ty(&self) -> Option<TypeRef> { support::child(&self.syntax) } | 155 | pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) } |
156 | pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) } | 156 | pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) } |
157 | pub fn body(&self) -> Option<Expr> { support::child(&self.syntax) } | 157 | pub fn body(&self) -> Option<Expr> { support::child(&self.syntax) } |
158 | pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } | 158 | pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } |
@@ -198,7 +198,7 @@ impl TypeAlias { | |||
198 | pub fn default_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![default]) } | 198 | pub fn default_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![default]) } |
199 | pub fn type_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![type]) } | 199 | pub fn type_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![type]) } |
200 | pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) } | 200 | pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) } |
201 | pub fn ty(&self) -> Option<TypeRef> { support::child(&self.syntax) } | 201 | pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) } |
202 | pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } | 202 | pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } |
203 | } | 203 | } |
204 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 204 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
@@ -333,7 +333,7 @@ pub struct RetType { | |||
333 | } | 333 | } |
334 | impl RetType { | 334 | impl RetType { |
335 | pub fn thin_arrow_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![->]) } | 335 | pub fn thin_arrow_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![->]) } |
336 | pub fn ty(&self) -> Option<TypeRef> { support::child(&self.syntax) } | 336 | pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) } |
337 | } | 337 | } |
338 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 338 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
339 | pub struct WhereClause { | 339 | pub struct WhereClause { |
@@ -369,7 +369,7 @@ impl SelfParam { | |||
369 | pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) } | 369 | pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) } |
370 | pub fn self_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![self]) } | 370 | pub fn self_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![self]) } |
371 | pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) } | 371 | pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) } |
372 | pub fn ty(&self) -> Option<TypeRef> { support::child(&self.syntax) } | 372 | pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) } |
373 | } | 373 | } |
374 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 374 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
375 | pub struct Param { | 375 | pub struct Param { |
@@ -379,7 +379,7 @@ impl ast::AttrsOwner for Param {} | |||
379 | impl Param { | 379 | impl Param { |
380 | pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) } | 380 | pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) } |
381 | pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) } | 381 | pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) } |
382 | pub fn ty(&self) -> Option<TypeRef> { support::child(&self.syntax) } | 382 | pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) } |
383 | pub fn dotdotdot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![...]) } | 383 | pub fn dotdotdot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![...]) } |
384 | } | 384 | } |
385 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 385 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
@@ -416,7 +416,7 @@ impl ast::NameOwner for RecordField {} | |||
416 | impl ast::VisibilityOwner for RecordField {} | 416 | impl ast::VisibilityOwner for RecordField {} |
417 | impl RecordField { | 417 | impl RecordField { |
418 | pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) } | 418 | pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) } |
419 | pub fn ty(&self) -> Option<TypeRef> { support::child(&self.syntax) } | 419 | pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) } |
420 | } | 420 | } |
421 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 421 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
422 | pub struct TupleField { | 422 | pub struct TupleField { |
@@ -425,7 +425,7 @@ pub struct TupleField { | |||
425 | impl ast::AttrsOwner for TupleField {} | 425 | impl ast::AttrsOwner for TupleField {} |
426 | impl ast::VisibilityOwner for TupleField {} | 426 | impl ast::VisibilityOwner for TupleField {} |
427 | impl TupleField { | 427 | impl TupleField { |
428 | pub fn ty(&self) -> Option<TypeRef> { support::child(&self.syntax) } | 428 | pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) } |
429 | } | 429 | } |
430 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 430 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
431 | pub struct VariantList { | 431 | pub struct VariantList { |
@@ -487,7 +487,7 @@ impl ast::NameOwner for TypeParam {} | |||
487 | impl ast::TypeBoundsOwner for TypeParam {} | 487 | impl ast::TypeBoundsOwner for TypeParam {} |
488 | impl TypeParam { | 488 | impl TypeParam { |
489 | pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) } | 489 | pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) } |
490 | pub fn default_type(&self) -> Option<TypeRef> { support::child(&self.syntax) } | 490 | pub fn default_type(&self) -> Option<Type> { support::child(&self.syntax) } |
491 | } | 491 | } |
492 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 492 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
493 | pub struct ConstParam { | 493 | pub struct ConstParam { |
@@ -498,7 +498,7 @@ impl ast::NameOwner for ConstParam {} | |||
498 | impl ConstParam { | 498 | impl ConstParam { |
499 | pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) } | 499 | pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) } |
500 | pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) } | 500 | pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) } |
501 | pub fn ty(&self) -> Option<TypeRef> { support::child(&self.syntax) } | 501 | pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) } |
502 | pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) } | 502 | pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) } |
503 | pub fn default_val(&self) -> Option<Expr> { support::child(&self.syntax) } | 503 | pub fn default_val(&self) -> Option<Expr> { support::child(&self.syntax) } |
504 | } | 504 | } |
@@ -525,7 +525,7 @@ pub struct ParenType { | |||
525 | } | 525 | } |
526 | impl ParenType { | 526 | impl ParenType { |
527 | pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) } | 527 | pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) } |
528 | pub fn ty(&self) -> Option<TypeRef> { support::child(&self.syntax) } | 528 | pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) } |
529 | pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) } | 529 | pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) } |
530 | } | 530 | } |
531 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 531 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
@@ -534,7 +534,7 @@ pub struct TupleType { | |||
534 | } | 534 | } |
535 | impl TupleType { | 535 | impl TupleType { |
536 | pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) } | 536 | pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) } |
537 | pub fn fields(&self) -> AstChildren<TypeRef> { support::children(&self.syntax) } | 537 | pub fn fields(&self) -> AstChildren<Type> { support::children(&self.syntax) } |
538 | pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) } | 538 | pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) } |
539 | } | 539 | } |
540 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 540 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
@@ -559,7 +559,7 @@ impl PointerType { | |||
559 | pub fn star_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![*]) } | 559 | pub fn star_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![*]) } |
560 | pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) } | 560 | pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) } |
561 | pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) } | 561 | pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) } |
562 | pub fn ty(&self) -> Option<TypeRef> { support::child(&self.syntax) } | 562 | pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) } |
563 | } | 563 | } |
564 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 564 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
565 | pub struct ArrayType { | 565 | pub struct ArrayType { |
@@ -567,7 +567,7 @@ pub struct ArrayType { | |||
567 | } | 567 | } |
568 | impl ArrayType { | 568 | impl ArrayType { |
569 | pub fn l_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['[']) } | 569 | pub fn l_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['[']) } |
570 | pub fn ty(&self) -> Option<TypeRef> { support::child(&self.syntax) } | 570 | pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) } |
571 | pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } | 571 | pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } |
572 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } | 572 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } |
573 | pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) } | 573 | pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) } |
@@ -578,7 +578,7 @@ pub struct SliceType { | |||
578 | } | 578 | } |
579 | impl SliceType { | 579 | impl SliceType { |
580 | pub fn l_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['[']) } | 580 | pub fn l_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['[']) } |
581 | pub fn ty(&self) -> Option<TypeRef> { support::child(&self.syntax) } | 581 | pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) } |
582 | pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) } | 582 | pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) } |
583 | } | 583 | } |
584 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 584 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
@@ -591,7 +591,7 @@ impl ReferenceType { | |||
591 | support::token(&self.syntax, T![lifetime]) | 591 | support::token(&self.syntax, T![lifetime]) |
592 | } | 592 | } |
593 | pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) } | 593 | pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) } |
594 | pub fn ty(&self) -> Option<TypeRef> { support::child(&self.syntax) } | 594 | pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) } |
595 | } | 595 | } |
596 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 596 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
597 | pub struct PlaceholderType { | 597 | pub struct PlaceholderType { |
@@ -618,7 +618,7 @@ pub struct ForType { | |||
618 | impl ForType { | 618 | impl ForType { |
619 | pub fn for_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![for]) } | 619 | pub fn for_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![for]) } |
620 | pub fn generic_param_list(&self) -> Option<GenericParamList> { support::child(&self.syntax) } | 620 | pub fn generic_param_list(&self) -> Option<GenericParamList> { support::child(&self.syntax) } |
621 | pub fn ty(&self) -> Option<TypeRef> { support::child(&self.syntax) } | 621 | pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) } |
622 | } | 622 | } |
623 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 623 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
624 | pub struct ImplTraitType { | 624 | pub struct ImplTraitType { |
@@ -882,7 +882,7 @@ impl ast::AttrsOwner for CastExpr {} | |||
882 | impl CastExpr { | 882 | impl CastExpr { |
883 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } | 883 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } |
884 | pub fn as_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![as]) } | 884 | pub fn as_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![as]) } |
885 | pub fn ty(&self) -> Option<TypeRef> { support::child(&self.syntax) } | 885 | pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) } |
886 | } | 886 | } |
887 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 887 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
888 | pub struct RefExpr { | 888 | pub struct RefExpr { |
@@ -1174,7 +1174,7 @@ impl TypeBound { | |||
1174 | support::token(&self.syntax, T![lifetime]) | 1174 | support::token(&self.syntax, T![lifetime]) |
1175 | } | 1175 | } |
1176 | pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) } | 1176 | pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) } |
1177 | pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } | 1177 | pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) } |
1178 | } | 1178 | } |
1179 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 1179 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
1180 | pub struct WherePred { | 1180 | pub struct WherePred { |
@@ -1187,7 +1187,7 @@ impl WherePred { | |||
1187 | pub fn lifetime_token(&self) -> Option<SyntaxToken> { | 1187 | pub fn lifetime_token(&self) -> Option<SyntaxToken> { |
1188 | support::token(&self.syntax, T![lifetime]) | 1188 | support::token(&self.syntax, T![lifetime]) |
1189 | } | 1189 | } |
1190 | pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } | 1190 | pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) } |
1191 | } | 1191 | } |
1192 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 1192 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
1193 | pub struct ExprStmt { | 1193 | pub struct ExprStmt { |
@@ -1207,7 +1207,7 @@ impl LetStmt { | |||
1207 | pub fn let_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![let]) } | 1207 | pub fn let_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![let]) } |
1208 | pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) } | 1208 | pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) } |
1209 | pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) } | 1209 | pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) } |
1210 | pub fn ty(&self) -> Option<TypeRef> { support::child(&self.syntax) } | 1210 | pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) } |
1211 | pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) } | 1211 | pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) } |
1212 | pub fn initializer(&self) -> Option<Expr> { support::child(&self.syntax) } | 1212 | pub fn initializer(&self) -> Option<Expr> { support::child(&self.syntax) } |
1213 | pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } | 1213 | pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } |
@@ -1234,7 +1234,7 @@ pub struct TypeArg { | |||
1234 | pub(crate) syntax: SyntaxNode, | 1234 | pub(crate) syntax: SyntaxNode, |
1235 | } | 1235 | } |
1236 | impl TypeArg { | 1236 | impl TypeArg { |
1237 | pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } | 1237 | pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) } |
1238 | } | 1238 | } |
1239 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 1239 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
1240 | pub struct LifetimeArg { | 1240 | pub struct LifetimeArg { |
@@ -1253,7 +1253,7 @@ impl ast::TypeBoundsOwner for AssocTypeArg {} | |||
1253 | impl AssocTypeArg { | 1253 | impl AssocTypeArg { |
1254 | pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) } | 1254 | pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) } |
1255 | pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) } | 1255 | pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) } |
1256 | pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } | 1256 | pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) } |
1257 | } | 1257 | } |
1258 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 1258 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
1259 | pub struct ConstArg { | 1259 | pub struct ConstArg { |
@@ -1282,7 +1282,7 @@ pub enum Item { | |||
1282 | } | 1282 | } |
1283 | impl ast::AttrsOwner for Item {} | 1283 | impl ast::AttrsOwner for Item {} |
1284 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 1284 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
1285 | pub enum TypeRef { | 1285 | pub enum Type { |
1286 | ParenType(ParenType), | 1286 | ParenType(ParenType), |
1287 | TupleType(TupleType), | 1287 | TupleType(TupleType), |
1288 | NeverType(NeverType), | 1288 | NeverType(NeverType), |
@@ -1355,6 +1355,16 @@ pub enum Expr { | |||
1355 | BoxExpr(BoxExpr), | 1355 | BoxExpr(BoxExpr), |
1356 | } | 1356 | } |
1357 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 1357 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
1358 | pub enum AdtDef { | ||
1359 | Struct(Struct), | ||
1360 | Enum(Enum), | ||
1361 | Union(Union), | ||
1362 | } | ||
1363 | impl ast::AttrsOwner for AdtDef {} | ||
1364 | impl ast::GenericParamsOwner for AdtDef {} | ||
1365 | impl ast::NameOwner for AdtDef {} | ||
1366 | impl ast::VisibilityOwner for AdtDef {} | ||
1367 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1358 | pub enum AssocItem { | 1368 | pub enum AssocItem { |
1359 | Fn(Fn), | 1369 | Fn(Fn), |
1360 | TypeAlias(TypeAlias), | 1370 | TypeAlias(TypeAlias), |
@@ -1384,16 +1394,6 @@ pub enum Stmt { | |||
1384 | ExprStmt(ExprStmt), | 1394 | ExprStmt(ExprStmt), |
1385 | } | 1395 | } |
1386 | impl ast::AttrsOwner for Stmt {} | 1396 | impl ast::AttrsOwner for Stmt {} |
1387 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1388 | pub enum AdtDef { | ||
1389 | Struct(Struct), | ||
1390 | Enum(Enum), | ||
1391 | Union(Union), | ||
1392 | } | ||
1393 | impl ast::AttrsOwner for AdtDef {} | ||
1394 | impl ast::GenericParamsOwner for AdtDef {} | ||
1395 | impl ast::NameOwner for AdtDef {} | ||
1396 | impl ast::VisibilityOwner for AdtDef {} | ||
1397 | impl AstNode for SourceFile { | 1397 | impl AstNode for SourceFile { |
1398 | fn can_cast(kind: SyntaxKind) -> bool { kind == SOURCE_FILE } | 1398 | fn can_cast(kind: SyntaxKind) -> bool { kind == SOURCE_FILE } |
1399 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 1399 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
@@ -2847,46 +2847,46 @@ impl AstNode for Item { | |||
2847 | } | 2847 | } |
2848 | } | 2848 | } |
2849 | } | 2849 | } |
2850 | impl From<ParenType> for TypeRef { | 2850 | impl From<ParenType> for Type { |
2851 | fn from(node: ParenType) -> TypeRef { TypeRef::ParenType(node) } | 2851 | fn from(node: ParenType) -> Type { Type::ParenType(node) } |
2852 | } | 2852 | } |
2853 | impl From<TupleType> for TypeRef { | 2853 | impl From<TupleType> for Type { |
2854 | fn from(node: TupleType) -> TypeRef { TypeRef::TupleType(node) } | 2854 | fn from(node: TupleType) -> Type { Type::TupleType(node) } |
2855 | } | 2855 | } |
2856 | impl From<NeverType> for TypeRef { | 2856 | impl From<NeverType> for Type { |
2857 | fn from(node: NeverType) -> TypeRef { TypeRef::NeverType(node) } | 2857 | fn from(node: NeverType) -> Type { Type::NeverType(node) } |
2858 | } | 2858 | } |
2859 | impl From<PathType> for TypeRef { | 2859 | impl From<PathType> for Type { |
2860 | fn from(node: PathType) -> TypeRef { TypeRef::PathType(node) } | 2860 | fn from(node: PathType) -> Type { Type::PathType(node) } |
2861 | } | 2861 | } |
2862 | impl From<PointerType> for TypeRef { | 2862 | impl From<PointerType> for Type { |
2863 | fn from(node: PointerType) -> TypeRef { TypeRef::PointerType(node) } | 2863 | fn from(node: PointerType) -> Type { Type::PointerType(node) } |
2864 | } | 2864 | } |
2865 | impl From<ArrayType> for TypeRef { | 2865 | impl From<ArrayType> for Type { |
2866 | fn from(node: ArrayType) -> TypeRef { TypeRef::ArrayType(node) } | 2866 | fn from(node: ArrayType) -> Type { Type::ArrayType(node) } |
2867 | } | 2867 | } |
2868 | impl From<SliceType> for TypeRef { | 2868 | impl From<SliceType> for Type { |
2869 | fn from(node: SliceType) -> TypeRef { TypeRef::SliceType(node) } | 2869 | fn from(node: SliceType) -> Type { Type::SliceType(node) } |
2870 | } | 2870 | } |
2871 | impl From<ReferenceType> for TypeRef { | 2871 | impl From<ReferenceType> for Type { |
2872 | fn from(node: ReferenceType) -> TypeRef { TypeRef::ReferenceType(node) } | 2872 | fn from(node: ReferenceType) -> Type { Type::ReferenceType(node) } |
2873 | } | 2873 | } |
2874 | impl From<PlaceholderType> for TypeRef { | 2874 | impl From<PlaceholderType> for Type { |
2875 | fn from(node: PlaceholderType) -> TypeRef { TypeRef::PlaceholderType(node) } | 2875 | fn from(node: PlaceholderType) -> Type { Type::PlaceholderType(node) } |
2876 | } | 2876 | } |
2877 | impl From<FnPointerType> for TypeRef { | 2877 | impl From<FnPointerType> for Type { |
2878 | fn from(node: FnPointerType) -> TypeRef { TypeRef::FnPointerType(node) } | 2878 | fn from(node: FnPointerType) -> Type { Type::FnPointerType(node) } |
2879 | } | 2879 | } |
2880 | impl From<ForType> for TypeRef { | 2880 | impl From<ForType> for Type { |
2881 | fn from(node: ForType) -> TypeRef { TypeRef::ForType(node) } | 2881 | fn from(node: ForType) -> Type { Type::ForType(node) } |
2882 | } | 2882 | } |
2883 | impl From<ImplTraitType> for TypeRef { | 2883 | impl From<ImplTraitType> for Type { |
2884 | fn from(node: ImplTraitType) -> TypeRef { TypeRef::ImplTraitType(node) } | 2884 | fn from(node: ImplTraitType) -> Type { Type::ImplTraitType(node) } |
2885 | } | 2885 | } |
2886 | impl From<DynTraitType> for TypeRef { | 2886 | impl From<DynTraitType> for Type { |
2887 | fn from(node: DynTraitType) -> TypeRef { TypeRef::DynTraitType(node) } | 2887 | fn from(node: DynTraitType) -> Type { Type::DynTraitType(node) } |
2888 | } | 2888 | } |
2889 | impl AstNode for TypeRef { | 2889 | impl AstNode for Type { |
2890 | fn can_cast(kind: SyntaxKind) -> bool { | 2890 | fn can_cast(kind: SyntaxKind) -> bool { |
2891 | match kind { | 2891 | match kind { |
2892 | PAREN_TYPE | TUPLE_TYPE | NEVER_TYPE | PATH_TYPE | POINTER_TYPE | ARRAY_TYPE | 2892 | PAREN_TYPE | TUPLE_TYPE | NEVER_TYPE | PATH_TYPE | POINTER_TYPE | ARRAY_TYPE |
@@ -2897,38 +2897,38 @@ impl AstNode for TypeRef { | |||
2897 | } | 2897 | } |
2898 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 2898 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
2899 | let res = match syntax.kind() { | 2899 | let res = match syntax.kind() { |
2900 | PAREN_TYPE => TypeRef::ParenType(ParenType { syntax }), | 2900 | PAREN_TYPE => Type::ParenType(ParenType { syntax }), |
2901 | TUPLE_TYPE => TypeRef::TupleType(TupleType { syntax }), | 2901 | TUPLE_TYPE => Type::TupleType(TupleType { syntax }), |
2902 | NEVER_TYPE => TypeRef::NeverType(NeverType { syntax }), | 2902 | NEVER_TYPE => Type::NeverType(NeverType { syntax }), |
2903 | PATH_TYPE => TypeRef::PathType(PathType { syntax }), | 2903 | PATH_TYPE => Type::PathType(PathType { syntax }), |
2904 | POINTER_TYPE => TypeRef::PointerType(PointerType { syntax }), | 2904 | POINTER_TYPE => Type::PointerType(PointerType { syntax }), |
2905 | ARRAY_TYPE => TypeRef::ArrayType(ArrayType { syntax }), | 2905 | ARRAY_TYPE => Type::ArrayType(ArrayType { syntax }), |
2906 | SLICE_TYPE => TypeRef::SliceType(SliceType { syntax }), | 2906 | SLICE_TYPE => Type::SliceType(SliceType { syntax }), |
2907 | REFERENCE_TYPE => TypeRef::ReferenceType(ReferenceType { syntax }), | 2907 | REFERENCE_TYPE => Type::ReferenceType(ReferenceType { syntax }), |
2908 | PLACEHOLDER_TYPE => TypeRef::PlaceholderType(PlaceholderType { syntax }), | 2908 | PLACEHOLDER_TYPE => Type::PlaceholderType(PlaceholderType { syntax }), |
2909 | FN_POINTER_TYPE => TypeRef::FnPointerType(FnPointerType { syntax }), | 2909 | FN_POINTER_TYPE => Type::FnPointerType(FnPointerType { syntax }), |
2910 | FOR_TYPE => TypeRef::ForType(ForType { syntax }), | 2910 | FOR_TYPE => Type::ForType(ForType { syntax }), |
2911 | IMPL_TRAIT_TYPE => TypeRef::ImplTraitType(ImplTraitType { syntax }), | 2911 | IMPL_TRAIT_TYPE => Type::ImplTraitType(ImplTraitType { syntax }), |
2912 | DYN_TRAIT_TYPE => TypeRef::DynTraitType(DynTraitType { syntax }), | 2912 | DYN_TRAIT_TYPE => Type::DynTraitType(DynTraitType { syntax }), |
2913 | _ => return None, | 2913 | _ => return None, |
2914 | }; | 2914 | }; |
2915 | Some(res) | 2915 | Some(res) |
2916 | } | 2916 | } |
2917 | fn syntax(&self) -> &SyntaxNode { | 2917 | fn syntax(&self) -> &SyntaxNode { |
2918 | match self { | 2918 | match self { |
2919 | TypeRef::ParenType(it) => &it.syntax, | 2919 | Type::ParenType(it) => &it.syntax, |
2920 | TypeRef::TupleType(it) => &it.syntax, | 2920 | Type::TupleType(it) => &it.syntax, |
2921 | TypeRef::NeverType(it) => &it.syntax, | 2921 | Type::NeverType(it) => &it.syntax, |
2922 | TypeRef::PathType(it) => &it.syntax, | 2922 | Type::PathType(it) => &it.syntax, |
2923 | TypeRef::PointerType(it) => &it.syntax, | 2923 | Type::PointerType(it) => &it.syntax, |
2924 | TypeRef::ArrayType(it) => &it.syntax, | 2924 | Type::ArrayType(it) => &it.syntax, |
2925 | TypeRef::SliceType(it) => &it.syntax, | 2925 | Type::SliceType(it) => &it.syntax, |
2926 | TypeRef::ReferenceType(it) => &it.syntax, | 2926 | Type::ReferenceType(it) => &it.syntax, |
2927 | TypeRef::PlaceholderType(it) => &it.syntax, | 2927 | Type::PlaceholderType(it) => &it.syntax, |
2928 | TypeRef::FnPointerType(it) => &it.syntax, | 2928 | Type::FnPointerType(it) => &it.syntax, |
2929 | TypeRef::ForType(it) => &it.syntax, | 2929 | Type::ForType(it) => &it.syntax, |
2930 | TypeRef::ImplTraitType(it) => &it.syntax, | 2930 | Type::ImplTraitType(it) => &it.syntax, |
2931 | TypeRef::DynTraitType(it) => &it.syntax, | 2931 | Type::DynTraitType(it) => &it.syntax, |
2932 | } | 2932 | } |
2933 | } | 2933 | } |
2934 | } | 2934 | } |
@@ -3234,6 +3234,39 @@ impl AstNode for Expr { | |||
3234 | } | 3234 | } |
3235 | } | 3235 | } |
3236 | } | 3236 | } |
3237 | impl From<Struct> for AdtDef { | ||
3238 | fn from(node: Struct) -> AdtDef { AdtDef::Struct(node) } | ||
3239 | } | ||
3240 | impl From<Enum> for AdtDef { | ||
3241 | fn from(node: Enum) -> AdtDef { AdtDef::Enum(node) } | ||
3242 | } | ||
3243 | impl From<Union> for AdtDef { | ||
3244 | fn from(node: Union) -> AdtDef { AdtDef::Union(node) } | ||
3245 | } | ||
3246 | impl AstNode for AdtDef { | ||
3247 | fn can_cast(kind: SyntaxKind) -> bool { | ||
3248 | match kind { | ||
3249 | STRUCT | ENUM | UNION => true, | ||
3250 | _ => false, | ||
3251 | } | ||
3252 | } | ||
3253 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
3254 | let res = match syntax.kind() { | ||
3255 | STRUCT => AdtDef::Struct(Struct { syntax }), | ||
3256 | ENUM => AdtDef::Enum(Enum { syntax }), | ||
3257 | UNION => AdtDef::Union(Union { syntax }), | ||
3258 | _ => return None, | ||
3259 | }; | ||
3260 | Some(res) | ||
3261 | } | ||
3262 | fn syntax(&self) -> &SyntaxNode { | ||
3263 | match self { | ||
3264 | AdtDef::Struct(it) => &it.syntax, | ||
3265 | AdtDef::Enum(it) => &it.syntax, | ||
3266 | AdtDef::Union(it) => &it.syntax, | ||
3267 | } | ||
3268 | } | ||
3269 | } | ||
3237 | impl From<Fn> for AssocItem { | 3270 | impl From<Fn> for AssocItem { |
3238 | fn from(node: Fn) -> AssocItem { AssocItem::Fn(node) } | 3271 | fn from(node: Fn) -> AssocItem { AssocItem::Fn(node) } |
3239 | } | 3272 | } |
@@ -3366,45 +3399,12 @@ impl AstNode for Stmt { | |||
3366 | } | 3399 | } |
3367 | } | 3400 | } |
3368 | } | 3401 | } |
3369 | impl From<Struct> for AdtDef { | ||
3370 | fn from(node: Struct) -> AdtDef { AdtDef::Struct(node) } | ||
3371 | } | ||
3372 | impl From<Enum> for AdtDef { | ||
3373 | fn from(node: Enum) -> AdtDef { AdtDef::Enum(node) } | ||
3374 | } | ||
3375 | impl From<Union> for AdtDef { | ||
3376 | fn from(node: Union) -> AdtDef { AdtDef::Union(node) } | ||
3377 | } | ||
3378 | impl AstNode for AdtDef { | ||
3379 | fn can_cast(kind: SyntaxKind) -> bool { | ||
3380 | match kind { | ||
3381 | STRUCT | ENUM | UNION => true, | ||
3382 | _ => false, | ||
3383 | } | ||
3384 | } | ||
3385 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
3386 | let res = match syntax.kind() { | ||
3387 | STRUCT => AdtDef::Struct(Struct { syntax }), | ||
3388 | ENUM => AdtDef::Enum(Enum { syntax }), | ||
3389 | UNION => AdtDef::Union(Union { syntax }), | ||
3390 | _ => return None, | ||
3391 | }; | ||
3392 | Some(res) | ||
3393 | } | ||
3394 | fn syntax(&self) -> &SyntaxNode { | ||
3395 | match self { | ||
3396 | AdtDef::Struct(it) => &it.syntax, | ||
3397 | AdtDef::Enum(it) => &it.syntax, | ||
3398 | AdtDef::Union(it) => &it.syntax, | ||
3399 | } | ||
3400 | } | ||
3401 | } | ||
3402 | impl std::fmt::Display for Item { | 3402 | impl std::fmt::Display for Item { |
3403 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3403 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3404 | std::fmt::Display::fmt(self.syntax(), f) | 3404 | std::fmt::Display::fmt(self.syntax(), f) |
3405 | } | 3405 | } |
3406 | } | 3406 | } |
3407 | impl std::fmt::Display for TypeRef { | 3407 | impl std::fmt::Display for Type { |
3408 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3408 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3409 | std::fmt::Display::fmt(self.syntax(), f) | 3409 | std::fmt::Display::fmt(self.syntax(), f) |
3410 | } | 3410 | } |
@@ -3424,27 +3424,27 @@ impl std::fmt::Display for Expr { | |||
3424 | std::fmt::Display::fmt(self.syntax(), f) | 3424 | std::fmt::Display::fmt(self.syntax(), f) |
3425 | } | 3425 | } |
3426 | } | 3426 | } |
3427 | impl std::fmt::Display for AssocItem { | 3427 | impl std::fmt::Display for AdtDef { |
3428 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3428 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3429 | std::fmt::Display::fmt(self.syntax(), f) | 3429 | std::fmt::Display::fmt(self.syntax(), f) |
3430 | } | 3430 | } |
3431 | } | 3431 | } |
3432 | impl std::fmt::Display for ExternItem { | 3432 | impl std::fmt::Display for AssocItem { |
3433 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3433 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3434 | std::fmt::Display::fmt(self.syntax(), f) | 3434 | std::fmt::Display::fmt(self.syntax(), f) |
3435 | } | 3435 | } |
3436 | } | 3436 | } |
3437 | impl std::fmt::Display for GenericParam { | 3437 | impl std::fmt::Display for ExternItem { |
3438 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3438 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3439 | std::fmt::Display::fmt(self.syntax(), f) | 3439 | std::fmt::Display::fmt(self.syntax(), f) |
3440 | } | 3440 | } |
3441 | } | 3441 | } |
3442 | impl std::fmt::Display for Stmt { | 3442 | impl std::fmt::Display for GenericParam { |
3443 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3443 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3444 | std::fmt::Display::fmt(self.syntax(), f) | 3444 | std::fmt::Display::fmt(self.syntax(), f) |
3445 | } | 3445 | } |
3446 | } | 3446 | } |
3447 | impl std::fmt::Display for AdtDef { | 3447 | impl std::fmt::Display for Stmt { |
3448 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3448 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3449 | std::fmt::Display::fmt(self.syntax(), f) | 3449 | std::fmt::Display::fmt(self.syntax(), f) |
3450 | } | 3450 | } |
diff --git a/crates/ra_syntax/src/ast/make.rs b/crates/ra_syntax/src/ast/make.rs index 509e8ae7a..3d4fed64c 100644 --- a/crates/ra_syntax/src/ast/make.rs +++ b/crates/ra_syntax/src/ast/make.rs | |||
@@ -17,7 +17,7 @@ pub fn name_ref(text: &str) -> ast::NameRef { | |||
17 | ast_from_text(&format!("fn f() {{ {}; }}", text)) | 17 | ast_from_text(&format!("fn f() {{ {}; }}", text)) |
18 | } | 18 | } |
19 | 19 | ||
20 | pub fn type_ref(text: &str) -> ast::TypeRef { | 20 | pub fn type_ref(text: &str) -> ast::Type { |
21 | ast_from_text(&format!("impl {} for D {{}};", text)) | 21 | ast_from_text(&format!("impl {} for D {{}};", text)) |
22 | } | 22 | } |
23 | 23 | ||
@@ -75,7 +75,7 @@ pub fn record_field(name: ast::NameRef, expr: Option<ast::Expr>) -> ast::RecordE | |||
75 | } | 75 | } |
76 | } | 76 | } |
77 | 77 | ||
78 | pub fn record_field_def(name: ast::NameRef, ty: ast::TypeRef) -> ast::RecordField { | 78 | pub fn record_field_def(name: ast::NameRef, ty: ast::Type) -> ast::RecordField { |
79 | ast_from_text(&format!("struct S {{ {}: {}, }}", name, ty)) | 79 | ast_from_text(&format!("struct S {{ {}: {}, }}", name, ty)) |
80 | } | 80 | } |
81 | 81 | ||
diff --git a/crates/ra_syntax/src/ast/node_ext.rs b/crates/ra_syntax/src/ast/node_ext.rs index bba7310ad..30c2db56b 100644 --- a/crates/ra_syntax/src/ast/node_ext.rs +++ b/crates/ra_syntax/src/ast/node_ext.rs | |||
@@ -82,7 +82,7 @@ impl ast::Attr { | |||
82 | #[derive(Debug, Clone, PartialEq, Eq)] | 82 | #[derive(Debug, Clone, PartialEq, Eq)] |
83 | pub enum PathSegmentKind { | 83 | pub enum PathSegmentKind { |
84 | Name(ast::NameRef), | 84 | Name(ast::NameRef), |
85 | Type { type_ref: Option<ast::TypeRef>, trait_ref: Option<ast::PathType> }, | 85 | Type { type_ref: Option<ast::Type>, trait_ref: Option<ast::PathType> }, |
86 | SelfKw, | 86 | SelfKw, |
87 | SuperKw, | 87 | SuperKw, |
88 | CrateKw, | 88 | CrateKw, |
@@ -108,8 +108,8 @@ impl ast::PathSegment { | |||
108 | // <T> or <T as Trait> | 108 | // <T> or <T as Trait> |
109 | // T is any TypeRef, Trait has to be a PathType | 109 | // T is any TypeRef, Trait has to be a PathType |
110 | let mut type_refs = | 110 | let mut type_refs = |
111 | self.syntax().children().filter(|node| ast::TypeRef::can_cast(node.kind())); | 111 | self.syntax().children().filter(|node| ast::Type::can_cast(node.kind())); |
112 | let type_ref = type_refs.next().and_then(ast::TypeRef::cast); | 112 | let type_ref = type_refs.next().and_then(ast::Type::cast); |
113 | let trait_ref = type_refs.next().and_then(ast::PathType::cast); | 113 | let trait_ref = type_refs.next().and_then(ast::PathType::cast); |
114 | PathSegmentKind::Type { type_ref, trait_ref } | 114 | PathSegmentKind::Type { type_ref, trait_ref } |
115 | } | 115 | } |
@@ -136,21 +136,21 @@ impl ast::UseTreeList { | |||
136 | } | 136 | } |
137 | 137 | ||
138 | impl ast::Impl { | 138 | impl ast::Impl { |
139 | pub fn target_type(&self) -> Option<ast::TypeRef> { | 139 | pub fn target_type(&self) -> Option<ast::Type> { |
140 | match self.target() { | 140 | match self.target() { |
141 | (Some(t), None) | (_, Some(t)) => Some(t), | 141 | (Some(t), None) | (_, Some(t)) => Some(t), |
142 | _ => None, | 142 | _ => None, |
143 | } | 143 | } |
144 | } | 144 | } |
145 | 145 | ||
146 | pub fn target_trait(&self) -> Option<ast::TypeRef> { | 146 | pub fn target_trait(&self) -> Option<ast::Type> { |
147 | match self.target() { | 147 | match self.target() { |
148 | (Some(t), Some(_)) => Some(t), | 148 | (Some(t), Some(_)) => Some(t), |
149 | _ => None, | 149 | _ => None, |
150 | } | 150 | } |
151 | } | 151 | } |
152 | 152 | ||
153 | fn target(&self) -> (Option<ast::TypeRef>, Option<ast::TypeRef>) { | 153 | fn target(&self) -> (Option<ast::Type>, Option<ast::Type>) { |
154 | let mut types = support::children(self.syntax()); | 154 | let mut types = support::children(self.syntax()); |
155 | let first = types.next(); | 155 | let first = types.next(); |
156 | let second = types.next(); | 156 | let second = types.next(); |
diff --git a/crates/ra_syntax/src/lib.rs b/crates/ra_syntax/src/lib.rs index 6203b6206..8a4d45386 100644 --- a/crates/ra_syntax/src/lib.rs +++ b/crates/ra_syntax/src/lib.rs | |||
@@ -194,7 +194,7 @@ impl ast::Item { | |||
194 | } | 194 | } |
195 | } | 195 | } |
196 | 196 | ||
197 | impl ast::TypeRef { | 197 | impl ast::Type { |
198 | /// Returns `text`, parsed as an type reference, but only if it has no errors. | 198 | /// Returns `text`, parsed as an type reference, but only if it has no errors. |
199 | pub fn parse(text: &str) -> Result<Self, ()> { | 199 | pub fn parse(text: &str) -> Result<Self, ()> { |
200 | parsing::parse_text_fragment(text, ra_parser::FragmentKind::Type) | 200 | parsing::parse_text_fragment(text, ra_parser::FragmentKind::Type) |
diff --git a/crates/ra_syntax/src/tests.rs b/crates/ra_syntax/src/tests.rs index 68cee8914..00b957f43 100644 --- a/crates/ra_syntax/src/tests.rs +++ b/crates/ra_syntax/src/tests.rs | |||
@@ -98,7 +98,7 @@ fn type_parser_tests() { | |||
98 | fragment_parser_dir_test( | 98 | fragment_parser_dir_test( |
99 | &["parser/fragments/type/ok"], | 99 | &["parser/fragments/type/ok"], |
100 | &["parser/fragments/type/err"], | 100 | &["parser/fragments/type/err"], |
101 | crate::ast::TypeRef::parse, | 101 | crate::ast::Type::parse, |
102 | ); | 102 | ); |
103 | } | 103 | } |
104 | 104 | ||