mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 12:54:58 +00:00
Rename FnDef -> Fn
This commit is contained in:
parent
3e1e6227ca
commit
1142112c70
244 changed files with 683 additions and 675 deletions
|
@ -79,19 +79,19 @@ impl ExternCrate {
|
|||
pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
|
||||
}
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
pub struct FnDef {
|
||||
pub struct Fn {
|
||||
pub(crate) syntax: SyntaxNode,
|
||||
}
|
||||
impl ast::AttrsOwner for FnDef {}
|
||||
impl ast::NameOwner for FnDef {}
|
||||
impl ast::VisibilityOwner for FnDef {}
|
||||
impl ast::TypeParamsOwner for FnDef {}
|
||||
impl FnDef {
|
||||
pub fn abi(&self) -> Option<Abi> { support::child(&self.syntax) }
|
||||
pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) }
|
||||
impl ast::AttrsOwner for Fn {}
|
||||
impl ast::NameOwner for Fn {}
|
||||
impl ast::VisibilityOwner for Fn {}
|
||||
impl ast::TypeParamsOwner for Fn {}
|
||||
impl Fn {
|
||||
pub fn default_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![default]) }
|
||||
pub fn async_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![async]) }
|
||||
pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) }
|
||||
pub fn unsafe_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![unsafe]) }
|
||||
pub fn abi(&self) -> Option<Abi> { support::child(&self.syntax) }
|
||||
pub fn fn_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![fn]) }
|
||||
pub fn param_list(&self) -> Option<ParamList> { support::child(&self.syntax) }
|
||||
pub fn ret_type(&self) -> Option<RetType> { support::child(&self.syntax) }
|
||||
|
@ -303,7 +303,9 @@ impl UseTreeList {
|
|||
pub struct Abi {
|
||||
pub(crate) syntax: SyntaxNode,
|
||||
}
|
||||
impl Abi {}
|
||||
impl Abi {
|
||||
pub fn extern_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![extern]) }
|
||||
}
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
pub struct TypeParamList {
|
||||
pub(crate) syntax: SyntaxNode,
|
||||
|
@ -321,8 +323,9 @@ pub struct ParamList {
|
|||
}
|
||||
impl ParamList {
|
||||
pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) }
|
||||
pub fn self_param(&self) -> Option<SelfParam> { support::child(&self.syntax) }
|
||||
pub fn params(&self) -> AstChildren<Param> { support::children(&self.syntax) }
|
||||
pub fn self_param(&self) -> Option<SelfParam> { support::child(&self.syntax) }
|
||||
pub fn comma_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![,]) }
|
||||
pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
|
||||
}
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
|
@ -355,6 +358,32 @@ impl BlockExpr {
|
|||
pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) }
|
||||
}
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
pub struct Param {
|
||||
pub(crate) syntax: SyntaxNode,
|
||||
}
|
||||
impl ast::AttrsOwner for Param {}
|
||||
impl ast::TypeAscriptionOwner for Param {}
|
||||
impl Param {
|
||||
pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
|
||||
pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) }
|
||||
pub fn dotdotdot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![...]) }
|
||||
}
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
pub struct SelfParam {
|
||||
pub(crate) syntax: SyntaxNode,
|
||||
}
|
||||
impl ast::AttrsOwner for SelfParam {}
|
||||
impl ast::TypeAscriptionOwner for SelfParam {}
|
||||
impl SelfParam {
|
||||
pub fn amp_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![&]) }
|
||||
pub fn lifetime_token(&self) -> Option<SyntaxToken> {
|
||||
support::token(&self.syntax, T![lifetime])
|
||||
}
|
||||
pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) }
|
||||
pub fn self_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![self]) }
|
||||
pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) }
|
||||
}
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
pub struct RecordFieldDefList {
|
||||
pub(crate) syntax: SyntaxNode,
|
||||
}
|
||||
|
@ -1173,32 +1202,6 @@ impl LetStmt {
|
|||
pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
|
||||
}
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
pub struct SelfParam {
|
||||
pub(crate) syntax: SyntaxNode,
|
||||
}
|
||||
impl ast::AttrsOwner for SelfParam {}
|
||||
impl ast::TypeAscriptionOwner for SelfParam {}
|
||||
impl SelfParam {
|
||||
pub fn amp_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![&]) }
|
||||
pub fn lifetime_token(&self) -> Option<SyntaxToken> {
|
||||
support::token(&self.syntax, T![lifetime])
|
||||
}
|
||||
pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) }
|
||||
pub fn self_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![self]) }
|
||||
pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) }
|
||||
}
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
pub struct Param {
|
||||
pub(crate) syntax: SyntaxNode,
|
||||
}
|
||||
impl ast::AttrsOwner for Param {}
|
||||
impl ast::TypeAscriptionOwner for Param {}
|
||||
impl Param {
|
||||
pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
|
||||
pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) }
|
||||
pub fn dotdotdot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![...]) }
|
||||
}
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
pub struct PathSegment {
|
||||
pub(crate) syntax: SyntaxNode,
|
||||
}
|
||||
|
@ -1274,7 +1277,7 @@ pub enum Item {
|
|||
EnumDef(EnumDef),
|
||||
ExternBlock(ExternBlock),
|
||||
ExternCrate(ExternCrate),
|
||||
FnDef(FnDef),
|
||||
Fn(Fn),
|
||||
ImplDef(ImplDef),
|
||||
MacroCall(MacroCall),
|
||||
Module(Module),
|
||||
|
@ -1303,6 +1306,24 @@ pub enum TypeRef {
|
|||
DynTraitType(DynTraitType),
|
||||
}
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
pub enum Pat {
|
||||
OrPat(OrPat),
|
||||
ParenPat(ParenPat),
|
||||
RefPat(RefPat),
|
||||
BoxPat(BoxPat),
|
||||
BindPat(BindPat),
|
||||
PlaceholderPat(PlaceholderPat),
|
||||
DotDotPat(DotDotPat),
|
||||
PathPat(PathPat),
|
||||
RecordPat(RecordPat),
|
||||
TupleStructPat(TupleStructPat),
|
||||
TuplePat(TuplePat),
|
||||
SlicePat(SlicePat),
|
||||
RangePat(RangePat),
|
||||
LiteralPat(LiteralPat),
|
||||
MacroPat(MacroPat),
|
||||
}
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
pub enum FieldDefList {
|
||||
RecordFieldDefList(RecordFieldDefList),
|
||||
TupleFieldDefList(TupleFieldDefList),
|
||||
|
@ -1343,7 +1364,7 @@ pub enum Expr {
|
|||
}
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
pub enum AssocItem {
|
||||
FnDef(FnDef),
|
||||
Fn(Fn),
|
||||
TypeAliasDef(TypeAliasDef),
|
||||
ConstDef(ConstDef),
|
||||
MacroCall(MacroCall),
|
||||
|
@ -1351,24 +1372,6 @@ pub enum AssocItem {
|
|||
impl ast::AttrsOwner for AssocItem {}
|
||||
impl ast::NameOwner for AssocItem {}
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
pub enum Pat {
|
||||
OrPat(OrPat),
|
||||
ParenPat(ParenPat),
|
||||
RefPat(RefPat),
|
||||
BoxPat(BoxPat),
|
||||
BindPat(BindPat),
|
||||
PlaceholderPat(PlaceholderPat),
|
||||
DotDotPat(DotDotPat),
|
||||
PathPat(PathPat),
|
||||
RecordPat(RecordPat),
|
||||
TupleStructPat(TupleStructPat),
|
||||
TuplePat(TuplePat),
|
||||
SlicePat(SlicePat),
|
||||
RangePat(RangePat),
|
||||
LiteralPat(LiteralPat),
|
||||
MacroPat(MacroPat),
|
||||
}
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
pub enum Stmt {
|
||||
LetStmt(LetStmt),
|
||||
ExprStmt(ExprStmt),
|
||||
|
@ -1381,7 +1384,7 @@ pub enum AttrInput {
|
|||
}
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
pub enum ExternItem {
|
||||
FnDef(FnDef),
|
||||
Fn(Fn),
|
||||
StaticDef(StaticDef),
|
||||
}
|
||||
impl ast::AttrsOwner for ExternItem {}
|
||||
|
@ -1463,8 +1466,8 @@ impl AstNode for ExternCrate {
|
|||
}
|
||||
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
||||
}
|
||||
impl AstNode for FnDef {
|
||||
fn can_cast(kind: SyntaxKind) -> bool { kind == FN_DEF }
|
||||
impl AstNode for Fn {
|
||||
fn can_cast(kind: SyntaxKind) -> bool { kind == FN }
|
||||
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
||||
if Self::can_cast(syntax.kind()) {
|
||||
Some(Self { syntax })
|
||||
|
@ -1727,6 +1730,28 @@ impl AstNode for BlockExpr {
|
|||
}
|
||||
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
||||
}
|
||||
impl AstNode for Param {
|
||||
fn can_cast(kind: SyntaxKind) -> bool { kind == PARAM }
|
||||
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 SelfParam {
|
||||
fn can_cast(kind: SyntaxKind) -> bool { kind == SELF_PARAM }
|
||||
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 RecordFieldDefList {
|
||||
fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_FIELD_DEF_LIST }
|
||||
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
||||
|
@ -2673,28 +2698,6 @@ impl AstNode for LetStmt {
|
|||
}
|
||||
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
||||
}
|
||||
impl AstNode for SelfParam {
|
||||
fn can_cast(kind: SyntaxKind) -> bool { kind == SELF_PARAM }
|
||||
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 Param {
|
||||
fn can_cast(kind: SyntaxKind) -> bool { kind == PARAM }
|
||||
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 PathSegment {
|
||||
fn can_cast(kind: SyntaxKind) -> bool { kind == PATH_SEGMENT }
|
||||
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
||||
|
@ -2784,8 +2787,8 @@ impl From<ExternBlock> for Item {
|
|||
impl From<ExternCrate> for Item {
|
||||
fn from(node: ExternCrate) -> Item { Item::ExternCrate(node) }
|
||||
}
|
||||
impl From<FnDef> for Item {
|
||||
fn from(node: FnDef) -> Item { Item::FnDef(node) }
|
||||
impl From<Fn> for Item {
|
||||
fn from(node: Fn) -> Item { Item::Fn(node) }
|
||||
}
|
||||
impl From<ImplDef> for Item {
|
||||
fn from(node: ImplDef) -> Item { Item::ImplDef(node) }
|
||||
|
@ -2817,7 +2820,7 @@ impl From<Use> for Item {
|
|||
impl AstNode for Item {
|
||||
fn can_cast(kind: SyntaxKind) -> bool {
|
||||
match kind {
|
||||
CONST_DEF | ENUM_DEF | EXTERN_BLOCK | EXTERN_CRATE | FN_DEF | IMPL_DEF | MACRO_CALL
|
||||
CONST_DEF | ENUM_DEF | EXTERN_BLOCK | EXTERN_CRATE | FN | IMPL_DEF | MACRO_CALL
|
||||
| MODULE | STATIC_DEF | STRUCT_DEF | TRAIT_DEF | TYPE_ALIAS_DEF | UNION_DEF | USE => {
|
||||
true
|
||||
}
|
||||
|
@ -2830,7 +2833,7 @@ impl AstNode for Item {
|
|||
ENUM_DEF => Item::EnumDef(EnumDef { syntax }),
|
||||
EXTERN_BLOCK => Item::ExternBlock(ExternBlock { syntax }),
|
||||
EXTERN_CRATE => Item::ExternCrate(ExternCrate { syntax }),
|
||||
FN_DEF => Item::FnDef(FnDef { syntax }),
|
||||
FN => Item::Fn(Fn { syntax }),
|
||||
IMPL_DEF => Item::ImplDef(ImplDef { syntax }),
|
||||
MACRO_CALL => Item::MacroCall(MacroCall { syntax }),
|
||||
MODULE => Item::Module(Module { syntax }),
|
||||
|
@ -2850,7 +2853,7 @@ impl AstNode for Item {
|
|||
Item::EnumDef(it) => &it.syntax,
|
||||
Item::ExternBlock(it) => &it.syntax,
|
||||
Item::ExternCrate(it) => &it.syntax,
|
||||
Item::FnDef(it) => &it.syntax,
|
||||
Item::Fn(it) => &it.syntax,
|
||||
Item::ImplDef(it) => &it.syntax,
|
||||
Item::MacroCall(it) => &it.syntax,
|
||||
Item::Module(it) => &it.syntax,
|
||||
|
@ -2948,6 +2951,101 @@ impl AstNode for TypeRef {
|
|||
}
|
||||
}
|
||||
}
|
||||
impl From<OrPat> for Pat {
|
||||
fn from(node: OrPat) -> Pat { Pat::OrPat(node) }
|
||||
}
|
||||
impl From<ParenPat> for Pat {
|
||||
fn from(node: ParenPat) -> Pat { Pat::ParenPat(node) }
|
||||
}
|
||||
impl From<RefPat> for Pat {
|
||||
fn from(node: RefPat) -> Pat { 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) }
|
||||
}
|
||||
impl From<PlaceholderPat> for Pat {
|
||||
fn from(node: PlaceholderPat) -> Pat { 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<RecordPat> for Pat {
|
||||
fn from(node: RecordPat) -> Pat { Pat::RecordPat(node) }
|
||||
}
|
||||
impl From<TupleStructPat> for Pat {
|
||||
fn from(node: TupleStructPat) -> Pat { Pat::TupleStructPat(node) }
|
||||
}
|
||||
impl From<TuplePat> for Pat {
|
||||
fn from(node: TuplePat) -> Pat { Pat::TuplePat(node) }
|
||||
}
|
||||
impl From<SlicePat> for Pat {
|
||||
fn from(node: SlicePat) -> Pat { Pat::SlicePat(node) }
|
||||
}
|
||||
impl From<RangePat> for Pat {
|
||||
fn from(node: RangePat) -> Pat { Pat::RangePat(node) }
|
||||
}
|
||||
impl From<LiteralPat> for Pat {
|
||||
fn from(node: LiteralPat) -> Pat { Pat::LiteralPat(node) }
|
||||
}
|
||||
impl From<MacroPat> for Pat {
|
||||
fn from(node: MacroPat) -> Pat { Pat::MacroPat(node) }
|
||||
}
|
||||
impl AstNode for Pat {
|
||||
fn can_cast(kind: SyntaxKind) -> bool {
|
||||
match kind {
|
||||
OR_PAT | PAREN_PAT | 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 | MACRO_PAT => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
||||
let res = match syntax.kind() {
|
||||
OR_PAT => Pat::OrPat(OrPat { syntax }),
|
||||
PAREN_PAT => Pat::ParenPat(ParenPat { syntax }),
|
||||
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 }),
|
||||
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 }),
|
||||
RANGE_PAT => Pat::RangePat(RangePat { syntax }),
|
||||
LITERAL_PAT => Pat::LiteralPat(LiteralPat { syntax }),
|
||||
MACRO_PAT => Pat::MacroPat(MacroPat { syntax }),
|
||||
_ => return None,
|
||||
};
|
||||
Some(res)
|
||||
}
|
||||
fn syntax(&self) -> &SyntaxNode {
|
||||
match self {
|
||||
Pat::OrPat(it) => &it.syntax,
|
||||
Pat::ParenPat(it) => &it.syntax,
|
||||
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::RecordPat(it) => &it.syntax,
|
||||
Pat::TupleStructPat(it) => &it.syntax,
|
||||
Pat::TuplePat(it) => &it.syntax,
|
||||
Pat::SlicePat(it) => &it.syntax,
|
||||
Pat::RangePat(it) => &it.syntax,
|
||||
Pat::LiteralPat(it) => &it.syntax,
|
||||
Pat::MacroPat(it) => &it.syntax,
|
||||
}
|
||||
}
|
||||
}
|
||||
impl From<RecordFieldDefList> for FieldDefList {
|
||||
fn from(node: RecordFieldDefList) -> FieldDefList { FieldDefList::RecordFieldDefList(node) }
|
||||
}
|
||||
|
@ -3157,8 +3255,8 @@ impl AstNode for Expr {
|
|||
}
|
||||
}
|
||||
}
|
||||
impl From<FnDef> for AssocItem {
|
||||
fn from(node: FnDef) -> AssocItem { AssocItem::FnDef(node) }
|
||||
impl From<Fn> for AssocItem {
|
||||
fn from(node: Fn) -> AssocItem { AssocItem::Fn(node) }
|
||||
}
|
||||
impl From<TypeAliasDef> for AssocItem {
|
||||
fn from(node: TypeAliasDef) -> AssocItem { AssocItem::TypeAliasDef(node) }
|
||||
|
@ -3172,13 +3270,13 @@ impl From<MacroCall> for AssocItem {
|
|||
impl AstNode for AssocItem {
|
||||
fn can_cast(kind: SyntaxKind) -> bool {
|
||||
match kind {
|
||||
FN_DEF | TYPE_ALIAS_DEF | CONST_DEF | MACRO_CALL => true,
|
||||
FN | TYPE_ALIAS_DEF | CONST_DEF | MACRO_CALL => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
||||
let res = match syntax.kind() {
|
||||
FN_DEF => AssocItem::FnDef(FnDef { syntax }),
|
||||
FN => AssocItem::Fn(Fn { syntax }),
|
||||
TYPE_ALIAS_DEF => AssocItem::TypeAliasDef(TypeAliasDef { syntax }),
|
||||
CONST_DEF => AssocItem::ConstDef(ConstDef { syntax }),
|
||||
MACRO_CALL => AssocItem::MacroCall(MacroCall { syntax }),
|
||||
|
@ -3188,108 +3286,13 @@ impl AstNode for AssocItem {
|
|||
}
|
||||
fn syntax(&self) -> &SyntaxNode {
|
||||
match self {
|
||||
AssocItem::FnDef(it) => &it.syntax,
|
||||
AssocItem::Fn(it) => &it.syntax,
|
||||
AssocItem::TypeAliasDef(it) => &it.syntax,
|
||||
AssocItem::ConstDef(it) => &it.syntax,
|
||||
AssocItem::MacroCall(it) => &it.syntax,
|
||||
}
|
||||
}
|
||||
}
|
||||
impl From<OrPat> for Pat {
|
||||
fn from(node: OrPat) -> Pat { Pat::OrPat(node) }
|
||||
}
|
||||
impl From<ParenPat> for Pat {
|
||||
fn from(node: ParenPat) -> Pat { Pat::ParenPat(node) }
|
||||
}
|
||||
impl From<RefPat> for Pat {
|
||||
fn from(node: RefPat) -> Pat { 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) }
|
||||
}
|
||||
impl From<PlaceholderPat> for Pat {
|
||||
fn from(node: PlaceholderPat) -> Pat { 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<RecordPat> for Pat {
|
||||
fn from(node: RecordPat) -> Pat { Pat::RecordPat(node) }
|
||||
}
|
||||
impl From<TupleStructPat> for Pat {
|
||||
fn from(node: TupleStructPat) -> Pat { Pat::TupleStructPat(node) }
|
||||
}
|
||||
impl From<TuplePat> for Pat {
|
||||
fn from(node: TuplePat) -> Pat { Pat::TuplePat(node) }
|
||||
}
|
||||
impl From<SlicePat> for Pat {
|
||||
fn from(node: SlicePat) -> Pat { Pat::SlicePat(node) }
|
||||
}
|
||||
impl From<RangePat> for Pat {
|
||||
fn from(node: RangePat) -> Pat { Pat::RangePat(node) }
|
||||
}
|
||||
impl From<LiteralPat> for Pat {
|
||||
fn from(node: LiteralPat) -> Pat { Pat::LiteralPat(node) }
|
||||
}
|
||||
impl From<MacroPat> for Pat {
|
||||
fn from(node: MacroPat) -> Pat { Pat::MacroPat(node) }
|
||||
}
|
||||
impl AstNode for Pat {
|
||||
fn can_cast(kind: SyntaxKind) -> bool {
|
||||
match kind {
|
||||
OR_PAT | PAREN_PAT | 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 | MACRO_PAT => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
||||
let res = match syntax.kind() {
|
||||
OR_PAT => Pat::OrPat(OrPat { syntax }),
|
||||
PAREN_PAT => Pat::ParenPat(ParenPat { syntax }),
|
||||
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 }),
|
||||
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 }),
|
||||
RANGE_PAT => Pat::RangePat(RangePat { syntax }),
|
||||
LITERAL_PAT => Pat::LiteralPat(LiteralPat { syntax }),
|
||||
MACRO_PAT => Pat::MacroPat(MacroPat { syntax }),
|
||||
_ => return None,
|
||||
};
|
||||
Some(res)
|
||||
}
|
||||
fn syntax(&self) -> &SyntaxNode {
|
||||
match self {
|
||||
Pat::OrPat(it) => &it.syntax,
|
||||
Pat::ParenPat(it) => &it.syntax,
|
||||
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::RecordPat(it) => &it.syntax,
|
||||
Pat::TupleStructPat(it) => &it.syntax,
|
||||
Pat::TuplePat(it) => &it.syntax,
|
||||
Pat::SlicePat(it) => &it.syntax,
|
||||
Pat::RangePat(it) => &it.syntax,
|
||||
Pat::LiteralPat(it) => &it.syntax,
|
||||
Pat::MacroPat(it) => &it.syntax,
|
||||
}
|
||||
}
|
||||
}
|
||||
impl From<LetStmt> for Stmt {
|
||||
fn from(node: LetStmt) -> Stmt { Stmt::LetStmt(node) }
|
||||
}
|
||||
|
@ -3346,8 +3349,8 @@ impl AstNode for AttrInput {
|
|||
}
|
||||
}
|
||||
}
|
||||
impl From<FnDef> for ExternItem {
|
||||
fn from(node: FnDef) -> ExternItem { ExternItem::FnDef(node) }
|
||||
impl From<Fn> for ExternItem {
|
||||
fn from(node: Fn) -> ExternItem { ExternItem::Fn(node) }
|
||||
}
|
||||
impl From<StaticDef> for ExternItem {
|
||||
fn from(node: StaticDef) -> ExternItem { ExternItem::StaticDef(node) }
|
||||
|
@ -3355,13 +3358,13 @@ impl From<StaticDef> for ExternItem {
|
|||
impl AstNode for ExternItem {
|
||||
fn can_cast(kind: SyntaxKind) -> bool {
|
||||
match kind {
|
||||
FN_DEF | STATIC_DEF => true,
|
||||
FN | STATIC_DEF => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
||||
let res = match syntax.kind() {
|
||||
FN_DEF => ExternItem::FnDef(FnDef { syntax }),
|
||||
FN => ExternItem::Fn(Fn { syntax }),
|
||||
STATIC_DEF => ExternItem::StaticDef(StaticDef { syntax }),
|
||||
_ => return None,
|
||||
};
|
||||
|
@ -3369,7 +3372,7 @@ impl AstNode for ExternItem {
|
|||
}
|
||||
fn syntax(&self) -> &SyntaxNode {
|
||||
match self {
|
||||
ExternItem::FnDef(it) => &it.syntax,
|
||||
ExternItem::Fn(it) => &it.syntax,
|
||||
ExternItem::StaticDef(it) => &it.syntax,
|
||||
}
|
||||
}
|
||||
|
@ -3417,6 +3420,11 @@ impl std::fmt::Display for TypeRef {
|
|||
std::fmt::Display::fmt(self.syntax(), f)
|
||||
}
|
||||
}
|
||||
impl std::fmt::Display for Pat {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
std::fmt::Display::fmt(self.syntax(), f)
|
||||
}
|
||||
}
|
||||
impl std::fmt::Display for FieldDefList {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
std::fmt::Display::fmt(self.syntax(), f)
|
||||
|
@ -3432,11 +3440,6 @@ impl std::fmt::Display for AssocItem {
|
|||
std::fmt::Display::fmt(self.syntax(), f)
|
||||
}
|
||||
}
|
||||
impl std::fmt::Display for Pat {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
std::fmt::Display::fmt(self.syntax(), f)
|
||||
}
|
||||
}
|
||||
impl std::fmt::Display for Stmt {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
std::fmt::Display::fmt(self.syntax(), f)
|
||||
|
@ -3487,7 +3490,7 @@ impl std::fmt::Display for ExternCrate {
|
|||
std::fmt::Display::fmt(self.syntax(), f)
|
||||
}
|
||||
}
|
||||
impl std::fmt::Display for FnDef {
|
||||
impl std::fmt::Display for Fn {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
std::fmt::Display::fmt(self.syntax(), f)
|
||||
}
|
||||
|
@ -3607,6 +3610,16 @@ impl std::fmt::Display for BlockExpr {
|
|||
std::fmt::Display::fmt(self.syntax(), f)
|
||||
}
|
||||
}
|
||||
impl std::fmt::Display for Param {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
std::fmt::Display::fmt(self.syntax(), f)
|
||||
}
|
||||
}
|
||||
impl std::fmt::Display for SelfParam {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
std::fmt::Display::fmt(self.syntax(), f)
|
||||
}
|
||||
}
|
||||
impl std::fmt::Display for RecordFieldDefList {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
std::fmt::Display::fmt(self.syntax(), f)
|
||||
|
@ -4037,16 +4050,6 @@ impl std::fmt::Display for LetStmt {
|
|||
std::fmt::Display::fmt(self.syntax(), f)
|
||||
}
|
||||
}
|
||||
impl std::fmt::Display for SelfParam {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
std::fmt::Display::fmt(self.syntax(), f)
|
||||
}
|
||||
}
|
||||
impl std::fmt::Display for Param {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
std::fmt::Display::fmt(self.syntax(), f)
|
||||
}
|
||||
}
|
||||
impl std::fmt::Display for PathSegment {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
std::fmt::Display::fmt(self.syntax(), f)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue