-// Generated file, do not edit by hand, see `crate/ra_tools/src/codegen`
+//! Generated file, do not edit by hand, see `crate/ra_tools/src/codegen`
use crate::{
ast::{self, AstChildren, AstNode},
}
}
impl Attr {
- pub fn value(&self) -> Option<TokenTree> {
+ pub fn path(&self) -> Option<Path> {
+ AstChildren::new(&self.syntax).next()
+ }
+ pub fn input(&self) -> Option<AttrInput> {
AstChildren::new(&self.syntax).next()
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
+pub enum AttrInput {
+ Literal(Literal),
+ TokenTree(TokenTree),
+}
+impl From<Literal> for AttrInput {
+ fn from(node: Literal) -> AttrInput {
+ AttrInput::Literal(node)
+ }
+}
+impl From<TokenTree> for AttrInput {
+ fn from(node: TokenTree) -> AttrInput {
+ AttrInput::TokenTree(node)
+ }
+}
+impl AstNode for AttrInput {
+ fn can_cast(kind: SyntaxKind) -> bool {
+ match kind {
+ LITERAL | TOKEN_TREE => true,
+ _ => false,
+ }
+ }
+ fn cast(syntax: SyntaxNode) -> Option<Self> {
+ let res = match syntax.kind() {
+ LITERAL => AttrInput::Literal(Literal { syntax }),
+ TOKEN_TREE => AttrInput::TokenTree(TokenTree { syntax }),
+ _ => return None,
+ };
+ Some(res)
+ }
+ fn syntax(&self) -> &SyntaxNode {
+ match self {
+ AttrInput::Literal(it) => &it.syntax,
+ AttrInput::TokenTree(it) => &it.syntax,
+ }
+ }
+}
+impl AttrInput {}
+#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct AwaitExpr {
pub(crate) syntax: SyntaxNode,
}
}
}
impl ast::AttrsOwner for Block {}
+impl ast::ModuleItemOwner for Block {}
impl Block {
pub fn statements(&self) -> AstChildren<Stmt> {
AstChildren::new(&self.syntax)
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
+pub struct BoxExpr {
+ pub(crate) syntax: SyntaxNode,
+}
+impl AstNode for BoxExpr {
+ fn can_cast(kind: SyntaxKind) -> bool {
+ match kind {
+ BOX_EXPR => true,
+ _ => false,
+ }
+ }
+ fn cast(syntax: SyntaxNode) -> Option<Self> {
+ if Self::can_cast(syntax.kind()) {
+ Some(Self { syntax })
+ } else {
+ None
+ }
+ }
+ fn syntax(&self) -> &SyntaxNode {
+ &self.syntax
+ }
+}
+impl BoxExpr {
+ pub fn expr(&self) -> Option<Expr> {
+ AstChildren::new(&self.syntax).next()
+ }
+}
+#[derive(Debug, Clone, PartialEq, Eq, Hash)]
+pub struct BoxPat {
+ pub(crate) syntax: SyntaxNode,
+}
+impl AstNode for BoxPat {
+ fn can_cast(kind: SyntaxKind) -> bool {
+ match kind {
+ BOX_PAT => true,
+ _ => false,
+ }
+ }
+ fn cast(syntax: SyntaxNode) -> Option<Self> {
+ if Self::can_cast(syntax.kind()) {
+ Some(Self { syntax })
+ } else {
+ None
+ }
+ }
+ fn syntax(&self) -> &SyntaxNode {
+ &self.syntax
+ }
+}
+impl BoxPat {
+ pub fn pat(&self) -> Option<Pat> {
+ AstChildren::new(&self.syntax).next()
+ }
+}
+#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct BreakExpr {
pub(crate) syntax: SyntaxNode,
}
}
impl ContinueExpr {}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
+pub struct DotDotPat {
+ pub(crate) syntax: SyntaxNode,
+}
+impl AstNode for DotDotPat {
+ fn can_cast(kind: SyntaxKind) -> bool {
+ match kind {
+ DOT_DOT_PAT => true,
+ _ => false,
+ }
+ }
+ fn cast(syntax: SyntaxNode) -> Option<Self> {
+ if Self::can_cast(syntax.kind()) {
+ Some(Self { syntax })
+ } else {
+ None
+ }
+ }
+ fn syntax(&self) -> &SyntaxNode {
+ &self.syntax
+ }
+}
+impl DotDotPat {}
+#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct DynTraitType {
pub(crate) syntax: SyntaxNode,
}
BlockExpr(BlockExpr),
ReturnExpr(ReturnExpr),
MatchExpr(MatchExpr),
- StructLit(StructLit),
+ RecordLit(RecordLit),
CallExpr(CallExpr),
IndexExpr(IndexExpr),
MethodCallExpr(MethodCallExpr),
BinExpr(BinExpr),
Literal(Literal),
MacroCall(MacroCall),
+ BoxExpr(BoxExpr),
}
impl From<TupleExpr> for Expr {
fn from(node: TupleExpr) -> Expr {
Expr::MatchExpr(node)
}
}
-impl From<StructLit> for Expr {
- fn from(node: StructLit) -> Expr {
- Expr::StructLit(node)
+impl From<RecordLit> for Expr {
+ fn from(node: RecordLit) -> Expr {
+ Expr::RecordLit(node)
}
}
impl From<CallExpr> for Expr {
Expr::MacroCall(node)
}
}
+impl From<BoxExpr> for Expr {
+ fn from(node: BoxExpr) -> Expr {
+ Expr::BoxExpr(node)
+ }
+}
impl AstNode for Expr {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
TUPLE_EXPR | ARRAY_EXPR | PAREN_EXPR | PATH_EXPR | LAMBDA_EXPR | IF_EXPR
| LOOP_EXPR | FOR_EXPR | WHILE_EXPR | CONTINUE_EXPR | BREAK_EXPR | LABEL
- | BLOCK_EXPR | RETURN_EXPR | MATCH_EXPR | STRUCT_LIT | CALL_EXPR | INDEX_EXPR
+ | BLOCK_EXPR | RETURN_EXPR | MATCH_EXPR | RECORD_LIT | CALL_EXPR | INDEX_EXPR
| METHOD_CALL_EXPR | FIELD_EXPR | AWAIT_EXPR | TRY_EXPR | TRY_BLOCK_EXPR
- | CAST_EXPR | REF_EXPR | PREFIX_EXPR | RANGE_EXPR | BIN_EXPR | LITERAL | MACRO_CALL => {
- true
- }
+ | CAST_EXPR | REF_EXPR | PREFIX_EXPR | RANGE_EXPR | BIN_EXPR | LITERAL | MACRO_CALL
+ | BOX_EXPR => true,
_ => false,
}
}
BLOCK_EXPR => Expr::BlockExpr(BlockExpr { syntax }),
RETURN_EXPR => Expr::ReturnExpr(ReturnExpr { syntax }),
MATCH_EXPR => Expr::MatchExpr(MatchExpr { syntax }),
- STRUCT_LIT => Expr::StructLit(StructLit { syntax }),
+ RECORD_LIT => Expr::RecordLit(RecordLit { syntax }),
CALL_EXPR => Expr::CallExpr(CallExpr { syntax }),
INDEX_EXPR => Expr::IndexExpr(IndexExpr { syntax }),
METHOD_CALL_EXPR => Expr::MethodCallExpr(MethodCallExpr { syntax }),
BIN_EXPR => Expr::BinExpr(BinExpr { syntax }),
LITERAL => Expr::Literal(Literal { syntax }),
MACRO_CALL => Expr::MacroCall(MacroCall { syntax }),
+ BOX_EXPR => Expr::BoxExpr(BoxExpr { syntax }),
_ => return None,
};
Some(res)
Expr::BlockExpr(it) => &it.syntax,
Expr::ReturnExpr(it) => &it.syntax,
Expr::MatchExpr(it) => &it.syntax,
- Expr::StructLit(it) => &it.syntax,
+ Expr::RecordLit(it) => &it.syntax,
Expr::CallExpr(it) => &it.syntax,
Expr::IndexExpr(it) => &it.syntax,
Expr::MethodCallExpr(it) => &it.syntax,
Expr::BinExpr(it) => &it.syntax,
Expr::Literal(it) => &it.syntax,
Expr::MacroCall(it) => &it.syntax,
+ Expr::BoxExpr(it) => &it.syntax,
}
}
}
&self.syntax
}
}
+impl ast::AttrsOwner for ExternCrateItem {}
impl ExternCrateItem {
pub fn name_ref(&self) -> Option<NameRef> {
AstChildren::new(&self.syntax).next()
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
-pub struct FieldPat {
- pub(crate) syntax: SyntaxNode,
-}
-impl AstNode for FieldPat {
- fn can_cast(kind: SyntaxKind) -> bool {
- match kind {
- FIELD_PAT => true,
- _ => false,
- }
- }
- fn cast(syntax: SyntaxNode) -> Option<Self> {
- if Self::can_cast(syntax.kind()) {
- Some(Self { syntax })
- } else {
- None
- }
- }
- fn syntax(&self) -> &SyntaxNode {
- &self.syntax
- }
-}
-impl ast::NameOwner for FieldPat {}
-impl FieldPat {
- pub fn pat(&self) -> Option<Pat> {
- AstChildren::new(&self.syntax).next()
- }
-}
-#[derive(Debug, Clone, PartialEq, Eq, Hash)]
-pub struct FieldPatList {
- pub(crate) syntax: SyntaxNode,
-}
-impl AstNode for FieldPatList {
- fn can_cast(kind: SyntaxKind) -> bool {
- match kind {
- FIELD_PAT_LIST => true,
- _ => false,
- }
- }
- fn cast(syntax: SyntaxNode) -> Option<Self> {
- if Self::can_cast(syntax.kind()) {
- Some(Self { syntax })
- } else {
- None
- }
- }
- fn syntax(&self) -> &SyntaxNode {
- &self.syntax
- }
-}
-impl FieldPatList {
- pub fn field_pats(&self) -> AstChildren<FieldPat> {
- AstChildren::new(&self.syntax)
- }
- pub fn bind_pats(&self) -> AstChildren<BindPat> {
- AstChildren::new(&self.syntax)
- }
-}
-#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct FnDef {
pub(crate) syntax: SyntaxNode,
}
pub fn param_list(&self) -> Option<ParamList> {
AstChildren::new(&self.syntax).next()
}
- pub fn body(&self) -> Option<Block> {
+ pub fn body(&self) -> Option<BlockExpr> {
AstChildren::new(&self.syntax).next()
}
pub fn ret_type(&self) -> Option<RetType> {
}
}
}
+impl ast::AttrsOwner for ImplItem {}
impl ImplItem {}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct ImplTraitType {
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum ModuleItem {
StructDef(StructDef),
+ UnionDef(UnionDef),
EnumDef(EnumDef),
FnDef(FnDef),
TraitDef(TraitDef),
ModuleItem::StructDef(node)
}
}
+impl From<UnionDef> for ModuleItem {
+ fn from(node: UnionDef) -> ModuleItem {
+ ModuleItem::UnionDef(node)
+ }
+}
impl From<EnumDef> for ModuleItem {
fn from(node: EnumDef) -> ModuleItem {
ModuleItem::EnumDef(node)
impl AstNode for ModuleItem {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
- STRUCT_DEF | ENUM_DEF | FN_DEF | TRAIT_DEF | TYPE_ALIAS_DEF | IMPL_BLOCK | USE_ITEM
- | EXTERN_CRATE_ITEM | CONST_DEF | STATIC_DEF | MODULE => true,
+ STRUCT_DEF | UNION_DEF | ENUM_DEF | FN_DEF | TRAIT_DEF | TYPE_ALIAS_DEF
+ | IMPL_BLOCK | USE_ITEM | EXTERN_CRATE_ITEM | CONST_DEF | STATIC_DEF | MODULE => true,
_ => false,
}
}
fn cast(syntax: SyntaxNode) -> Option<Self> {
let res = match syntax.kind() {
STRUCT_DEF => ModuleItem::StructDef(StructDef { syntax }),
+ UNION_DEF => ModuleItem::UnionDef(UnionDef { syntax }),
ENUM_DEF => ModuleItem::EnumDef(EnumDef { syntax }),
FN_DEF => ModuleItem::FnDef(FnDef { syntax }),
TRAIT_DEF => ModuleItem::TraitDef(TraitDef { syntax }),
fn syntax(&self) -> &SyntaxNode {
match self {
ModuleItem::StructDef(it) => &it.syntax,
+ ModuleItem::UnionDef(it) => &it.syntax,
ModuleItem::EnumDef(it) => &it.syntax,
ModuleItem::FnDef(it) => &it.syntax,
ModuleItem::TraitDef(it) => &it.syntax,
}
}
}
+impl ast::AttrsOwner for ModuleItem {}
impl ModuleItem {}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct Name {
}
impl NameRef {}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
-pub struct NamedField {
- pub(crate) syntax: SyntaxNode,
-}
-impl AstNode for NamedField {
- fn can_cast(kind: SyntaxKind) -> bool {
- match kind {
- NAMED_FIELD => true,
- _ => false,
- }
- }
- fn cast(syntax: SyntaxNode) -> Option<Self> {
- if Self::can_cast(syntax.kind()) {
- Some(Self { syntax })
- } else {
- None
- }
- }
- fn syntax(&self) -> &SyntaxNode {
- &self.syntax
- }
-}
-impl NamedField {
- pub fn name_ref(&self) -> Option<NameRef> {
- AstChildren::new(&self.syntax).next()
- }
- pub fn expr(&self) -> Option<Expr> {
- AstChildren::new(&self.syntax).next()
- }
-}
-#[derive(Debug, Clone, PartialEq, Eq, Hash)]
-pub struct NamedFieldDef {
- pub(crate) syntax: SyntaxNode,
-}
-impl AstNode for NamedFieldDef {
- fn can_cast(kind: SyntaxKind) -> bool {
- match kind {
- NAMED_FIELD_DEF => true,
- _ => false,
- }
- }
- fn cast(syntax: SyntaxNode) -> Option<Self> {
- if Self::can_cast(syntax.kind()) {
- Some(Self { syntax })
- } else {
- None
- }
- }
- fn syntax(&self) -> &SyntaxNode {
- &self.syntax
- }
-}
-impl ast::VisibilityOwner for NamedFieldDef {}
-impl ast::NameOwner for NamedFieldDef {}
-impl ast::AttrsOwner for NamedFieldDef {}
-impl ast::DocCommentsOwner for NamedFieldDef {}
-impl ast::TypeAscriptionOwner for NamedFieldDef {}
-impl NamedFieldDef {}
-#[derive(Debug, Clone, PartialEq, Eq, Hash)]
-pub struct NamedFieldDefList {
- pub(crate) syntax: SyntaxNode,
-}
-impl AstNode for NamedFieldDefList {
- fn can_cast(kind: SyntaxKind) -> bool {
- match kind {
- NAMED_FIELD_DEF_LIST => true,
- _ => false,
- }
- }
- fn cast(syntax: SyntaxNode) -> Option<Self> {
- if Self::can_cast(syntax.kind()) {
- Some(Self { syntax })
- } else {
- None
- }
- }
- fn syntax(&self) -> &SyntaxNode {
- &self.syntax
- }
-}
-impl NamedFieldDefList {
- pub fn fields(&self) -> AstChildren<NamedFieldDef> {
- AstChildren::new(&self.syntax)
- }
-}
-#[derive(Debug, Clone, PartialEq, Eq, Hash)]
-pub struct NamedFieldList {
- pub(crate) syntax: SyntaxNode,
-}
-impl AstNode for NamedFieldList {
- fn can_cast(kind: SyntaxKind) -> bool {
- match kind {
- NAMED_FIELD_LIST => true,
- _ => false,
- }
- }
- fn cast(syntax: SyntaxNode) -> Option<Self> {
- if Self::can_cast(syntax.kind()) {
- Some(Self { syntax })
- } else {
- None
- }
- }
- fn syntax(&self) -> &SyntaxNode {
- &self.syntax
- }
-}
-impl NamedFieldList {
- pub fn fields(&self) -> AstChildren<NamedField> {
- AstChildren::new(&self.syntax)
- }
- pub fn spread(&self) -> Option<Expr> {
- AstChildren::new(&self.syntax).next()
- }
-}
-#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct NeverType {
pub(crate) syntax: SyntaxNode,
}
pub enum NominalDef {
StructDef(StructDef),
EnumDef(EnumDef),
+ UnionDef(UnionDef),
}
impl From<StructDef> for NominalDef {
fn from(node: StructDef) -> NominalDef {
NominalDef::EnumDef(node)
}
}
+impl From<UnionDef> for NominalDef {
+ fn from(node: UnionDef) -> NominalDef {
+ NominalDef::UnionDef(node)
+ }
+}
impl AstNode for NominalDef {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
- STRUCT_DEF | ENUM_DEF => true,
+ STRUCT_DEF | ENUM_DEF | UNION_DEF => true,
_ => false,
}
}
let res = match syntax.kind() {
STRUCT_DEF => NominalDef::StructDef(StructDef { syntax }),
ENUM_DEF => NominalDef::EnumDef(EnumDef { syntax }),
+ UNION_DEF => NominalDef::UnionDef(UnionDef { syntax }),
_ => return None,
};
Some(res)
match self {
NominalDef::StructDef(it) => &it.syntax,
NominalDef::EnumDef(it) => &it.syntax,
+ NominalDef::UnionDef(it) => &it.syntax,
}
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum Pat {
RefPat(RefPat),
+ BoxPat(BoxPat),
BindPat(BindPat),
PlaceholderPat(PlaceholderPat),
+ DotDotPat(DotDotPat),
PathPat(PathPat),
- StructPat(StructPat),
+ RecordPat(RecordPat),
TupleStructPat(TupleStructPat),
TuplePat(TuplePat),
SlicePat(SlicePat),
Pat::RefPat(node)
}
}
+impl From<BoxPat> for Pat {
+ fn from(node: BoxPat) -> Pat {
+ Pat::BoxPat(node)
+ }
+}
impl From<BindPat> for Pat {
fn from(node: BindPat) -> Pat {
Pat::BindPat(node)
Pat::PlaceholderPat(node)
}
}
+impl From<DotDotPat> for Pat {
+ fn from(node: DotDotPat) -> Pat {
+ Pat::DotDotPat(node)
+ }
+}
impl From<PathPat> for Pat {
fn from(node: PathPat) -> Pat {
Pat::PathPat(node)
}
}
-impl From<StructPat> for Pat {
- fn from(node: StructPat) -> Pat {
- Pat::StructPat(node)
+impl From<RecordPat> for Pat {
+ fn from(node: RecordPat) -> Pat {
+ Pat::RecordPat(node)
}
}
impl From<TupleStructPat> for Pat {
impl AstNode for Pat {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
- REF_PAT | BIND_PAT | PLACEHOLDER_PAT | PATH_PAT | STRUCT_PAT | TUPLE_STRUCT_PAT
- | TUPLE_PAT | SLICE_PAT | RANGE_PAT | LITERAL_PAT => true,
+ REF_PAT | BOX_PAT | BIND_PAT | PLACEHOLDER_PAT | DOT_DOT_PAT | PATH_PAT
+ | RECORD_PAT | TUPLE_STRUCT_PAT | TUPLE_PAT | SLICE_PAT | RANGE_PAT | LITERAL_PAT => {
+ true
+ }
_ => false,
}
}
fn cast(syntax: SyntaxNode) -> Option<Self> {
let res = match syntax.kind() {
REF_PAT => Pat::RefPat(RefPat { syntax }),
+ BOX_PAT => Pat::BoxPat(BoxPat { syntax }),
BIND_PAT => Pat::BindPat(BindPat { syntax }),
PLACEHOLDER_PAT => Pat::PlaceholderPat(PlaceholderPat { syntax }),
+ DOT_DOT_PAT => Pat::DotDotPat(DotDotPat { syntax }),
PATH_PAT => Pat::PathPat(PathPat { syntax }),
- STRUCT_PAT => Pat::StructPat(StructPat { syntax }),
+ RECORD_PAT => Pat::RecordPat(RecordPat { syntax }),
TUPLE_STRUCT_PAT => Pat::TupleStructPat(TupleStructPat { syntax }),
TUPLE_PAT => Pat::TuplePat(TuplePat { syntax }),
SLICE_PAT => Pat::SlicePat(SlicePat { syntax }),
fn syntax(&self) -> &SyntaxNode {
match self {
Pat::RefPat(it) => &it.syntax,
+ Pat::BoxPat(it) => &it.syntax,
Pat::BindPat(it) => &it.syntax,
Pat::PlaceholderPat(it) => &it.syntax,
+ Pat::DotDotPat(it) => &it.syntax,
Pat::PathPat(it) => &it.syntax,
- Pat::StructPat(it) => &it.syntax,
+ Pat::RecordPat(it) => &it.syntax,
Pat::TupleStructPat(it) => &it.syntax,
Pat::TuplePat(it) => &it.syntax,
Pat::SlicePat(it) => &it.syntax,
pub fn type_arg_list(&self) -> Option<TypeArgList> {
AstChildren::new(&self.syntax).next()
}
+ pub fn param_list(&self) -> Option<ParamList> {
+ AstChildren::new(&self.syntax).next()
+ }
+ pub fn ret_type(&self) -> Option<RetType> {
+ AstChildren::new(&self.syntax).next()
+ }
+ pub fn path_type(&self) -> Option<PathType> {
+ AstChildren::new(&self.syntax).next()
+ }
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct PathType {
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
-pub struct PosFieldDef {
+pub struct PrefixExpr {
pub(crate) syntax: SyntaxNode,
}
-impl AstNode for PosFieldDef {
+impl AstNode for PrefixExpr {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
- POS_FIELD_DEF => true,
+ PREFIX_EXPR => true,
_ => false,
}
}
&self.syntax
}
}
-impl ast::VisibilityOwner for PosFieldDef {}
-impl ast::AttrsOwner for PosFieldDef {}
-impl PosFieldDef {
- pub fn type_ref(&self) -> Option<TypeRef> {
+impl PrefixExpr {
+ pub fn expr(&self) -> Option<Expr> {
AstChildren::new(&self.syntax).next()
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
-pub struct PosFieldDefList {
+pub struct RangeExpr {
pub(crate) syntax: SyntaxNode,
}
-impl AstNode for PosFieldDefList {
+impl AstNode for RangeExpr {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
- POS_FIELD_DEF_LIST => true,
+ RANGE_EXPR => true,
_ => false,
}
}
&self.syntax
}
}
-impl PosFieldDefList {
- pub fn fields(&self) -> AstChildren<PosFieldDef> {
- AstChildren::new(&self.syntax)
+impl RangeExpr {}
+#[derive(Debug, Clone, PartialEq, Eq, Hash)]
+pub struct RangePat {
+ pub(crate) syntax: SyntaxNode,
+}
+impl AstNode for RangePat {
+ fn can_cast(kind: SyntaxKind) -> bool {
+ match kind {
+ RANGE_PAT => true,
+ _ => false,
+ }
+ }
+ fn cast(syntax: SyntaxNode) -> Option<Self> {
+ if Self::can_cast(syntax.kind()) {
+ Some(Self { syntax })
+ } else {
+ None
+ }
+ }
+ fn syntax(&self) -> &SyntaxNode {
+ &self.syntax
}
}
+impl RangePat {}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
-pub struct PrefixExpr {
+pub struct RecordField {
pub(crate) syntax: SyntaxNode,
}
-impl AstNode for PrefixExpr {
+impl AstNode for RecordField {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
- PREFIX_EXPR => true,
+ RECORD_FIELD => true,
_ => false,
}
}
&self.syntax
}
}
-impl PrefixExpr {
+impl RecordField {
+ pub fn name_ref(&self) -> Option<NameRef> {
+ AstChildren::new(&self.syntax).next()
+ }
pub fn expr(&self) -> Option<Expr> {
AstChildren::new(&self.syntax).next()
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
-pub struct RangeExpr {
+pub struct RecordFieldDef {
pub(crate) syntax: SyntaxNode,
}
-impl AstNode for RangeExpr {
+impl AstNode for RecordFieldDef {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
- RANGE_EXPR => true,
+ RECORD_FIELD_DEF => true,
_ => false,
}
}
&self.syntax
}
}
-impl RangeExpr {}
+impl ast::VisibilityOwner for RecordFieldDef {}
+impl ast::NameOwner for RecordFieldDef {}
+impl ast::AttrsOwner for RecordFieldDef {}
+impl ast::DocCommentsOwner for RecordFieldDef {}
+impl ast::TypeAscriptionOwner for RecordFieldDef {}
+impl RecordFieldDef {}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
-pub struct RangePat {
+pub struct RecordFieldDefList {
pub(crate) syntax: SyntaxNode,
}
-impl AstNode for RangePat {
+impl AstNode for RecordFieldDefList {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
- RANGE_PAT => true,
+ RECORD_FIELD_DEF_LIST => true,
_ => false,
}
}
&self.syntax
}
}
-impl RangePat {}
+impl RecordFieldDefList {
+ pub fn fields(&self) -> AstChildren<RecordFieldDef> {
+ AstChildren::new(&self.syntax)
+ }
+}
+#[derive(Debug, Clone, PartialEq, Eq, Hash)]
+pub struct RecordFieldList {
+ pub(crate) syntax: SyntaxNode,
+}
+impl AstNode for RecordFieldList {
+ fn can_cast(kind: SyntaxKind) -> bool {
+ match kind {
+ RECORD_FIELD_LIST => true,
+ _ => false,
+ }
+ }
+ fn cast(syntax: SyntaxNode) -> Option<Self> {
+ if Self::can_cast(syntax.kind()) {
+ Some(Self { syntax })
+ } else {
+ None
+ }
+ }
+ fn syntax(&self) -> &SyntaxNode {
+ &self.syntax
+ }
+}
+impl RecordFieldList {
+ pub fn fields(&self) -> AstChildren<RecordField> {
+ AstChildren::new(&self.syntax)
+ }
+ pub fn spread(&self) -> Option<Expr> {
+ AstChildren::new(&self.syntax).next()
+ }
+}
+#[derive(Debug, Clone, PartialEq, Eq, Hash)]
+pub struct RecordFieldPat {
+ pub(crate) syntax: SyntaxNode,
+}
+impl AstNode for RecordFieldPat {
+ fn can_cast(kind: SyntaxKind) -> bool {
+ match kind {
+ RECORD_FIELD_PAT => true,
+ _ => false,
+ }
+ }
+ fn cast(syntax: SyntaxNode) -> Option<Self> {
+ if Self::can_cast(syntax.kind()) {
+ Some(Self { syntax })
+ } else {
+ None
+ }
+ }
+ fn syntax(&self) -> &SyntaxNode {
+ &self.syntax
+ }
+}
+impl ast::NameOwner for RecordFieldPat {}
+impl RecordFieldPat {
+ pub fn pat(&self) -> Option<Pat> {
+ AstChildren::new(&self.syntax).next()
+ }
+}
+#[derive(Debug, Clone, PartialEq, Eq, Hash)]
+pub struct RecordFieldPatList {
+ pub(crate) syntax: SyntaxNode,
+}
+impl AstNode for RecordFieldPatList {
+ fn can_cast(kind: SyntaxKind) -> bool {
+ match kind {
+ RECORD_FIELD_PAT_LIST => true,
+ _ => false,
+ }
+ }
+ fn cast(syntax: SyntaxNode) -> Option<Self> {
+ if Self::can_cast(syntax.kind()) {
+ Some(Self { syntax })
+ } else {
+ None
+ }
+ }
+ fn syntax(&self) -> &SyntaxNode {
+ &self.syntax
+ }
+}
+impl RecordFieldPatList {
+ pub fn record_field_pats(&self) -> AstChildren<RecordFieldPat> {
+ AstChildren::new(&self.syntax)
+ }
+ pub fn bind_pats(&self) -> AstChildren<BindPat> {
+ AstChildren::new(&self.syntax)
+ }
+}
+#[derive(Debug, Clone, PartialEq, Eq, Hash)]
+pub struct RecordLit {
+ pub(crate) syntax: SyntaxNode,
+}
+impl AstNode for RecordLit {
+ fn can_cast(kind: SyntaxKind) -> bool {
+ match kind {
+ RECORD_LIT => true,
+ _ => false,
+ }
+ }
+ fn cast(syntax: SyntaxNode) -> Option<Self> {
+ if Self::can_cast(syntax.kind()) {
+ Some(Self { syntax })
+ } else {
+ None
+ }
+ }
+ fn syntax(&self) -> &SyntaxNode {
+ &self.syntax
+ }
+}
+impl RecordLit {
+ pub fn path(&self) -> Option<Path> {
+ AstChildren::new(&self.syntax).next()
+ }
+ pub fn record_field_list(&self) -> Option<RecordFieldList> {
+ AstChildren::new(&self.syntax).next()
+ }
+}
+#[derive(Debug, Clone, PartialEq, Eq, Hash)]
+pub struct RecordPat {
+ pub(crate) syntax: SyntaxNode,
+}
+impl AstNode for RecordPat {
+ fn can_cast(kind: SyntaxKind) -> bool {
+ match kind {
+ RECORD_PAT => true,
+ _ => false,
+ }
+ }
+ fn cast(syntax: SyntaxNode) -> Option<Self> {
+ if Self::can_cast(syntax.kind()) {
+ Some(Self { syntax })
+ } else {
+ None
+ }
+ }
+ fn syntax(&self) -> &SyntaxNode {
+ &self.syntax
+ }
+}
+impl RecordPat {
+ pub fn record_field_pat_list(&self) -> Option<RecordFieldPatList> {
+ AstChildren::new(&self.syntax).next()
+ }
+ pub fn path(&self) -> Option<Path> {
+ AstChildren::new(&self.syntax).next()
+ }
+}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct RefExpr {
pub(crate) syntax: SyntaxNode,
impl ast::DocCommentsOwner for StructDef {}
impl StructDef {}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
-pub struct StructLit {
+pub struct TokenTree {
pub(crate) syntax: SyntaxNode,
}
-impl AstNode for StructLit {
+impl AstNode for TokenTree {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
- STRUCT_LIT => true,
+ TOKEN_TREE => true,
_ => false,
}
}
&self.syntax
}
}
-impl StructLit {
- pub fn path(&self) -> Option<Path> {
- AstChildren::new(&self.syntax).next()
- }
- pub fn named_field_list(&self) -> Option<NamedFieldList> {
- AstChildren::new(&self.syntax).next()
- }
-}
+impl TokenTree {}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
-pub struct StructPat {
+pub struct TraitDef {
pub(crate) syntax: SyntaxNode,
}
-impl AstNode for StructPat {
+impl AstNode for TraitDef {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
- STRUCT_PAT => true,
+ TRAIT_DEF => true,
_ => false,
}
}
&self.syntax
}
}
-impl StructPat {
- pub fn field_pat_list(&self) -> Option<FieldPatList> {
- AstChildren::new(&self.syntax).next()
- }
- pub fn path(&self) -> Option<Path> {
+impl ast::VisibilityOwner for TraitDef {}
+impl ast::NameOwner for TraitDef {}
+impl ast::AttrsOwner for TraitDef {}
+impl ast::DocCommentsOwner for TraitDef {}
+impl ast::TypeParamsOwner for TraitDef {}
+impl ast::TypeBoundsOwner for TraitDef {}
+impl TraitDef {
+ pub fn item_list(&self) -> Option<ItemList> {
AstChildren::new(&self.syntax).next()
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
-pub struct TokenTree {
+pub struct TryBlockExpr {
pub(crate) syntax: SyntaxNode,
}
-impl AstNode for TokenTree {
+impl AstNode for TryBlockExpr {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
- TOKEN_TREE => true,
+ TRY_BLOCK_EXPR => true,
_ => false,
}
}
&self.syntax
}
}
-impl TokenTree {}
+impl TryBlockExpr {
+ pub fn body(&self) -> Option<BlockExpr> {
+ AstChildren::new(&self.syntax).next()
+ }
+}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
-pub struct TraitDef {
+pub struct TryExpr {
pub(crate) syntax: SyntaxNode,
}
-impl AstNode for TraitDef {
+impl AstNode for TryExpr {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
- TRAIT_DEF => true,
+ TRY_EXPR => true,
_ => false,
}
}
&self.syntax
}
}
-impl ast::VisibilityOwner for TraitDef {}
-impl ast::NameOwner for TraitDef {}
-impl ast::AttrsOwner for TraitDef {}
-impl ast::DocCommentsOwner for TraitDef {}
-impl ast::TypeParamsOwner for TraitDef {}
-impl ast::TypeBoundsOwner for TraitDef {}
-impl TraitDef {
- pub fn item_list(&self) -> Option<ItemList> {
+impl TryExpr {
+ pub fn expr(&self) -> Option<Expr> {
AstChildren::new(&self.syntax).next()
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
-pub struct TryBlockExpr {
+pub struct TupleExpr {
pub(crate) syntax: SyntaxNode,
}
-impl AstNode for TryBlockExpr {
+impl AstNode for TupleExpr {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
- TRY_BLOCK_EXPR => true,
+ TUPLE_EXPR => true,
_ => false,
}
}
&self.syntax
}
}
-impl ast::TryBlockBodyOwner for TryBlockExpr {}
-impl TryBlockExpr {}
+impl TupleExpr {
+ pub fn exprs(&self) -> AstChildren<Expr> {
+ AstChildren::new(&self.syntax)
+ }
+}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
-pub struct TryExpr {
+pub struct TupleFieldDef {
pub(crate) syntax: SyntaxNode,
}
-impl AstNode for TryExpr {
+impl AstNode for TupleFieldDef {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
- TRY_EXPR => true,
+ TUPLE_FIELD_DEF => true,
_ => false,
}
}
&self.syntax
}
}
-impl TryExpr {
- pub fn expr(&self) -> Option<Expr> {
+impl ast::VisibilityOwner for TupleFieldDef {}
+impl ast::AttrsOwner for TupleFieldDef {}
+impl TupleFieldDef {
+ pub fn type_ref(&self) -> Option<TypeRef> {
AstChildren::new(&self.syntax).next()
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
-pub struct TupleExpr {
+pub struct TupleFieldDefList {
pub(crate) syntax: SyntaxNode,
}
-impl AstNode for TupleExpr {
+impl AstNode for TupleFieldDefList {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
- TUPLE_EXPR => true,
+ TUPLE_FIELD_DEF_LIST => true,
_ => false,
}
}
&self.syntax
}
}
-impl TupleExpr {
- pub fn exprs(&self) -> AstChildren<Expr> {
+impl TupleFieldDefList {
+ pub fn fields(&self) -> AstChildren<TupleFieldDef> {
AstChildren::new(&self.syntax)
}
}
impl ast::NameOwner for TypeParam {}
impl ast::AttrsOwner for TypeParam {}
impl ast::TypeBoundsOwner for TypeParam {}
-impl ast::DefaultTypeParamOwner for TypeParam {}
-impl TypeParam {}
+impl TypeParam {
+ pub fn default_type(&self) -> Option<TypeRef> {
+ AstChildren::new(&self.syntax).next()
+ }
+}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct TypeParamList {
pub(crate) syntax: SyntaxNode,
}
impl TypeRef {}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
+pub struct UnionDef {
+ pub(crate) syntax: SyntaxNode,
+}
+impl AstNode for UnionDef {
+ fn can_cast(kind: SyntaxKind) -> bool {
+ match kind {
+ UNION_DEF => true,
+ _ => false,
+ }
+ }
+ fn cast(syntax: SyntaxNode) -> Option<Self> {
+ if Self::can_cast(syntax.kind()) {
+ Some(Self { syntax })
+ } else {
+ None
+ }
+ }
+ fn syntax(&self) -> &SyntaxNode {
+ &self.syntax
+ }
+}
+impl ast::VisibilityOwner for UnionDef {}
+impl ast::NameOwner for UnionDef {}
+impl ast::TypeParamsOwner for UnionDef {}
+impl ast::AttrsOwner for UnionDef {}
+impl ast::DocCommentsOwner for UnionDef {}
+impl UnionDef {
+ pub fn record_field_def_list(&self) -> Option<RecordFieldDefList> {
+ AstChildren::new(&self.syntax).next()
+ }
+}
+#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct UseItem {
pub(crate) syntax: SyntaxNode,
}