@@ -1072,6 +1072,13 @@ impl InferType {
1072
1072
pub fn underscore_token ( & self ) -> Option < SyntaxToken > { support:: token ( & self . syntax , T ! [ _] ) }
1073
1073
}
1074
1074
#[ derive( Debug , Clone , PartialEq , Eq , Hash ) ]
1075
+ pub struct MacroType {
1076
+ pub ( crate ) syntax : SyntaxNode ,
1077
+ }
1078
+ impl MacroType {
1079
+ pub fn macro_call ( & self ) -> Option < MacroCall > { support:: child ( & self . syntax ) }
1080
+ }
1081
+ #[ derive( Debug , Clone , PartialEq , Eq , Hash ) ]
1075
1082
pub struct NeverType {
1076
1083
pub ( crate ) syntax : SyntaxNode ,
1077
1084
}
@@ -1300,6 +1307,7 @@ pub enum Type {
1300
1307
ForType ( ForType ) ,
1301
1308
ImplTraitType ( ImplTraitType ) ,
1302
1309
InferType ( InferType ) ,
1310
+ MacroType ( MacroType ) ,
1303
1311
NeverType ( NeverType ) ,
1304
1312
ParenType ( ParenType ) ,
1305
1313
PathType ( PathType ) ,
@@ -2558,6 +2566,17 @@ impl AstNode for InferType {
2558
2566
}
2559
2567
fn syntax ( & self ) -> & SyntaxNode { & self . syntax }
2560
2568
}
2569
+ impl AstNode for MacroType {
2570
+ fn can_cast ( kind : SyntaxKind ) -> bool { kind == MACRO_TYPE }
2571
+ fn cast ( syntax : SyntaxNode ) -> Option < Self > {
2572
+ if Self :: can_cast ( syntax. kind ( ) ) {
2573
+ Some ( Self { syntax } )
2574
+ } else {
2575
+ None
2576
+ }
2577
+ }
2578
+ fn syntax ( & self ) -> & SyntaxNode { & self . syntax }
2579
+ }
2561
2580
impl AstNode for NeverType {
2562
2581
fn can_cast ( kind : SyntaxKind ) -> bool { kind == NEVER_TYPE }
2563
2582
fn cast ( syntax : SyntaxNode ) -> Option < Self > {
@@ -2889,6 +2908,9 @@ impl From<ImplTraitType> for Type {
2889
2908
impl From < InferType > for Type {
2890
2909
fn from ( node : InferType ) -> Type { Type :: InferType ( node) }
2891
2910
}
2911
+ impl From < MacroType > for Type {
2912
+ fn from ( node : MacroType ) -> Type { Type :: MacroType ( node) }
2913
+ }
2892
2914
impl From < NeverType > for Type {
2893
2915
fn from ( node : NeverType ) -> Type { Type :: NeverType ( node) }
2894
2916
}
@@ -2914,8 +2936,8 @@ impl AstNode for Type {
2914
2936
fn can_cast ( kind : SyntaxKind ) -> bool {
2915
2937
match kind {
2916
2938
ARRAY_TYPE | DYN_TRAIT_TYPE | FN_PTR_TYPE | FOR_TYPE | IMPL_TRAIT_TYPE | INFER_TYPE
2917
- | NEVER_TYPE | PAREN_TYPE | PATH_TYPE | PTR_TYPE | REF_TYPE | SLICE_TYPE
2918
- | TUPLE_TYPE => true ,
2939
+ | MACRO_TYPE | NEVER_TYPE | PAREN_TYPE | PATH_TYPE | PTR_TYPE | REF_TYPE
2940
+ | SLICE_TYPE | TUPLE_TYPE => true ,
2919
2941
_ => false ,
2920
2942
}
2921
2943
}
@@ -2927,6 +2949,7 @@ impl AstNode for Type {
2927
2949
FOR_TYPE => Type :: ForType ( ForType { syntax } ) ,
2928
2950
IMPL_TRAIT_TYPE => Type :: ImplTraitType ( ImplTraitType { syntax } ) ,
2929
2951
INFER_TYPE => Type :: InferType ( InferType { syntax } ) ,
2952
+ MACRO_TYPE => Type :: MacroType ( MacroType { syntax } ) ,
2930
2953
NEVER_TYPE => Type :: NeverType ( NeverType { syntax } ) ,
2931
2954
PAREN_TYPE => Type :: ParenType ( ParenType { syntax } ) ,
2932
2955
PATH_TYPE => Type :: PathType ( PathType { syntax } ) ,
@@ -2946,6 +2969,7 @@ impl AstNode for Type {
2946
2969
Type :: ForType ( it) => & it. syntax ,
2947
2970
Type :: ImplTraitType ( it) => & it. syntax ,
2948
2971
Type :: InferType ( it) => & it. syntax ,
2972
+ Type :: MacroType ( it) => & it. syntax ,
2949
2973
Type :: NeverType ( it) => & it. syntax ,
2950
2974
Type :: ParenType ( it) => & it. syntax ,
2951
2975
Type :: PathType ( it) => & it. syntax ,
@@ -4082,6 +4106,11 @@ impl std::fmt::Display for InferType {
4082
4106
std:: fmt:: Display :: fmt ( self . syntax ( ) , f)
4083
4107
}
4084
4108
}
4109
+ impl std:: fmt:: Display for MacroType {
4110
+ fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
4111
+ std:: fmt:: Display :: fmt ( self . syntax ( ) , f)
4112
+ }
4113
+ }
4085
4114
impl std:: fmt:: Display for NeverType {
4086
4115
fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
4087
4116
std:: fmt:: Display :: fmt ( self . syntax ( ) , f)
0 commit comments