pub fn underscore_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![_]) }
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
+pub struct MacroType {
+ pub(crate) syntax: SyntaxNode,
+}
+impl MacroType {
+ pub fn macro_call(&self) -> Option<MacroCall> { support::child(&self.syntax) }
+}
+#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct NeverType {
pub(crate) syntax: SyntaxNode,
}
ForType(ForType),
ImplTraitType(ImplTraitType),
InferType(InferType),
+ MacroType(MacroType),
NeverType(NeverType),
ParenType(ParenType),
PathType(PathType),
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
+impl AstNode for MacroType {
+ fn can_cast(kind: SyntaxKind) -> bool { kind == MACRO_TYPE }
+ fn cast(syntax: SyntaxNode) -> Option<Self> {
+ if Self::can_cast(syntax.kind()) {
+ Some(Self { syntax })
+ } else {
+ None
+ }
+ }
+ fn syntax(&self) -> &SyntaxNode { &self.syntax }
+}
impl AstNode for NeverType {
fn can_cast(kind: SyntaxKind) -> bool { kind == NEVER_TYPE }
fn cast(syntax: SyntaxNode) -> Option<Self> {
impl From<InferType> for Type {
fn from(node: InferType) -> Type { Type::InferType(node) }
}
+impl From<MacroType> for Type {
+ fn from(node: MacroType) -> Type { Type::MacroType(node) }
+}
impl From<NeverType> for Type {
fn from(node: NeverType) -> Type { Type::NeverType(node) }
}
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
ARRAY_TYPE | DYN_TRAIT_TYPE | FN_PTR_TYPE | FOR_TYPE | IMPL_TRAIT_TYPE | INFER_TYPE
- | NEVER_TYPE | PAREN_TYPE | PATH_TYPE | PTR_TYPE | REF_TYPE | SLICE_TYPE
- | TUPLE_TYPE => true,
+ | MACRO_TYPE | NEVER_TYPE | PAREN_TYPE | PATH_TYPE | PTR_TYPE | REF_TYPE
+ | SLICE_TYPE | TUPLE_TYPE => true,
_ => false,
}
}
FOR_TYPE => Type::ForType(ForType { syntax }),
IMPL_TRAIT_TYPE => Type::ImplTraitType(ImplTraitType { syntax }),
INFER_TYPE => Type::InferType(InferType { syntax }),
+ MACRO_TYPE => Type::MacroType(MacroType { syntax }),
NEVER_TYPE => Type::NeverType(NeverType { syntax }),
PAREN_TYPE => Type::ParenType(ParenType { syntax }),
PATH_TYPE => Type::PathType(PathType { syntax }),
Type::ForType(it) => &it.syntax,
Type::ImplTraitType(it) => &it.syntax,
Type::InferType(it) => &it.syntax,
+ Type::MacroType(it) => &it.syntax,
Type::NeverType(it) => &it.syntax,
Type::ParenType(it) => &it.syntax,
Type::PathType(it) => &it.syntax,
std::fmt::Display::fmt(self.syntax(), f)
}
}
+impl std::fmt::Display for MacroType {
+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ std::fmt::Display::fmt(self.syntax(), f)
+ }
+}
impl std::fmt::Display for NeverType {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)