mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-12 21:28:51 +00:00
Rename FnDef -> Fn
This commit is contained in:
parent
3e1e6227ca
commit
1142112c70
244 changed files with 683 additions and 675 deletions
|
@ -118,7 +118,7 @@ fn add_missing_impl_members_inner(
|
||||||
|
|
||||||
let def_name = |item: &ast::AssocItem| -> Option<SmolStr> {
|
let def_name = |item: &ast::AssocItem| -> Option<SmolStr> {
|
||||||
match item {
|
match item {
|
||||||
ast::AssocItem::FnDef(def) => def.name(),
|
ast::AssocItem::Fn(def) => def.name(),
|
||||||
ast::AssocItem::TypeAliasDef(def) => def.name(),
|
ast::AssocItem::TypeAliasDef(def) => def.name(),
|
||||||
ast::AssocItem::ConstDef(def) => def.name(),
|
ast::AssocItem::ConstDef(def) => def.name(),
|
||||||
ast::AssocItem::MacroCall(_) => None,
|
ast::AssocItem::MacroCall(_) => None,
|
||||||
|
@ -129,13 +129,13 @@ fn add_missing_impl_members_inner(
|
||||||
let missing_items = get_missing_assoc_items(&ctx.sema, &impl_def)
|
let missing_items = get_missing_assoc_items(&ctx.sema, &impl_def)
|
||||||
.iter()
|
.iter()
|
||||||
.map(|i| match i {
|
.map(|i| match i {
|
||||||
hir::AssocItem::Function(i) => ast::AssocItem::FnDef(i.source(ctx.db()).value),
|
hir::AssocItem::Function(i) => ast::AssocItem::Fn(i.source(ctx.db()).value),
|
||||||
hir::AssocItem::TypeAlias(i) => ast::AssocItem::TypeAliasDef(i.source(ctx.db()).value),
|
hir::AssocItem::TypeAlias(i) => ast::AssocItem::TypeAliasDef(i.source(ctx.db()).value),
|
||||||
hir::AssocItem::Const(i) => ast::AssocItem::ConstDef(i.source(ctx.db()).value),
|
hir::AssocItem::Const(i) => ast::AssocItem::ConstDef(i.source(ctx.db()).value),
|
||||||
})
|
})
|
||||||
.filter(|t| def_name(&t).is_some())
|
.filter(|t| def_name(&t).is_some())
|
||||||
.filter(|t| match t {
|
.filter(|t| match t {
|
||||||
ast::AssocItem::FnDef(def) => match mode {
|
ast::AssocItem::Fn(def) => match mode {
|
||||||
AddMissingImplMembersMode::DefaultMethodsOnly => def.body().is_some(),
|
AddMissingImplMembersMode::DefaultMethodsOnly => def.body().is_some(),
|
||||||
AddMissingImplMembersMode::NoDefaultMethods => def.body().is_none(),
|
AddMissingImplMembersMode::NoDefaultMethods => def.body().is_none(),
|
||||||
},
|
},
|
||||||
|
@ -158,7 +158,7 @@ fn add_missing_impl_members_inner(
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|it| ast_transform::apply(&*ast_transform, it))
|
.map(|it| ast_transform::apply(&*ast_transform, it))
|
||||||
.map(|it| match it {
|
.map(|it| match it {
|
||||||
ast::AssocItem::FnDef(def) => ast::AssocItem::FnDef(add_body(def)),
|
ast::AssocItem::Fn(def) => ast::AssocItem::Fn(add_body(def)),
|
||||||
ast::AssocItem::TypeAliasDef(def) => {
|
ast::AssocItem::TypeAliasDef(def) => {
|
||||||
ast::AssocItem::TypeAliasDef(def.remove_bounds())
|
ast::AssocItem::TypeAliasDef(def.remove_bounds())
|
||||||
}
|
}
|
||||||
|
@ -174,7 +174,7 @@ fn add_missing_impl_members_inner(
|
||||||
Some(cap) => {
|
Some(cap) => {
|
||||||
let mut cursor = Cursor::Before(first_new_item.syntax());
|
let mut cursor = Cursor::Before(first_new_item.syntax());
|
||||||
let placeholder;
|
let placeholder;
|
||||||
if let ast::AssocItem::FnDef(func) = &first_new_item {
|
if let ast::AssocItem::Fn(func) = &first_new_item {
|
||||||
if let Some(m) = func.syntax().descendants().find_map(ast::MacroCall::cast) {
|
if let Some(m) = func.syntax().descendants().find_map(ast::MacroCall::cast) {
|
||||||
if m.syntax().text() == "todo!()" {
|
if m.syntax().text() == "todo!()" {
|
||||||
placeholder = m;
|
placeholder = m;
|
||||||
|
@ -192,7 +192,7 @@ fn add_missing_impl_members_inner(
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn add_body(fn_def: ast::FnDef) -> ast::FnDef {
|
fn add_body(fn_def: ast::Fn) -> ast::Fn {
|
||||||
if fn_def.body().is_some() {
|
if fn_def.body().is_some() {
|
||||||
return fn_def;
|
return fn_def;
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ use test_utils::mark;
|
||||||
pub(crate) fn change_return_type_to_result(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
|
pub(crate) fn change_return_type_to_result(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
|
||||||
let ret_type = ctx.find_node_at_offset::<ast::RetType>()?;
|
let ret_type = ctx.find_node_at_offset::<ast::RetType>()?;
|
||||||
// FIXME: extend to lambdas as well
|
// FIXME: extend to lambdas as well
|
||||||
let fn_def = ret_type.syntax().parent().and_then(ast::FnDef::cast)?;
|
let fn_def = ret_type.syntax().parent().and_then(ast::Fn::cast)?;
|
||||||
|
|
||||||
let type_ref = &ret_type.type_ref()?;
|
let type_ref = &ret_type.type_ref()?;
|
||||||
let ret_type_str = type_ref.syntax().text().to_string();
|
let ret_type_str = type_ref.syntax().text().to_string();
|
||||||
|
|
|
@ -2,7 +2,7 @@ use ra_syntax::{
|
||||||
ast::{self, NameOwner, VisibilityOwner},
|
ast::{self, NameOwner, VisibilityOwner},
|
||||||
AstNode,
|
AstNode,
|
||||||
SyntaxKind::{
|
SyntaxKind::{
|
||||||
CONST_DEF, ENUM_DEF, FN_DEF, MODULE, STATIC_DEF, STRUCT_DEF, TRAIT_DEF, VISIBILITY,
|
CONST_DEF, ENUM_DEF, FN, MODULE, STATIC_DEF, STRUCT_DEF, TRAIT_DEF, VISIBILITY,
|
||||||
},
|
},
|
||||||
T,
|
T,
|
||||||
};
|
};
|
||||||
|
@ -38,7 +38,7 @@ fn add_vis(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
|
||||||
|
|
||||||
let (offset, target) = if let Some(keyword) = item_keyword {
|
let (offset, target) = if let Some(keyword) = item_keyword {
|
||||||
let parent = keyword.parent();
|
let parent = keyword.parent();
|
||||||
let def_kws = vec![CONST_DEF, STATIC_DEF, FN_DEF, MODULE, STRUCT_DEF, ENUM_DEF, TRAIT_DEF];
|
let def_kws = vec![CONST_DEF, STATIC_DEF, FN, MODULE, STRUCT_DEF, ENUM_DEF, TRAIT_DEF];
|
||||||
// Parent is not a definition, can't add visibility
|
// Parent is not a definition, can't add visibility
|
||||||
if !def_kws.iter().any(|&def_kw| def_kw == parent.kind()) {
|
if !def_kws.iter().any(|&def_kw| def_kw == parent.kind()) {
|
||||||
return None;
|
return None;
|
||||||
|
|
|
@ -8,7 +8,7 @@ use ra_syntax::{
|
||||||
make,
|
make,
|
||||||
},
|
},
|
||||||
AstNode,
|
AstNode,
|
||||||
SyntaxKind::{FN_DEF, LOOP_EXPR, L_CURLY, R_CURLY, WHILE_EXPR, WHITESPACE},
|
SyntaxKind::{FN, LOOP_EXPR, L_CURLY, R_CURLY, WHILE_EXPR, WHITESPACE},
|
||||||
SyntaxNode,
|
SyntaxNode,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -88,7 +88,7 @@ pub(crate) fn convert_to_guarded_return(acc: &mut Assists, ctx: &AssistContext)
|
||||||
|
|
||||||
let early_expression: ast::Expr = match parent_container.kind() {
|
let early_expression: ast::Expr = match parent_container.kind() {
|
||||||
WHILE_EXPR | LOOP_EXPR => make::expr_continue(),
|
WHILE_EXPR | LOOP_EXPR => make::expr_continue(),
|
||||||
FN_DEF => make::expr_return(),
|
FN => make::expr_return(),
|
||||||
_ => return None,
|
_ => return None,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -82,7 +82,7 @@ struct FunctionTemplate {
|
||||||
insert_offset: TextSize,
|
insert_offset: TextSize,
|
||||||
placeholder_expr: ast::MacroCall,
|
placeholder_expr: ast::MacroCall,
|
||||||
leading_ws: String,
|
leading_ws: String,
|
||||||
fn_def: ast::FnDef,
|
fn_def: ast::Fn,
|
||||||
trailing_ws: String,
|
trailing_ws: String,
|
||||||
file: FileId,
|
file: FileId,
|
||||||
}
|
}
|
||||||
|
|
|
@ -160,7 +160,7 @@ fn find_struct_impl(ctx: &AssistContext, strukt: &ast::StructDef) -> Option<Opti
|
||||||
fn has_new_fn(imp: &ast::ImplDef) -> bool {
|
fn has_new_fn(imp: &ast::ImplDef) -> bool {
|
||||||
if let Some(il) = imp.assoc_item_list() {
|
if let Some(il) = imp.assoc_item_list() {
|
||||||
for item in il.assoc_items() {
|
for item in il.assoc_items() {
|
||||||
if let ast::AssocItem::FnDef(f) = item {
|
if let ast::AssocItem::Fn(f) = item {
|
||||||
if let Some(name) = f.name() {
|
if let Some(name) = f.name() {
|
||||||
if name.text().eq_ignore_ascii_case("new") {
|
if name.text().eq_ignore_ascii_case("new") {
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -38,7 +38,7 @@ pub(crate) fn introduce_named_lifetime(acc: &mut Assists, ctx: &AssistContext) -
|
||||||
let lifetime_token = ctx
|
let lifetime_token = ctx
|
||||||
.find_token_at_offset(SyntaxKind::LIFETIME)
|
.find_token_at_offset(SyntaxKind::LIFETIME)
|
||||||
.filter(|lifetime| lifetime.text() == "'_")?;
|
.filter(|lifetime| lifetime.text() == "'_")?;
|
||||||
if let Some(fn_def) = lifetime_token.ancestors().find_map(ast::FnDef::cast) {
|
if let Some(fn_def) = lifetime_token.ancestors().find_map(ast::Fn::cast) {
|
||||||
generate_fn_def_assist(acc, &fn_def, lifetime_token.text_range())
|
generate_fn_def_assist(acc, &fn_def, lifetime_token.text_range())
|
||||||
} else if let Some(impl_def) = lifetime_token.ancestors().find_map(ast::ImplDef::cast) {
|
} else if let Some(impl_def) = lifetime_token.ancestors().find_map(ast::ImplDef::cast) {
|
||||||
generate_impl_def_assist(acc, &impl_def, lifetime_token.text_range())
|
generate_impl_def_assist(acc, &impl_def, lifetime_token.text_range())
|
||||||
|
@ -50,7 +50,7 @@ pub(crate) fn introduce_named_lifetime(acc: &mut Assists, ctx: &AssistContext) -
|
||||||
/// Generate the assist for the fn def case
|
/// Generate the assist for the fn def case
|
||||||
fn generate_fn_def_assist(
|
fn generate_fn_def_assist(
|
||||||
acc: &mut Assists,
|
acc: &mut Assists,
|
||||||
fn_def: &ast::FnDef,
|
fn_def: &ast::Fn,
|
||||||
lifetime_loc: TextRange,
|
lifetime_loc: TextRange,
|
||||||
) -> Option<()> {
|
) -> Option<()> {
|
||||||
let param_list: ast::ParamList = fn_def.param_list()?;
|
let param_list: ast::ParamList = fn_def.param_list()?;
|
||||||
|
|
|
@ -37,7 +37,7 @@ pub(crate) fn move_bounds_to_where_clause(acc: &mut Assists, ctx: &AssistContext
|
||||||
|
|
||||||
let anchor = match_ast! {
|
let anchor = match_ast! {
|
||||||
match parent {
|
match parent {
|
||||||
ast::FnDef(it) => it.body()?.syntax().clone().into(),
|
ast::Fn(it) => it.body()?.syntax().clone().into(),
|
||||||
ast::TraitDef(it) => it.assoc_item_list()?.syntax().clone().into(),
|
ast::TraitDef(it) => it.assoc_item_list()?.syntax().clone().into(),
|
||||||
ast::ImplDef(it) => it.assoc_item_list()?.syntax().clone().into(),
|
ast::ImplDef(it) => it.assoc_item_list()?.syntax().clone().into(),
|
||||||
ast::EnumDef(it) => it.variant_list()?.syntax().clone().into(),
|
ast::EnumDef(it) => it.variant_list()?.syntax().clone().into(),
|
||||||
|
|
|
@ -66,7 +66,7 @@ pub fn get_missing_assoc_items(
|
||||||
if let Some(item_list) = impl_def.assoc_item_list() {
|
if let Some(item_list) = impl_def.assoc_item_list() {
|
||||||
for item in item_list.assoc_items() {
|
for item in item_list.assoc_items() {
|
||||||
match item {
|
match item {
|
||||||
ast::AssocItem::FnDef(f) => {
|
ast::AssocItem::Fn(f) => {
|
||||||
if let Some(n) = f.name() {
|
if let Some(n) = f.name() {
|
||||||
impl_fns_consts.insert(n.syntax().to_string());
|
impl_fns_consts.insert(n.syntax().to_string());
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,8 +81,8 @@ impl HasSource for EnumVariant {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl HasSource for Function {
|
impl HasSource for Function {
|
||||||
type Ast = ast::FnDef;
|
type Ast = ast::Fn;
|
||||||
fn source(self, db: &dyn HirDatabase) -> InFile<ast::FnDef> {
|
fn source(self, db: &dyn HirDatabase) -> InFile<ast::Fn> {
|
||||||
self.id.lookup(db.upcast()).source(db.upcast())
|
self.id.lookup(db.upcast()).source(db.upcast())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -585,7 +585,7 @@ to_def_impls![
|
||||||
(crate::TypeAlias, ast::TypeAliasDef, type_alias_to_def),
|
(crate::TypeAlias, ast::TypeAliasDef, type_alias_to_def),
|
||||||
(crate::Const, ast::ConstDef, const_to_def),
|
(crate::Const, ast::ConstDef, const_to_def),
|
||||||
(crate::Static, ast::StaticDef, static_to_def),
|
(crate::Static, ast::StaticDef, static_to_def),
|
||||||
(crate::Function, ast::FnDef, fn_to_def),
|
(crate::Function, ast::Fn, fn_to_def),
|
||||||
(crate::Field, ast::RecordFieldDef, record_field_to_def),
|
(crate::Field, ast::RecordFieldDef, record_field_to_def),
|
||||||
(crate::Field, ast::TupleFieldDef, tuple_field_to_def),
|
(crate::Field, ast::TupleFieldDef, tuple_field_to_def),
|
||||||
(crate::EnumVariant, ast::EnumVariant, enum_variant_to_def),
|
(crate::EnumVariant, ast::EnumVariant, enum_variant_to_def),
|
||||||
|
|
|
@ -71,7 +71,7 @@ impl SourceToDefCtx<'_, '_> {
|
||||||
pub(super) fn impl_to_def(&mut self, src: InFile<ast::ImplDef>) -> Option<ImplId> {
|
pub(super) fn impl_to_def(&mut self, src: InFile<ast::ImplDef>) -> Option<ImplId> {
|
||||||
self.to_def(src, keys::IMPL)
|
self.to_def(src, keys::IMPL)
|
||||||
}
|
}
|
||||||
pub(super) fn fn_to_def(&mut self, src: InFile<ast::FnDef>) -> Option<FunctionId> {
|
pub(super) fn fn_to_def(&mut self, src: InFile<ast::Fn>) -> Option<FunctionId> {
|
||||||
self.to_def(src, keys::FUNCTION)
|
self.to_def(src, keys::FUNCTION)
|
||||||
}
|
}
|
||||||
pub(super) fn struct_to_def(&mut self, src: InFile<ast::StructDef>) -> Option<StructId> {
|
pub(super) fn struct_to_def(&mut self, src: InFile<ast::StructDef>) -> Option<StructId> {
|
||||||
|
@ -171,7 +171,7 @@ impl SourceToDefCtx<'_, '_> {
|
||||||
let def = self.impl_to_def(container.with_value(it))?;
|
let def = self.impl_to_def(container.with_value(it))?;
|
||||||
def.into()
|
def.into()
|
||||||
},
|
},
|
||||||
ast::FnDef(it) => {
|
ast::Fn(it) => {
|
||||||
let def = self.fn_to_def(container.with_value(it))?;
|
let def = self.fn_to_def(container.with_value(it))?;
|
||||||
DefWithBodyId::from(def).into()
|
DefWithBodyId::from(def).into()
|
||||||
},
|
},
|
||||||
|
@ -213,7 +213,7 @@ impl SourceToDefCtx<'_, '_> {
|
||||||
for container in src.cloned().ancestors_with_macros(self.db.upcast()).skip(1) {
|
for container in src.cloned().ancestors_with_macros(self.db.upcast()).skip(1) {
|
||||||
let res: GenericDefId = match_ast! {
|
let res: GenericDefId = match_ast! {
|
||||||
match (container.value) {
|
match (container.value) {
|
||||||
ast::FnDef(it) => self.fn_to_def(container.with_value(it))?.into(),
|
ast::Fn(it) => self.fn_to_def(container.with_value(it))?.into(),
|
||||||
ast::StructDef(it) => self.struct_to_def(container.with_value(it))?.into(),
|
ast::StructDef(it) => self.struct_to_def(container.with_value(it))?.into(),
|
||||||
ast::EnumDef(it) => self.enum_to_def(container.with_value(it))?.into(),
|
ast::EnumDef(it) => self.enum_to_def(container.with_value(it))?.into(),
|
||||||
ast::TraitDef(it) => self.trait_to_def(container.with_value(it))?.into(),
|
ast::TraitDef(it) => self.trait_to_def(container.with_value(it))?.into(),
|
||||||
|
@ -233,7 +233,7 @@ impl SourceToDefCtx<'_, '_> {
|
||||||
match (container.value) {
|
match (container.value) {
|
||||||
ast::ConstDef(it) => self.const_to_def(container.with_value(it))?.into(),
|
ast::ConstDef(it) => self.const_to_def(container.with_value(it))?.into(),
|
||||||
ast::StaticDef(it) => self.static_to_def(container.with_value(it))?.into(),
|
ast::StaticDef(it) => self.static_to_def(container.with_value(it))?.into(),
|
||||||
ast::FnDef(it) => self.fn_to_def(container.with_value(it))?.into(),
|
ast::Fn(it) => self.fn_to_def(container.with_value(it))?.into(),
|
||||||
_ => continue,
|
_ => continue,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -627,7 +627,7 @@ impl ExprCollector<'_> {
|
||||||
.items()
|
.items()
|
||||||
.filter_map(|item| {
|
.filter_map(|item| {
|
||||||
let (def, name): (ModuleDefId, Option<ast::Name>) = match item {
|
let (def, name): (ModuleDefId, Option<ast::Name>) = match item {
|
||||||
ast::Item::FnDef(def) => {
|
ast::Item::Fn(def) => {
|
||||||
let id = self.find_inner_item(&def)?;
|
let id = self.find_inner_item(&def)?;
|
||||||
(
|
(
|
||||||
FunctionLoc { container: container.into(), id }.intern(self.db).into(),
|
FunctionLoc { container: container.into(), id }.intern(self.db).into(),
|
||||||
|
|
|
@ -413,7 +413,7 @@ macro_rules! mod_items {
|
||||||
mod_items! {
|
mod_items! {
|
||||||
Import in imports -> ast::Use,
|
Import in imports -> ast::Use,
|
||||||
ExternCrate in extern_crates -> ast::ExternCrate,
|
ExternCrate in extern_crates -> ast::ExternCrate,
|
||||||
Function in functions -> ast::FnDef,
|
Function in functions -> ast::Fn,
|
||||||
Struct in structs -> ast::StructDef,
|
Struct in structs -> ast::StructDef,
|
||||||
Union in unions -> ast::UnionDef,
|
Union in unions -> ast::UnionDef,
|
||||||
Enum in enums -> ast::EnumDef,
|
Enum in enums -> ast::EnumDef,
|
||||||
|
@ -505,7 +505,7 @@ pub struct Function {
|
||||||
pub params: Box<[TypeRef]>,
|
pub params: Box<[TypeRef]>,
|
||||||
pub is_varargs: bool,
|
pub is_varargs: bool,
|
||||||
pub ret_type: TypeRef,
|
pub ret_type: TypeRef,
|
||||||
pub ast_id: FileAstId<ast::FnDef>,
|
pub ast_id: FileAstId<ast::Fn>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Eq, PartialEq)]
|
#[derive(Debug, Clone, Eq, PartialEq)]
|
||||||
|
|
|
@ -78,7 +78,7 @@ impl Ctx {
|
||||||
ast::Item::StructDef(_)
|
ast::Item::StructDef(_)
|
||||||
| ast::Item::UnionDef(_)
|
| ast::Item::UnionDef(_)
|
||||||
| ast::Item::EnumDef(_)
|
| ast::Item::EnumDef(_)
|
||||||
| ast::Item::FnDef(_)
|
| ast::Item::Fn(_)
|
||||||
| ast::Item::TypeAliasDef(_)
|
| ast::Item::TypeAliasDef(_)
|
||||||
| ast::Item::ConstDef(_)
|
| ast::Item::ConstDef(_)
|
||||||
| ast::Item::StaticDef(_)
|
| ast::Item::StaticDef(_)
|
||||||
|
@ -103,7 +103,7 @@ impl Ctx {
|
||||||
ast::Item::StructDef(ast) => self.lower_struct(ast).map(Into::into),
|
ast::Item::StructDef(ast) => self.lower_struct(ast).map(Into::into),
|
||||||
ast::Item::UnionDef(ast) => self.lower_union(ast).map(Into::into),
|
ast::Item::UnionDef(ast) => self.lower_union(ast).map(Into::into),
|
||||||
ast::Item::EnumDef(ast) => self.lower_enum(ast).map(Into::into),
|
ast::Item::EnumDef(ast) => self.lower_enum(ast).map(Into::into),
|
||||||
ast::Item::FnDef(ast) => self.lower_function(ast).map(Into::into),
|
ast::Item::Fn(ast) => self.lower_function(ast).map(Into::into),
|
||||||
ast::Item::TypeAliasDef(ast) => self.lower_type_alias(ast).map(Into::into),
|
ast::Item::TypeAliasDef(ast) => self.lower_type_alias(ast).map(Into::into),
|
||||||
ast::Item::StaticDef(ast) => self.lower_static(ast).map(Into::into),
|
ast::Item::StaticDef(ast) => self.lower_static(ast).map(Into::into),
|
||||||
ast::Item::ConstDef(ast) => Some(self.lower_const(ast).into()),
|
ast::Item::ConstDef(ast) => Some(self.lower_const(ast).into()),
|
||||||
|
@ -155,7 +155,7 @@ impl Ctx {
|
||||||
|
|
||||||
fn lower_assoc_item(&mut self, item: &ast::AssocItem) -> Option<AssocItem> {
|
fn lower_assoc_item(&mut self, item: &ast::AssocItem) -> Option<AssocItem> {
|
||||||
match item {
|
match item {
|
||||||
ast::AssocItem::FnDef(ast) => self.lower_function(ast).map(Into::into),
|
ast::AssocItem::Fn(ast) => self.lower_function(ast).map(Into::into),
|
||||||
ast::AssocItem::TypeAliasDef(ast) => self.lower_type_alias(ast).map(Into::into),
|
ast::AssocItem::TypeAliasDef(ast) => self.lower_type_alias(ast).map(Into::into),
|
||||||
ast::AssocItem::ConstDef(ast) => Some(self.lower_const(ast).into()),
|
ast::AssocItem::ConstDef(ast) => Some(self.lower_const(ast).into()),
|
||||||
ast::AssocItem::MacroCall(ast) => self.lower_macro_call(ast).map(Into::into),
|
ast::AssocItem::MacroCall(ast) => self.lower_macro_call(ast).map(Into::into),
|
||||||
|
@ -277,7 +277,7 @@ impl Ctx {
|
||||||
Some(res)
|
Some(res)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn lower_function(&mut self, func: &ast::FnDef) -> Option<FileItemTreeId<Function>> {
|
fn lower_function(&mut self, func: &ast::Fn) -> Option<FileItemTreeId<Function>> {
|
||||||
let visibility = self.lower_visibility(func);
|
let visibility = self.lower_visibility(func);
|
||||||
let name = func.name()?.as_name();
|
let name = func.name()?.as_name();
|
||||||
|
|
||||||
|
@ -547,7 +547,7 @@ impl Ctx {
|
||||||
self.collect_inner_items(item.syntax());
|
self.collect_inner_items(item.syntax());
|
||||||
let attrs = Attrs::new(&item, &self.hygiene);
|
let attrs = Attrs::new(&item, &self.hygiene);
|
||||||
let id: ModItem = match item {
|
let id: ModItem = match item {
|
||||||
ast::ExternItem::FnDef(ast) => {
|
ast::ExternItem::Fn(ast) => {
|
||||||
let func = self.lower_function(&ast)?;
|
let func = self.lower_function(&ast)?;
|
||||||
self.data().functions[func.index].is_unsafe = true;
|
self.data().functions[func.index].is_unsafe = true;
|
||||||
func.into()
|
func.into()
|
||||||
|
|
|
@ -240,9 +240,9 @@ fn smoke() {
|
||||||
> #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("assoc_const"))] }, input: None }]) }]
|
> #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("assoc_const"))] }, input: None }]) }]
|
||||||
> Const { name: Some(Name(Text("CONST"))), visibility: RawVisibilityId("pub(self)"), type_ref: Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("u8"))] }, generic_args: [None] }), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::ConstDef>(9) }
|
> Const { name: Some(Name(Text("CONST"))), visibility: RawVisibilityId("pub(self)"), type_ref: Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("u8"))] }, generic_args: [None] }), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::ConstDef>(9) }
|
||||||
> #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("assoc_method"))] }, input: None }]) }]
|
> #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("assoc_method"))] }, input: None }]) }]
|
||||||
> Function { name: Name(Text("method")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: true, is_unsafe: false, params: [Reference(Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("Self"))] }, generic_args: [None] }), Shared)], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::FnDef>(10) }
|
> Function { name: Name(Text("method")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: true, is_unsafe: false, params: [Reference(Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("Self"))] }, generic_args: [None] }), Shared)], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::Fn>(10) }
|
||||||
> #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("assoc_dfl_method"))] }, input: None }]) }]
|
> #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("assoc_dfl_method"))] }, input: None }]) }]
|
||||||
> Function { name: Name(Text("dfl_method")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: true, is_unsafe: false, params: [Reference(Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("Self"))] }, generic_args: [None] }), Mut)], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::FnDef>(11) }
|
> Function { name: Name(Text("dfl_method")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: true, is_unsafe: false, params: [Reference(Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("Self"))] }, generic_args: [None] }), Mut)], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::Fn>(11) }
|
||||||
#[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("struct0"))] }, input: None }]) }]
|
#[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("struct0"))] }, input: None }]) }]
|
||||||
Struct { name: Name(Text("Struct0")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(1), fields: Unit, ast_id: FileAstId::<ra_syntax::ast::generated::nodes::StructDef>(3), kind: Unit }
|
Struct { name: Name(Text("Struct0")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(1), fields: Unit, ast_id: FileAstId::<ra_syntax::ast::generated::nodes::StructDef>(3), kind: Unit }
|
||||||
#[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("struct1"))] }, input: None }]) }]
|
#[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("struct1"))] }, input: None }]) }]
|
||||||
|
@ -275,12 +275,12 @@ fn simple_inner_items() {
|
||||||
|
|
||||||
top-level items:
|
top-level items:
|
||||||
Impl { generic_params: GenericParamsId(0), target_trait: Some(Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("D"))] }, generic_args: [None] })), target_type: Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("Response"))] }, generic_args: [Some(GenericArgs { args: [Type(Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("T"))] }, generic_args: [None] }))], has_self_type: false, bindings: [] })] }), is_negative: false, items: [Function(Idx::<Function>(1))], ast_id: FileAstId::<ra_syntax::ast::generated::nodes::ImplDef>(0) }
|
Impl { generic_params: GenericParamsId(0), target_trait: Some(Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("D"))] }, generic_args: [None] })), target_type: Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("Response"))] }, generic_args: [Some(GenericArgs { args: [Type(Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("T"))] }, generic_args: [None] }))], has_self_type: false, bindings: [] })] }), is_negative: false, items: [Function(Idx::<Function>(1))], ast_id: FileAstId::<ra_syntax::ast::generated::nodes::ImplDef>(0) }
|
||||||
> Function { name: Name(Text("foo")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: false, is_unsafe: false, params: [], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::FnDef>(1) }
|
> Function { name: Name(Text("foo")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: false, is_unsafe: false, params: [], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::Fn>(1) }
|
||||||
|
|
||||||
inner items:
|
inner items:
|
||||||
|
|
||||||
for AST FileAstId::<ra_syntax::ast::generated::nodes::Item>(2):
|
for AST FileAstId::<ra_syntax::ast::generated::nodes::Item>(2):
|
||||||
Function { name: Name(Text("end")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(1), has_self_param: false, is_unsafe: false, params: [], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::FnDef>(2) }
|
Function { name: Name(Text("end")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(1), has_self_param: false, is_unsafe: false, params: [], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::Fn>(2) }
|
||||||
|
|
||||||
"#]],
|
"#]],
|
||||||
);
|
);
|
||||||
|
@ -303,9 +303,9 @@ fn extern_attrs() {
|
||||||
|
|
||||||
top-level items:
|
top-level items:
|
||||||
#[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("attr_a"))] }, input: None }, Attr { path: ModPath { kind: Plain, segments: [Name(Text("block_attr"))] }, input: None }]) }]
|
#[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("attr_a"))] }, input: None }, Attr { path: ModPath { kind: Plain, segments: [Name(Text("block_attr"))] }, input: None }]) }]
|
||||||
Function { name: Name(Text("a")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: false, is_unsafe: true, params: [], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::FnDef>(1) }
|
Function { name: Name(Text("a")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: false, is_unsafe: true, params: [], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::Fn>(1) }
|
||||||
#[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("attr_b"))] }, input: None }, Attr { path: ModPath { kind: Plain, segments: [Name(Text("block_attr"))] }, input: None }]) }]
|
#[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("attr_b"))] }, input: None }, Attr { path: ModPath { kind: Plain, segments: [Name(Text("block_attr"))] }, input: None }]) }]
|
||||||
Function { name: Name(Text("b")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: false, is_unsafe: true, params: [], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::FnDef>(2) }
|
Function { name: Name(Text("b")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: false, is_unsafe: true, params: [], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::Fn>(2) }
|
||||||
"##]],
|
"##]],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -329,9 +329,9 @@ fn trait_attrs() {
|
||||||
#[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("trait_attr"))] }, input: None }]) }]
|
#[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("trait_attr"))] }, input: None }]) }]
|
||||||
Trait { name: Name(Text("Tr")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(0), auto: false, items: [Function(Idx::<Function>(0)), Function(Idx::<Function>(1))], ast_id: FileAstId::<ra_syntax::ast::generated::nodes::TraitDef>(0) }
|
Trait { name: Name(Text("Tr")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(0), auto: false, items: [Function(Idx::<Function>(0)), Function(Idx::<Function>(1))], ast_id: FileAstId::<ra_syntax::ast::generated::nodes::TraitDef>(0) }
|
||||||
> #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("attr_a"))] }, input: None }]) }]
|
> #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("attr_a"))] }, input: None }]) }]
|
||||||
> Function { name: Name(Text("a")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: false, is_unsafe: false, params: [], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::FnDef>(1) }
|
> Function { name: Name(Text("a")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: false, is_unsafe: false, params: [], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::Fn>(1) }
|
||||||
> #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("attr_b"))] }, input: None }]) }]
|
> #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("attr_b"))] }, input: None }]) }]
|
||||||
> Function { name: Name(Text("b")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: false, is_unsafe: false, params: [], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::FnDef>(2) }
|
> Function { name: Name(Text("b")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: false, is_unsafe: false, params: [], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::Fn>(2) }
|
||||||
"##]],
|
"##]],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -355,9 +355,9 @@ fn impl_attrs() {
|
||||||
#[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("impl_attr"))] }, input: None }]) }]
|
#[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("impl_attr"))] }, input: None }]) }]
|
||||||
Impl { generic_params: GenericParamsId(4294967295), target_trait: None, target_type: Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("Ty"))] }, generic_args: [None] }), is_negative: false, items: [Function(Idx::<Function>(0)), Function(Idx::<Function>(1))], ast_id: FileAstId::<ra_syntax::ast::generated::nodes::ImplDef>(0) }
|
Impl { generic_params: GenericParamsId(4294967295), target_trait: None, target_type: Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("Ty"))] }, generic_args: [None] }), is_negative: false, items: [Function(Idx::<Function>(0)), Function(Idx::<Function>(1))], ast_id: FileAstId::<ra_syntax::ast::generated::nodes::ImplDef>(0) }
|
||||||
> #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("attr_a"))] }, input: None }]) }]
|
> #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("attr_a"))] }, input: None }]) }]
|
||||||
> Function { name: Name(Text("a")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: false, is_unsafe: false, params: [], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::FnDef>(1) }
|
> Function { name: Name(Text("a")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: false, is_unsafe: false, params: [], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::Fn>(1) }
|
||||||
> #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("attr_b"))] }, input: None }]) }]
|
> #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("attr_b"))] }, input: None }]) }]
|
||||||
> Function { name: Name(Text("b")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: false, is_unsafe: false, params: [], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::FnDef>(2) }
|
> Function { name: Name(Text("b")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: false, is_unsafe: false, params: [], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::Fn>(2) }
|
||||||
"##]],
|
"##]],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -408,13 +408,13 @@ fn inner_item_attrs() {
|
||||||
inner attrs: Attrs { entries: None }
|
inner attrs: Attrs { entries: None }
|
||||||
|
|
||||||
top-level items:
|
top-level items:
|
||||||
Function { name: Name(Text("foo")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: false, is_unsafe: false, params: [], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::FnDef>(0) }
|
Function { name: Name(Text("foo")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: false, is_unsafe: false, params: [], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::Fn>(0) }
|
||||||
|
|
||||||
inner items:
|
inner items:
|
||||||
|
|
||||||
for AST FileAstId::<ra_syntax::ast::generated::nodes::Item>(1):
|
for AST FileAstId::<ra_syntax::ast::generated::nodes::Item>(1):
|
||||||
#[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("on_inner"))] }, input: None }]) }]
|
#[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("on_inner"))] }, input: None }]) }]
|
||||||
Function { name: Name(Text("inner")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: false, is_unsafe: false, params: [], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::FnDef>(1) }
|
Function { name: Name(Text("inner")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: false, is_unsafe: false, params: [], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::Fn>(1) }
|
||||||
|
|
||||||
"##]],
|
"##]],
|
||||||
);
|
);
|
||||||
|
|
|
@ -14,7 +14,7 @@ use crate::{
|
||||||
|
|
||||||
pub type Key<K, V> = crate::dyn_map::Key<InFile<K>, V, AstPtrPolicy<K, V>>;
|
pub type Key<K, V> = crate::dyn_map::Key<InFile<K>, V, AstPtrPolicy<K, V>>;
|
||||||
|
|
||||||
pub const FUNCTION: Key<ast::FnDef, FunctionId> = Key::new();
|
pub const FUNCTION: Key<ast::Fn, FunctionId> = Key::new();
|
||||||
pub const CONST: Key<ast::ConstDef, ConstId> = Key::new();
|
pub const CONST: Key<ast::ConstDef, ConstId> = Key::new();
|
||||||
pub const STATIC: Key<ast::StaticDef, StaticId> = Key::new();
|
pub const STATIC: Key<ast::StaticDef, StaticId> = Key::new();
|
||||||
pub const TYPE_ALIAS: Key<ast::TypeAliasDef, TypeAliasId> = Key::new();
|
pub const TYPE_ALIAS: Key<ast::TypeAliasDef, TypeAliasId> = Key::new();
|
||||||
|
|
|
@ -81,7 +81,7 @@ fn check_types_impl(ra_fixture: &str, display_source: bool) {
|
||||||
fn type_at_range(db: &TestDB, pos: FileRange) -> Ty {
|
fn type_at_range(db: &TestDB, pos: FileRange) -> Ty {
|
||||||
let file = db.parse(pos.file_id).ok().unwrap();
|
let file = db.parse(pos.file_id).ok().unwrap();
|
||||||
let expr = algo::find_node_at_range::<ast::Expr>(file.syntax(), pos.range).unwrap();
|
let expr = algo::find_node_at_range::<ast::Expr>(file.syntax(), pos.range).unwrap();
|
||||||
let fn_def = expr.syntax().ancestors().find_map(ast::FnDef::cast).unwrap();
|
let fn_def = expr.syntax().ancestors().find_map(ast::Fn::cast).unwrap();
|
||||||
let module = db.module_for_file(pos.file_id);
|
let module = db.module_for_file(pos.file_id);
|
||||||
let func = *module.child_by_source(db)[keys::FUNCTION]
|
let func = *module.child_by_source(db)[keys::FUNCTION]
|
||||||
.get(&InFile::new(pos.file_id.into(), fn_def))
|
.get(&InFile::new(pos.file_id.into(), fn_def))
|
||||||
|
|
|
@ -59,7 +59,7 @@ pub(crate) fn incoming_calls(db: &RootDatabase, position: FilePosition) -> Optio
|
||||||
if let Some(nav) = syntax.ancestors().find_map(|node| {
|
if let Some(nav) = syntax.ancestors().find_map(|node| {
|
||||||
match_ast! {
|
match_ast! {
|
||||||
match node {
|
match node {
|
||||||
ast::FnDef(it) => {
|
ast::Fn(it) => {
|
||||||
let def = sema.to_def(&it)?;
|
let def = sema.to_def(&it)?;
|
||||||
Some(def.to_nav(sema.db))
|
Some(def.to_nav(sema.db))
|
||||||
},
|
},
|
||||||
|
@ -181,8 +181,8 @@ fn caller() {
|
||||||
call<|>ee();
|
call<|>ee();
|
||||||
}
|
}
|
||||||
"#,
|
"#,
|
||||||
"callee FN_DEF FileId(1) 0..14 3..9",
|
"callee FN FileId(1) 0..14 3..9",
|
||||||
&["caller FN_DEF FileId(1) 15..44 18..24 : [33..39]"],
|
&["caller FN FileId(1) 15..44 18..24 : [33..39]"],
|
||||||
&[],
|
&[],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -197,8 +197,8 @@ fn caller() {
|
||||||
callee();
|
callee();
|
||||||
}
|
}
|
||||||
"#,
|
"#,
|
||||||
"callee FN_DEF FileId(1) 0..14 3..9",
|
"callee FN FileId(1) 0..14 3..9",
|
||||||
&["caller FN_DEF FileId(1) 15..44 18..24 : [33..39]"],
|
&["caller FN FileId(1) 15..44 18..24 : [33..39]"],
|
||||||
&[],
|
&[],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -214,8 +214,8 @@ fn caller() {
|
||||||
callee();
|
callee();
|
||||||
}
|
}
|
||||||
"#,
|
"#,
|
||||||
"callee FN_DEF FileId(1) 0..14 3..9",
|
"callee FN FileId(1) 0..14 3..9",
|
||||||
&["caller FN_DEF FileId(1) 15..58 18..24 : [33..39, 47..53]"],
|
&["caller FN FileId(1) 15..58 18..24 : [33..39, 47..53]"],
|
||||||
&[],
|
&[],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -234,10 +234,10 @@ fn caller2() {
|
||||||
callee();
|
callee();
|
||||||
}
|
}
|
||||||
"#,
|
"#,
|
||||||
"callee FN_DEF FileId(1) 0..14 3..9",
|
"callee FN FileId(1) 0..14 3..9",
|
||||||
&[
|
&[
|
||||||
"caller1 FN_DEF FileId(1) 15..45 18..25 : [34..40]",
|
"caller1 FN FileId(1) 15..45 18..25 : [34..40]",
|
||||||
"caller2 FN_DEF FileId(1) 47..77 50..57 : [66..72]",
|
"caller2 FN FileId(1) 47..77 50..57 : [66..72]",
|
||||||
],
|
],
|
||||||
&[],
|
&[],
|
||||||
);
|
);
|
||||||
|
@ -263,10 +263,10 @@ mod tests {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
"#,
|
"#,
|
||||||
"callee FN_DEF FileId(1) 0..14 3..9",
|
"callee FN FileId(1) 0..14 3..9",
|
||||||
&[
|
&[
|
||||||
"caller1 FN_DEF FileId(1) 15..45 18..25 : [34..40]",
|
"caller1 FN FileId(1) 15..45 18..25 : [34..40]",
|
||||||
"test_caller FN_DEF FileId(1) 95..149 110..121 : [134..140]",
|
"test_caller FN FileId(1) 95..149 110..121 : [134..140]",
|
||||||
],
|
],
|
||||||
&[],
|
&[],
|
||||||
);
|
);
|
||||||
|
@ -287,8 +287,8 @@ fn caller() {
|
||||||
//- /foo/mod.rs
|
//- /foo/mod.rs
|
||||||
pub fn callee() {}
|
pub fn callee() {}
|
||||||
"#,
|
"#,
|
||||||
"callee FN_DEF FileId(2) 0..18 7..13",
|
"callee FN FileId(2) 0..18 7..13",
|
||||||
&["caller FN_DEF FileId(1) 27..56 30..36 : [45..51]"],
|
&["caller FN FileId(1) 27..56 30..36 : [45..51]"],
|
||||||
&[],
|
&[],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -304,9 +304,9 @@ fn call<|>er() {
|
||||||
callee();
|
callee();
|
||||||
}
|
}
|
||||||
"#,
|
"#,
|
||||||
"caller FN_DEF FileId(1) 15..58 18..24",
|
"caller FN FileId(1) 15..58 18..24",
|
||||||
&[],
|
&[],
|
||||||
&["callee FN_DEF FileId(1) 0..14 3..9 : [33..39, 47..53]"],
|
&["callee FN FileId(1) 0..14 3..9 : [33..39, 47..53]"],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -325,9 +325,9 @@ fn call<|>er() {
|
||||||
//- /foo/mod.rs
|
//- /foo/mod.rs
|
||||||
pub fn callee() {}
|
pub fn callee() {}
|
||||||
"#,
|
"#,
|
||||||
"caller FN_DEF FileId(1) 27..56 30..36",
|
"caller FN FileId(1) 27..56 30..36",
|
||||||
&[],
|
&[],
|
||||||
&["callee FN_DEF FileId(2) 0..18 7..13 : [45..51]"],
|
&["callee FN FileId(2) 0..18 7..13 : [45..51]"],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -348,9 +348,9 @@ fn caller3() {
|
||||||
|
|
||||||
}
|
}
|
||||||
"#,
|
"#,
|
||||||
"caller2 FN_DEF FileId(1) 33..64 36..43",
|
"caller2 FN FileId(1) 33..64 36..43",
|
||||||
&["caller1 FN_DEF FileId(1) 0..31 3..10 : [19..26]"],
|
&["caller1 FN FileId(1) 0..31 3..10 : [19..26]"],
|
||||||
&["caller3 FN_DEF FileId(1) 66..83 69..76 : [52..59]"],
|
&["caller3 FN FileId(1) 66..83 69..76 : [52..59]"],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -368,9 +368,9 @@ fn main() {
|
||||||
a<|>()
|
a<|>()
|
||||||
}
|
}
|
||||||
"#,
|
"#,
|
||||||
"a FN_DEF FileId(1) 0..18 3..4",
|
"a FN FileId(1) 0..18 3..4",
|
||||||
&["main FN_DEF FileId(1) 31..52 34..38 : [47..48]"],
|
&["main FN FileId(1) 31..52 34..38 : [47..48]"],
|
||||||
&["b FN_DEF FileId(1) 20..29 23..24 : [13..14]"],
|
&["b FN FileId(1) 20..29 23..24 : [13..14]"],
|
||||||
);
|
);
|
||||||
|
|
||||||
check_hierarchy(
|
check_hierarchy(
|
||||||
|
@ -385,8 +385,8 @@ fn main() {
|
||||||
a()
|
a()
|
||||||
}
|
}
|
||||||
"#,
|
"#,
|
||||||
"b FN_DEF FileId(1) 20..29 23..24",
|
"b FN FileId(1) 20..29 23..24",
|
||||||
&["a FN_DEF FileId(1) 0..18 3..4 : [13..14]"],
|
&["a FN FileId(1) 0..18 3..4 : [13..14]"],
|
||||||
&[],
|
&[],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,8 +19,8 @@ pub(super) fn complete_fn_param(acc: &mut Completions, ctx: &CompletionContext)
|
||||||
|
|
||||||
let mut params = FxHashMap::default();
|
let mut params = FxHashMap::default();
|
||||||
|
|
||||||
let me = ctx.token.ancestors().find_map(ast::FnDef::cast);
|
let me = ctx.token.ancestors().find_map(ast::Fn::cast);
|
||||||
let mut process_fn = |func: ast::FnDef| {
|
let mut process_fn = |func: ast::Fn| {
|
||||||
if Some(&func) == me.as_ref() {
|
if Some(&func) == me.as_ref() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -34,15 +34,15 @@ pub(super) fn complete_fn_param(acc: &mut Completions, ctx: &CompletionContext)
|
||||||
match_ast! {
|
match_ast! {
|
||||||
match node {
|
match node {
|
||||||
ast::SourceFile(it) => it.items().filter_map(|item| match item {
|
ast::SourceFile(it) => it.items().filter_map(|item| match item {
|
||||||
ast::Item::FnDef(it) => Some(it),
|
ast::Item::Fn(it) => Some(it),
|
||||||
_ => None,
|
_ => None,
|
||||||
}).for_each(&mut process_fn),
|
}).for_each(&mut process_fn),
|
||||||
ast::ItemList(it) => it.items().filter_map(|item| match item {
|
ast::ItemList(it) => it.items().filter_map(|item| match item {
|
||||||
ast::Item::FnDef(it) => Some(it),
|
ast::Item::Fn(it) => Some(it),
|
||||||
_ => None,
|
_ => None,
|
||||||
}).for_each(&mut process_fn),
|
}).for_each(&mut process_fn),
|
||||||
ast::AssocItemList(it) => it.assoc_items().filter_map(|item| match item {
|
ast::AssocItemList(it) => it.assoc_items().filter_map(|item| match item {
|
||||||
ast::AssocItem::FnDef(it) => Some(it),
|
ast::AssocItem::Fn(it) => Some(it),
|
||||||
_ => None,
|
_ => None,
|
||||||
}).for_each(&mut process_fn),
|
}).for_each(&mut process_fn),
|
||||||
_ => continue,
|
_ => continue,
|
||||||
|
|
|
@ -169,7 +169,7 @@ fn add_keyword(ctx: &CompletionContext, acc: &mut Completions, kw: &str, snippet
|
||||||
|
|
||||||
fn complete_return(
|
fn complete_return(
|
||||||
ctx: &CompletionContext,
|
ctx: &CompletionContext,
|
||||||
fn_def: &ast::FnDef,
|
fn_def: &ast::Fn,
|
||||||
can_be_stmt: bool,
|
can_be_stmt: bool,
|
||||||
) -> Option<CompletionItem> {
|
) -> Option<CompletionItem> {
|
||||||
let snip = match (can_be_stmt, fn_def.ret_type().is_some()) {
|
let snip = match (can_be_stmt, fn_def.ret_type().is_some()) {
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
//!
|
//!
|
||||||
//! This module adds the completion items related to implementing associated
|
//! This module adds the completion items related to implementing associated
|
||||||
//! items within a `impl Trait for Struct` block. The current context node
|
//! items within a `impl Trait for Struct` block. The current context node
|
||||||
//! must be within either a `FN_DEF`, `TYPE_ALIAS_DEF`, or `CONST_DEF` node
|
//! must be within either a `FN`, `TYPE_ALIAS_DEF`, or `CONST_DEF` node
|
||||||
//! and an direct child of an `IMPL_DEF`.
|
//! and an direct child of an `IMPL_DEF`.
|
||||||
//!
|
//!
|
||||||
//! # Examples
|
//! # Examples
|
||||||
|
@ -63,7 +63,7 @@ pub(crate) fn complete_trait_impl(acc: &mut Completions, ctx: &CompletionContext
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
|
|
||||||
SyntaxKind::FN_DEF => {
|
SyntaxKind::FN => {
|
||||||
for missing_fn in get_missing_assoc_items(&ctx.sema, &impl_def)
|
for missing_fn in get_missing_assoc_items(&ctx.sema, &impl_def)
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.filter_map(|item| match item {
|
.filter_map(|item| match item {
|
||||||
|
@ -106,7 +106,7 @@ pub(crate) fn complete_trait_impl(acc: &mut Completions, ctx: &CompletionContext
|
||||||
|
|
||||||
fn completion_match(ctx: &CompletionContext) -> Option<(SyntaxNode, ImplDef)> {
|
fn completion_match(ctx: &CompletionContext) -> Option<(SyntaxNode, ImplDef)> {
|
||||||
let (trigger, impl_def_offset) = ctx.token.ancestors().find_map(|p| match p.kind() {
|
let (trigger, impl_def_offset) = ctx.token.ancestors().find_map(|p| match p.kind() {
|
||||||
SyntaxKind::FN_DEF
|
SyntaxKind::FN
|
||||||
| SyntaxKind::TYPE_ALIAS_DEF
|
| SyntaxKind::TYPE_ALIAS_DEF
|
||||||
| SyntaxKind::CONST_DEF
|
| SyntaxKind::CONST_DEF
|
||||||
| SyntaxKind::BLOCK_EXPR => Some((p, 2)),
|
| SyntaxKind::BLOCK_EXPR => Some((p, 2)),
|
||||||
|
|
|
@ -35,7 +35,7 @@ pub(crate) struct CompletionContext<'a> {
|
||||||
pub(super) krate: Option<hir::Crate>,
|
pub(super) krate: Option<hir::Crate>,
|
||||||
pub(super) expected_type: Option<Type>,
|
pub(super) expected_type: Option<Type>,
|
||||||
pub(super) name_ref_syntax: Option<ast::NameRef>,
|
pub(super) name_ref_syntax: Option<ast::NameRef>,
|
||||||
pub(super) function_syntax: Option<ast::FnDef>,
|
pub(super) function_syntax: Option<ast::Fn>,
|
||||||
pub(super) use_item_syntax: Option<ast::Use>,
|
pub(super) use_item_syntax: Option<ast::Use>,
|
||||||
pub(super) record_lit_syntax: Option<ast::RecordLit>,
|
pub(super) record_lit_syntax: Option<ast::RecordLit>,
|
||||||
pub(super) record_pat_syntax: Option<ast::RecordPat>,
|
pub(super) record_pat_syntax: Option<ast::RecordPat>,
|
||||||
|
@ -349,7 +349,7 @@ impl<'a> CompletionContext<'a> {
|
||||||
.sema
|
.sema
|
||||||
.ancestors_with_macros(self.token.parent())
|
.ancestors_with_macros(self.token.parent())
|
||||||
.take_while(|it| it.kind() != SOURCE_FILE && it.kind() != MODULE)
|
.take_while(|it| it.kind() != SOURCE_FILE && it.kind() != MODULE)
|
||||||
.find_map(ast::FnDef::cast);
|
.find_map(ast::Fn::cast);
|
||||||
|
|
||||||
self.record_field_syntax = self
|
self.record_field_syntax = self
|
||||||
.sema
|
.sema
|
||||||
|
|
|
@ -134,7 +134,7 @@ pub(crate) fn is_in_loop_body(element: SyntaxElement) -> bool {
|
||||||
NodeOrToken::Token(token) => token.parent(),
|
NodeOrToken::Token(token) => token.parent(),
|
||||||
};
|
};
|
||||||
for node in leaf.ancestors() {
|
for node in leaf.ancestors() {
|
||||||
if node.kind() == FN_DEF || node.kind() == LAMBDA_EXPR {
|
if node.kind() == FN || node.kind() == LAMBDA_EXPR {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
let loop_body = match_ast! {
|
let loop_body = match_ast! {
|
||||||
|
|
|
@ -16,7 +16,7 @@ pub use navigation_target::NavigationTarget;
|
||||||
pub(crate) use navigation_target::{ToNav, TryToNav};
|
pub(crate) use navigation_target::{ToNav, TryToNav};
|
||||||
pub(crate) use short_label::ShortLabel;
|
pub(crate) use short_label::ShortLabel;
|
||||||
|
|
||||||
pub(crate) fn function_declaration(node: &ast::FnDef) -> String {
|
pub(crate) fn function_declaration(node: &ast::Fn) -> String {
|
||||||
let mut buf = String::new();
|
let mut buf = String::new();
|
||||||
if let Some(vis) = node.visibility() {
|
if let Some(vis) = node.visibility() {
|
||||||
format_to!(buf, "{} ", vis);
|
format_to!(buf, "{} ", vis);
|
||||||
|
|
|
@ -379,7 +379,7 @@ pub(crate) fn docs_from_symbol(db: &RootDatabase, symbol: &FileSymbol) -> Option
|
||||||
|
|
||||||
match_ast! {
|
match_ast! {
|
||||||
match node {
|
match node {
|
||||||
ast::FnDef(it) => it.doc_comment_text(),
|
ast::Fn(it) => it.doc_comment_text(),
|
||||||
ast::StructDef(it) => it.doc_comment_text(),
|
ast::StructDef(it) => it.doc_comment_text(),
|
||||||
ast::EnumDef(it) => it.doc_comment_text(),
|
ast::EnumDef(it) => it.doc_comment_text(),
|
||||||
ast::TraitDef(it) => it.doc_comment_text(),
|
ast::TraitDef(it) => it.doc_comment_text(),
|
||||||
|
@ -404,7 +404,7 @@ pub(crate) fn description_from_symbol(db: &RootDatabase, symbol: &FileSymbol) ->
|
||||||
|
|
||||||
match_ast! {
|
match_ast! {
|
||||||
match node {
|
match node {
|
||||||
ast::FnDef(it) => it.short_label(),
|
ast::Fn(it) => it.short_label(),
|
||||||
ast::StructDef(it) => it.short_label(),
|
ast::StructDef(it) => it.short_label(),
|
||||||
ast::EnumDef(it) => it.short_label(),
|
ast::EnumDef(it) => it.short_label(),
|
||||||
ast::TraitDef(it) => it.short_label(),
|
ast::TraitDef(it) => it.short_label(),
|
||||||
|
|
|
@ -7,7 +7,7 @@ pub(crate) trait ShortLabel {
|
||||||
fn short_label(&self) -> Option<String>;
|
fn short_label(&self) -> Option<String>;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ShortLabel for ast::FnDef {
|
impl ShortLabel for ast::Fn {
|
||||||
fn short_label(&self) -> Option<String> {
|
fn short_label(&self) -> Option<String> {
|
||||||
Some(crate::display::function_declaration(self))
|
Some(crate::display::function_declaration(self))
|
||||||
}
|
}
|
||||||
|
|
|
@ -111,7 +111,7 @@ fn structure_node(node: &SyntaxNode) -> Option<StructureNode> {
|
||||||
|
|
||||||
match_ast! {
|
match_ast! {
|
||||||
match node {
|
match node {
|
||||||
ast::FnDef(it) => {
|
ast::Fn(it) => {
|
||||||
let mut detail = String::from("fn");
|
let mut detail = String::from("fn");
|
||||||
if let Some(type_param_list) = it.type_param_list() {
|
if let Some(type_param_list) = it.type_param_list() {
|
||||||
collapse_ws(type_param_list.syntax(), &mut detail);
|
collapse_ws(type_param_list.syntax(), &mut detail);
|
||||||
|
@ -271,7 +271,7 @@ fn very_obsolete() {}
|
||||||
label: "bar1",
|
label: "bar1",
|
||||||
navigation_range: 43..47,
|
navigation_range: 43..47,
|
||||||
node_range: 40..52,
|
node_range: 40..52,
|
||||||
kind: FN_DEF,
|
kind: FN,
|
||||||
detail: Some(
|
detail: Some(
|
||||||
"fn()",
|
"fn()",
|
||||||
),
|
),
|
||||||
|
@ -284,7 +284,7 @@ fn very_obsolete() {}
|
||||||
label: "bar2",
|
label: "bar2",
|
||||||
navigation_range: 60..64,
|
navigation_range: 60..64,
|
||||||
node_range: 57..81,
|
node_range: 57..81,
|
||||||
kind: FN_DEF,
|
kind: FN,
|
||||||
detail: Some(
|
detail: Some(
|
||||||
"fn<T>(t: T) -> T",
|
"fn<T>(t: T) -> T",
|
||||||
),
|
),
|
||||||
|
@ -297,7 +297,7 @@ fn very_obsolete() {}
|
||||||
label: "bar3",
|
label: "bar3",
|
||||||
navigation_range: 89..93,
|
navigation_range: 89..93,
|
||||||
node_range: 86..156,
|
node_range: 86..156,
|
||||||
kind: FN_DEF,
|
kind: FN,
|
||||||
detail: Some(
|
detail: Some(
|
||||||
"fn<A, B>(a: A, b: B) -> Vec< u32 >",
|
"fn<A, B>(a: A, b: B) -> Vec< u32 >",
|
||||||
),
|
),
|
||||||
|
@ -417,7 +417,7 @@ fn very_obsolete() {}
|
||||||
label: "obsolete",
|
label: "obsolete",
|
||||||
navigation_range: 428..436,
|
navigation_range: 428..436,
|
||||||
node_range: 411..441,
|
node_range: 411..441,
|
||||||
kind: FN_DEF,
|
kind: FN,
|
||||||
detail: Some(
|
detail: Some(
|
||||||
"fn()",
|
"fn()",
|
||||||
),
|
),
|
||||||
|
@ -428,7 +428,7 @@ fn very_obsolete() {}
|
||||||
label: "very_obsolete",
|
label: "very_obsolete",
|
||||||
navigation_range: 481..494,
|
navigation_range: 481..494,
|
||||||
node_range: 443..499,
|
node_range: 443..499,
|
||||||
kind: FN_DEF,
|
kind: FN,
|
||||||
detail: Some(
|
detail: Some(
|
||||||
"fn()",
|
"fn()",
|
||||||
),
|
),
|
||||||
|
|
|
@ -1361,7 +1361,7 @@ fn foo_<|>test() {}
|
||||||
11..19,
|
11..19,
|
||||||
),
|
),
|
||||||
name: "foo_test",
|
name: "foo_test",
|
||||||
kind: FN_DEF,
|
kind: FN,
|
||||||
container_name: None,
|
container_name: None,
|
||||||
description: None,
|
description: None,
|
||||||
docs: None,
|
docs: None,
|
||||||
|
|
|
@ -376,7 +376,7 @@ impl Foo {
|
||||||
}
|
}
|
||||||
"#,
|
"#,
|
||||||
);
|
);
|
||||||
check_result(refs, "f FN_DEF FileId(1) 27..43 30..31 Other", &[]);
|
check_result(refs, "f FN FileId(1) 27..43 30..31 Other", &[]);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -514,7 +514,7 @@ pub(super) struct Foo<|> {
|
||||||
let refs = analysis.find_all_refs(pos, None).unwrap().unwrap();
|
let refs = analysis.find_all_refs(pos, None).unwrap().unwrap();
|
||||||
check_result(
|
check_result(
|
||||||
refs,
|
refs,
|
||||||
"quux FN_DEF FileId(1) 19..35 26..30 Other",
|
"quux FN FileId(1) 19..35 26..30 Other",
|
||||||
&["FileId(2) 16..20 StructLiteral", "FileId(3) 16..20 StructLiteral"],
|
&["FileId(2) 16..20 StructLiteral", "FileId(3) 16..20 StructLiteral"],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -522,7 +522,7 @@ pub(super) struct Foo<|> {
|
||||||
analysis.find_all_refs(pos, Some(SearchScope::single_file(bar))).unwrap().unwrap();
|
analysis.find_all_refs(pos, Some(SearchScope::single_file(bar))).unwrap().unwrap();
|
||||||
check_result(
|
check_result(
|
||||||
refs,
|
refs,
|
||||||
"quux FN_DEF FileId(1) 19..35 26..30 Other",
|
"quux FN FileId(1) 19..35 26..30 Other",
|
||||||
&["FileId(3) 16..20 StructLiteral"],
|
&["FileId(3) 16..20 StructLiteral"],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -619,7 +619,7 @@ fn main() {
|
||||||
);
|
);
|
||||||
check_result(
|
check_result(
|
||||||
refs,
|
refs,
|
||||||
"new FN_DEF FileId(1) 54..101 61..64 Other",
|
"new FN FileId(1) 54..101 61..64 Other",
|
||||||
&["FileId(1) 146..149 StructLiteral"],
|
&["FileId(1) 146..149 StructLiteral"],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -646,7 +646,7 @@ fn main() {
|
||||||
let refs = analysis.find_all_refs(pos, None).unwrap().unwrap();
|
let refs = analysis.find_all_refs(pos, None).unwrap().unwrap();
|
||||||
check_result(
|
check_result(
|
||||||
refs,
|
refs,
|
||||||
"f FN_DEF FileId(1) 26..35 29..30 Other",
|
"f FN FileId(1) 26..35 29..30 Other",
|
||||||
&["FileId(2) 11..12 Other", "FileId(2) 28..29 StructLiteral"],
|
&["FileId(2) 11..12 Other", "FileId(2) 28..29 StructLiteral"],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -149,7 +149,7 @@ fn rename_to_self(
|
||||||
let source_file = sema.parse(position.file_id);
|
let source_file = sema.parse(position.file_id);
|
||||||
let syn = source_file.syntax();
|
let syn = source_file.syntax();
|
||||||
|
|
||||||
let fn_def = find_node_at_offset::<ast::FnDef>(syn, position.offset)?;
|
let fn_def = find_node_at_offset::<ast::Fn>(syn, position.offset)?;
|
||||||
let params = fn_def.param_list()?;
|
let params = fn_def.param_list()?;
|
||||||
if params.self_param().is_some() {
|
if params.self_param().is_some() {
|
||||||
return None; // method already has self param
|
return None; // method already has self param
|
||||||
|
@ -221,7 +221,7 @@ fn rename_self_to_param(
|
||||||
let syn = source_file.syntax();
|
let syn = source_file.syntax();
|
||||||
|
|
||||||
let text = sema.db.file_text(position.file_id);
|
let text = sema.db.file_text(position.file_id);
|
||||||
let fn_def = find_node_at_offset::<ast::FnDef>(syn, position.offset)?;
|
let fn_def = find_node_at_offset::<ast::Fn>(syn, position.offset)?;
|
||||||
let search_range = fn_def.syntax().text_range();
|
let search_range = fn_def.syntax().text_range();
|
||||||
|
|
||||||
let mut edits: Vec<SourceFileEdit> = vec![];
|
let mut edits: Vec<SourceFileEdit> = vec![];
|
||||||
|
|
|
@ -102,7 +102,7 @@ pub(crate) fn runnable(
|
||||||
) -> Option<Runnable> {
|
) -> Option<Runnable> {
|
||||||
match_ast! {
|
match_ast! {
|
||||||
match item {
|
match item {
|
||||||
ast::FnDef(it) => runnable_fn(sema, it, file_id),
|
ast::Fn(it) => runnable_fn(sema, it, file_id),
|
||||||
ast::Module(it) => runnable_mod(sema, it, file_id),
|
ast::Module(it) => runnable_mod(sema, it, file_id),
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
|
@ -111,7 +111,7 @@ pub(crate) fn runnable(
|
||||||
|
|
||||||
fn runnable_fn(
|
fn runnable_fn(
|
||||||
sema: &Semantics<RootDatabase>,
|
sema: &Semantics<RootDatabase>,
|
||||||
fn_def: ast::FnDef,
|
fn_def: ast::Fn,
|
||||||
file_id: FileId,
|
file_id: FileId,
|
||||||
) -> Option<Runnable> {
|
) -> Option<Runnable> {
|
||||||
let name_string = fn_def.name()?.text().to_string();
|
let name_string = fn_def.name()?.text().to_string();
|
||||||
|
@ -188,7 +188,7 @@ pub struct TestAttr {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TestAttr {
|
impl TestAttr {
|
||||||
fn from_fn(fn_def: &ast::FnDef) -> TestAttr {
|
fn from_fn(fn_def: &ast::Fn) -> TestAttr {
|
||||||
let ignore = fn_def
|
let ignore = fn_def
|
||||||
.attrs()
|
.attrs()
|
||||||
.filter_map(|attr| attr.simple_name())
|
.filter_map(|attr| attr.simple_name())
|
||||||
|
@ -203,7 +203,7 @@ impl TestAttr {
|
||||||
///
|
///
|
||||||
/// It may produce false positives, for example, `#[wasm_bindgen_test]` requires a different command to run the test,
|
/// It may produce false positives, for example, `#[wasm_bindgen_test]` requires a different command to run the test,
|
||||||
/// but it's better than not to have the runnables for the tests at all.
|
/// but it's better than not to have the runnables for the tests at all.
|
||||||
fn has_test_related_attribute(fn_def: &ast::FnDef) -> bool {
|
fn has_test_related_attribute(fn_def: &ast::Fn) -> bool {
|
||||||
fn_def
|
fn_def
|
||||||
.attrs()
|
.attrs()
|
||||||
.filter_map(|attr| attr.path())
|
.filter_map(|attr| attr.path())
|
||||||
|
@ -211,7 +211,7 @@ fn has_test_related_attribute(fn_def: &ast::FnDef) -> bool {
|
||||||
.any(|attribute_text| attribute_text.contains("test"))
|
.any(|attribute_text| attribute_text.contains("test"))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn has_doc_test(fn_def: &ast::FnDef) -> bool {
|
fn has_doc_test(fn_def: &ast::Fn) -> bool {
|
||||||
fn_def.doc_comment_text().map_or(false, |comment| comment.contains("```"))
|
fn_def.doc_comment_text().map_or(false, |comment| comment.contains("```"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -246,7 +246,7 @@ fn has_test_function_or_multiple_test_submodules(module: &ast::Module) -> bool {
|
||||||
|
|
||||||
for item in item_list.items() {
|
for item in item_list.items() {
|
||||||
match item {
|
match item {
|
||||||
ast::Item::FnDef(f) => {
|
ast::Item::Fn(f) => {
|
||||||
if has_test_related_attribute(&f) {
|
if has_test_related_attribute(&f) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -320,7 +320,7 @@ fn bench() {}
|
||||||
4..8,
|
4..8,
|
||||||
),
|
),
|
||||||
name: "main",
|
name: "main",
|
||||||
kind: FN_DEF,
|
kind: FN,
|
||||||
container_name: None,
|
container_name: None,
|
||||||
description: None,
|
description: None,
|
||||||
docs: None,
|
docs: None,
|
||||||
|
@ -338,7 +338,7 @@ fn bench() {}
|
||||||
26..34,
|
26..34,
|
||||||
),
|
),
|
||||||
name: "test_foo",
|
name: "test_foo",
|
||||||
kind: FN_DEF,
|
kind: FN,
|
||||||
container_name: None,
|
container_name: None,
|
||||||
description: None,
|
description: None,
|
||||||
docs: None,
|
docs: None,
|
||||||
|
@ -363,7 +363,7 @@ fn bench() {}
|
||||||
62..70,
|
62..70,
|
||||||
),
|
),
|
||||||
name: "test_foo",
|
name: "test_foo",
|
||||||
kind: FN_DEF,
|
kind: FN,
|
||||||
container_name: None,
|
container_name: None,
|
||||||
description: None,
|
description: None,
|
||||||
docs: None,
|
docs: None,
|
||||||
|
@ -388,7 +388,7 @@ fn bench() {}
|
||||||
89..94,
|
89..94,
|
||||||
),
|
),
|
||||||
name: "bench",
|
name: "bench",
|
||||||
kind: FN_DEF,
|
kind: FN,
|
||||||
container_name: None,
|
container_name: None,
|
||||||
description: None,
|
description: None,
|
||||||
docs: None,
|
docs: None,
|
||||||
|
@ -431,7 +431,7 @@ fn foo() {}
|
||||||
4..8,
|
4..8,
|
||||||
),
|
),
|
||||||
name: "main",
|
name: "main",
|
||||||
kind: FN_DEF,
|
kind: FN,
|
||||||
container_name: None,
|
container_name: None,
|
||||||
description: None,
|
description: None,
|
||||||
docs: None,
|
docs: None,
|
||||||
|
@ -447,7 +447,7 @@ fn foo() {}
|
||||||
full_range: 15..57,
|
full_range: 15..57,
|
||||||
focus_range: None,
|
focus_range: None,
|
||||||
name: "foo",
|
name: "foo",
|
||||||
kind: FN_DEF,
|
kind: FN,
|
||||||
container_name: None,
|
container_name: None,
|
||||||
description: None,
|
description: None,
|
||||||
docs: None,
|
docs: None,
|
||||||
|
@ -493,7 +493,7 @@ impl Data {
|
||||||
4..8,
|
4..8,
|
||||||
),
|
),
|
||||||
name: "main",
|
name: "main",
|
||||||
kind: FN_DEF,
|
kind: FN,
|
||||||
container_name: None,
|
container_name: None,
|
||||||
description: None,
|
description: None,
|
||||||
docs: None,
|
docs: None,
|
||||||
|
@ -509,7 +509,7 @@ impl Data {
|
||||||
full_range: 44..98,
|
full_range: 44..98,
|
||||||
focus_range: None,
|
focus_range: None,
|
||||||
name: "foo",
|
name: "foo",
|
||||||
kind: FN_DEF,
|
kind: FN,
|
||||||
container_name: None,
|
container_name: None,
|
||||||
description: None,
|
description: None,
|
||||||
docs: None,
|
docs: None,
|
||||||
|
@ -570,7 +570,7 @@ mod test_mod {
|
||||||
35..44,
|
35..44,
|
||||||
),
|
),
|
||||||
name: "test_foo1",
|
name: "test_foo1",
|
||||||
kind: FN_DEF,
|
kind: FN,
|
||||||
container_name: None,
|
container_name: None,
|
||||||
description: None,
|
description: None,
|
||||||
docs: None,
|
docs: None,
|
||||||
|
@ -670,7 +670,7 @@ mod root_tests {
|
||||||
107..121,
|
107..121,
|
||||||
),
|
),
|
||||||
name: "nested_test_11",
|
name: "nested_test_11",
|
||||||
kind: FN_DEF,
|
kind: FN,
|
||||||
container_name: None,
|
container_name: None,
|
||||||
description: None,
|
description: None,
|
||||||
docs: None,
|
docs: None,
|
||||||
|
@ -695,7 +695,7 @@ mod root_tests {
|
||||||
163..177,
|
163..177,
|
||||||
),
|
),
|
||||||
name: "nested_test_12",
|
name: "nested_test_12",
|
||||||
kind: FN_DEF,
|
kind: FN,
|
||||||
container_name: None,
|
container_name: None,
|
||||||
description: None,
|
description: None,
|
||||||
docs: None,
|
docs: None,
|
||||||
|
@ -740,7 +740,7 @@ mod root_tests {
|
||||||
258..271,
|
258..271,
|
||||||
),
|
),
|
||||||
name: "nested_test_2",
|
name: "nested_test_2",
|
||||||
kind: FN_DEF,
|
kind: FN,
|
||||||
container_name: None,
|
container_name: None,
|
||||||
description: None,
|
description: None,
|
||||||
docs: None,
|
docs: None,
|
||||||
|
@ -783,7 +783,7 @@ fn test_foo1() {}
|
||||||
36..45,
|
36..45,
|
||||||
),
|
),
|
||||||
name: "test_foo1",
|
name: "test_foo1",
|
||||||
kind: FN_DEF,
|
kind: FN,
|
||||||
container_name: None,
|
container_name: None,
|
||||||
description: None,
|
description: None,
|
||||||
docs: None,
|
docs: None,
|
||||||
|
@ -831,7 +831,7 @@ fn test_foo1() {}
|
||||||
58..67,
|
58..67,
|
||||||
),
|
),
|
||||||
name: "test_foo1",
|
name: "test_foo1",
|
||||||
kind: FN_DEF,
|
kind: FN,
|
||||||
container_name: None,
|
container_name: None,
|
||||||
description: None,
|
description: None,
|
||||||
docs: None,
|
docs: None,
|
||||||
|
|
|
@ -464,7 +464,7 @@ fn highlight_element(
|
||||||
let db = sema.db;
|
let db = sema.db;
|
||||||
let mut binding_hash = None;
|
let mut binding_hash = None;
|
||||||
let highlight: Highlight = match element.kind() {
|
let highlight: Highlight = match element.kind() {
|
||||||
FN_DEF => {
|
FN => {
|
||||||
bindings_shadow_count.clear();
|
bindings_shadow_count.clear();
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
@ -713,7 +713,7 @@ fn highlight_name_by_syntax(name: ast::Name) -> Highlight {
|
||||||
TYPE_PARAM => HighlightTag::TypeParam,
|
TYPE_PARAM => HighlightTag::TypeParam,
|
||||||
RECORD_FIELD_DEF => HighlightTag::Field,
|
RECORD_FIELD_DEF => HighlightTag::Field,
|
||||||
MODULE => HighlightTag::Module,
|
MODULE => HighlightTag::Module,
|
||||||
FN_DEF => HighlightTag::Function,
|
FN => HighlightTag::Function,
|
||||||
CONST_DEF => HighlightTag::Constant,
|
CONST_DEF => HighlightTag::Constant,
|
||||||
STATIC_DEF => HighlightTag::Static,
|
STATIC_DEF => HighlightTag::Static,
|
||||||
ENUM_VARIANT => HighlightTag::EnumVariant,
|
ENUM_VARIANT => HighlightTag::EnumVariant,
|
||||||
|
|
|
@ -116,7 +116,7 @@ mod tests {
|
||||||
syn.trim(),
|
syn.trim(),
|
||||||
r#"
|
r#"
|
||||||
SOURCE_FILE@0..11
|
SOURCE_FILE@0..11
|
||||||
FN_DEF@0..11
|
FN@0..11
|
||||||
FN_KW@0..2 "fn"
|
FN_KW@0..2 "fn"
|
||||||
WHITESPACE@2..3 " "
|
WHITESPACE@2..3 " "
|
||||||
NAME@3..6
|
NAME@3..6
|
||||||
|
@ -148,7 +148,7 @@ fn test() {
|
||||||
syn.trim(),
|
syn.trim(),
|
||||||
r#"
|
r#"
|
||||||
SOURCE_FILE@0..60
|
SOURCE_FILE@0..60
|
||||||
FN_DEF@0..60
|
FN@0..60
|
||||||
FN_KW@0..2 "fn"
|
FN_KW@0..2 "fn"
|
||||||
WHITESPACE@2..3 " "
|
WHITESPACE@2..3 " "
|
||||||
NAME@3..7
|
NAME@3..7
|
||||||
|
@ -190,7 +190,7 @@ SOURCE_FILE@0..60
|
||||||
assert_eq_text!(
|
assert_eq_text!(
|
||||||
syn.trim(),
|
syn.trim(),
|
||||||
r#"
|
r#"
|
||||||
FN_DEF@0..11
|
FN@0..11
|
||||||
FN_KW@0..2 "fn"
|
FN_KW@0..2 "fn"
|
||||||
WHITESPACE@2..3 " "
|
WHITESPACE@2..3 " "
|
||||||
NAME@3..6
|
NAME@3..6
|
||||||
|
@ -258,7 +258,7 @@ fn bar() {
|
||||||
syn.trim(),
|
syn.trim(),
|
||||||
r#"
|
r#"
|
||||||
SOURCE_FILE@0..12
|
SOURCE_FILE@0..12
|
||||||
FN_DEF@0..12
|
FN@0..12
|
||||||
FN_KW@0..2 "fn"
|
FN_KW@0..2 "fn"
|
||||||
WHITESPACE@2..3 " "
|
WHITESPACE@2..3 " "
|
||||||
NAME@3..6
|
NAME@3..6
|
||||||
|
@ -292,7 +292,7 @@ fn bar() {
|
||||||
syn.trim(),
|
syn.trim(),
|
||||||
r#"
|
r#"
|
||||||
SOURCE_FILE@0..12
|
SOURCE_FILE@0..12
|
||||||
FN_DEF@0..12
|
FN@0..12
|
||||||
FN_KW@0..2 "fn"
|
FN_KW@0..2 "fn"
|
||||||
WHITESPACE@2..3 " "
|
WHITESPACE@2..3 " "
|
||||||
NAME@3..6
|
NAME@3..6
|
||||||
|
@ -325,7 +325,7 @@ fn bar() {
|
||||||
syn.trim(),
|
syn.trim(),
|
||||||
r#"
|
r#"
|
||||||
SOURCE_FILE@0..25
|
SOURCE_FILE@0..25
|
||||||
FN_DEF@0..12
|
FN@0..12
|
||||||
FN_KW@0..2 "fn"
|
FN_KW@0..2 "fn"
|
||||||
WHITESPACE@2..3 " "
|
WHITESPACE@2..3 " "
|
||||||
NAME@3..6
|
NAME@3..6
|
||||||
|
@ -339,7 +339,7 @@ SOURCE_FILE@0..25
|
||||||
WHITESPACE@10..11 "\n"
|
WHITESPACE@10..11 "\n"
|
||||||
R_CURLY@11..12 "}"
|
R_CURLY@11..12 "}"
|
||||||
WHITESPACE@12..13 "\n"
|
WHITESPACE@12..13 "\n"
|
||||||
FN_DEF@13..25
|
FN@13..25
|
||||||
FN_KW@13..15 "fn"
|
FN_KW@13..15 "fn"
|
||||||
WHITESPACE@15..16 " "
|
WHITESPACE@15..16 " "
|
||||||
NAME@16..19
|
NAME@16..19
|
||||||
|
|
|
@ -174,7 +174,7 @@ pub fn classify_name(sema: &Semantics<RootDatabase>, name: &ast::Name) -> Option
|
||||||
let def: hir::EnumVariant = sema.to_def(&it)?;
|
let def: hir::EnumVariant = sema.to_def(&it)?;
|
||||||
Some(NameClass::Definition(Definition::ModuleDef(def.into())))
|
Some(NameClass::Definition(Definition::ModuleDef(def.into())))
|
||||||
},
|
},
|
||||||
ast::FnDef(it) => {
|
ast::Fn(it) => {
|
||||||
let def: hir::Function = sema.to_def(&it)?;
|
let def: hir::Function = sema.to_def(&it)?;
|
||||||
Some(NameClass::Definition(Definition::ModuleDef(def.into())))
|
Some(NameClass::Definition(Definition::ModuleDef(def.into())))
|
||||||
},
|
},
|
||||||
|
|
|
@ -397,7 +397,7 @@ fn to_symbol(node: &SyntaxNode) -> Option<(SmolStr, SyntaxNodePtr, TextRange)> {
|
||||||
}
|
}
|
||||||
match_ast! {
|
match_ast! {
|
||||||
match node {
|
match node {
|
||||||
ast::FnDef(it) => decl(it),
|
ast::Fn(it) => decl(it),
|
||||||
ast::StructDef(it) => decl(it),
|
ast::StructDef(it) => decl(it),
|
||||||
ast::EnumDef(it) => decl(it),
|
ast::EnumDef(it) => decl(it),
|
||||||
ast::TraitDef(it) => decl(it),
|
ast::TraitDef(it) => decl(it),
|
||||||
|
|
|
@ -258,7 +258,7 @@ fn test_expr_order() {
|
||||||
assert_eq_text!(
|
assert_eq_text!(
|
||||||
dump.trim(),
|
dump.trim(),
|
||||||
r#"MACRO_ITEMS@0..15
|
r#"MACRO_ITEMS@0..15
|
||||||
FN_DEF@0..15
|
FN@0..15
|
||||||
FN_KW@0..2 "fn"
|
FN_KW@0..2 "fn"
|
||||||
NAME@2..5
|
NAME@2..5
|
||||||
IDENT@2..5 "bar"
|
IDENT@2..5 "bar"
|
||||||
|
|
|
@ -180,7 +180,7 @@ pub(super) fn maybe_item(p: &mut Parser, m: Marker, flavor: ItemFlavor) -> Resul
|
||||||
// unsafe const fn bar() {}
|
// unsafe const fn bar() {}
|
||||||
T![fn] => {
|
T![fn] => {
|
||||||
fn_def(p);
|
fn_def(p);
|
||||||
m.complete(p, FN_DEF);
|
m.complete(p, FN);
|
||||||
}
|
}
|
||||||
|
|
||||||
// test unsafe_trait
|
// test unsafe_trait
|
||||||
|
|
|
@ -126,7 +126,7 @@ pub enum SyntaxKind {
|
||||||
STRUCT_DEF,
|
STRUCT_DEF,
|
||||||
UNION_DEF,
|
UNION_DEF,
|
||||||
ENUM_DEF,
|
ENUM_DEF,
|
||||||
FN_DEF,
|
FN,
|
||||||
RET_TYPE,
|
RET_TYPE,
|
||||||
EXTERN_CRATE,
|
EXTERN_CRATE,
|
||||||
MODULE,
|
MODULE,
|
||||||
|
|
|
@ -29,9 +29,9 @@ impl ast::BinExpr {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ast::FnDef {
|
impl ast::Fn {
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn with_body(&self, body: ast::BlockExpr) -> ast::FnDef {
|
pub fn with_body(&self, body: ast::BlockExpr) -> ast::Fn {
|
||||||
let mut to_insert: ArrayVec<[SyntaxElement; 2]> = ArrayVec::new();
|
let mut to_insert: ArrayVec<[SyntaxElement; 2]> = ArrayVec::new();
|
||||||
let old_body_or_semi: SyntaxElement = if let Some(old_body) = self.body() {
|
let old_body_or_semi: SyntaxElement = if let Some(old_body) = self.body() {
|
||||||
old_body.syntax().clone().into()
|
old_body.syntax().clone().into()
|
||||||
|
|
|
@ -401,7 +401,7 @@ impl ast::BlockExpr {
|
||||||
Some(it) => it,
|
Some(it) => it,
|
||||||
None => return true,
|
None => return true,
|
||||||
};
|
};
|
||||||
!matches!(parent.kind(), FN_DEF | IF_EXPR | WHILE_EXPR | LOOP_EXPR | EFFECT_EXPR)
|
!matches!(parent.kind(), FN | IF_EXPR | WHILE_EXPR | LOOP_EXPR | EFFECT_EXPR)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -79,19 +79,19 @@ impl ExternCrate {
|
||||||
pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
|
pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
|
||||||
}
|
}
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||||
pub struct FnDef {
|
pub struct Fn {
|
||||||
pub(crate) syntax: SyntaxNode,
|
pub(crate) syntax: SyntaxNode,
|
||||||
}
|
}
|
||||||
impl ast::AttrsOwner for FnDef {}
|
impl ast::AttrsOwner for Fn {}
|
||||||
impl ast::NameOwner for FnDef {}
|
impl ast::NameOwner for Fn {}
|
||||||
impl ast::VisibilityOwner for FnDef {}
|
impl ast::VisibilityOwner for Fn {}
|
||||||
impl ast::TypeParamsOwner for FnDef {}
|
impl ast::TypeParamsOwner for Fn {}
|
||||||
impl FnDef {
|
impl Fn {
|
||||||
pub fn abi(&self) -> Option<Abi> { support::child(&self.syntax) }
|
|
||||||
pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) }
|
|
||||||
pub fn default_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![default]) }
|
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 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 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 fn_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![fn]) }
|
||||||
pub fn param_list(&self) -> Option<ParamList> { support::child(&self.syntax) }
|
pub fn param_list(&self) -> Option<ParamList> { support::child(&self.syntax) }
|
||||||
pub fn ret_type(&self) -> Option<RetType> { 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 struct Abi {
|
||||||
pub(crate) syntax: SyntaxNode,
|
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)]
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||||
pub struct TypeParamList {
|
pub struct TypeParamList {
|
||||||
pub(crate) syntax: SyntaxNode,
|
pub(crate) syntax: SyntaxNode,
|
||||||
|
@ -321,8 +323,9 @@ pub struct ParamList {
|
||||||
}
|
}
|
||||||
impl ParamList {
|
impl ParamList {
|
||||||
pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) }
|
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 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![')']) }
|
pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
|
||||||
}
|
}
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
#[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!['}']) }
|
pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) }
|
||||||
}
|
}
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
#[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 struct RecordFieldDefList {
|
||||||
pub(crate) syntax: SyntaxNode,
|
pub(crate) syntax: SyntaxNode,
|
||||||
}
|
}
|
||||||
|
@ -1173,32 +1202,6 @@ impl LetStmt {
|
||||||
pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
|
pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
|
||||||
}
|
}
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
#[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 struct PathSegment {
|
||||||
pub(crate) syntax: SyntaxNode,
|
pub(crate) syntax: SyntaxNode,
|
||||||
}
|
}
|
||||||
|
@ -1274,7 +1277,7 @@ pub enum Item {
|
||||||
EnumDef(EnumDef),
|
EnumDef(EnumDef),
|
||||||
ExternBlock(ExternBlock),
|
ExternBlock(ExternBlock),
|
||||||
ExternCrate(ExternCrate),
|
ExternCrate(ExternCrate),
|
||||||
FnDef(FnDef),
|
Fn(Fn),
|
||||||
ImplDef(ImplDef),
|
ImplDef(ImplDef),
|
||||||
MacroCall(MacroCall),
|
MacroCall(MacroCall),
|
||||||
Module(Module),
|
Module(Module),
|
||||||
|
@ -1303,6 +1306,24 @@ pub enum TypeRef {
|
||||||
DynTraitType(DynTraitType),
|
DynTraitType(DynTraitType),
|
||||||
}
|
}
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
#[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 {
|
pub enum FieldDefList {
|
||||||
RecordFieldDefList(RecordFieldDefList),
|
RecordFieldDefList(RecordFieldDefList),
|
||||||
TupleFieldDefList(TupleFieldDefList),
|
TupleFieldDefList(TupleFieldDefList),
|
||||||
|
@ -1343,7 +1364,7 @@ pub enum Expr {
|
||||||
}
|
}
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||||
pub enum AssocItem {
|
pub enum AssocItem {
|
||||||
FnDef(FnDef),
|
Fn(Fn),
|
||||||
TypeAliasDef(TypeAliasDef),
|
TypeAliasDef(TypeAliasDef),
|
||||||
ConstDef(ConstDef),
|
ConstDef(ConstDef),
|
||||||
MacroCall(MacroCall),
|
MacroCall(MacroCall),
|
||||||
|
@ -1351,24 +1372,6 @@ pub enum AssocItem {
|
||||||
impl ast::AttrsOwner for AssocItem {}
|
impl ast::AttrsOwner for AssocItem {}
|
||||||
impl ast::NameOwner for AssocItem {}
|
impl ast::NameOwner for AssocItem {}
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
#[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 {
|
pub enum Stmt {
|
||||||
LetStmt(LetStmt),
|
LetStmt(LetStmt),
|
||||||
ExprStmt(ExprStmt),
|
ExprStmt(ExprStmt),
|
||||||
|
@ -1381,7 +1384,7 @@ pub enum AttrInput {
|
||||||
}
|
}
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||||
pub enum ExternItem {
|
pub enum ExternItem {
|
||||||
FnDef(FnDef),
|
Fn(Fn),
|
||||||
StaticDef(StaticDef),
|
StaticDef(StaticDef),
|
||||||
}
|
}
|
||||||
impl ast::AttrsOwner for ExternItem {}
|
impl ast::AttrsOwner for ExternItem {}
|
||||||
|
@ -1463,8 +1466,8 @@ impl AstNode for ExternCrate {
|
||||||
}
|
}
|
||||||
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
||||||
}
|
}
|
||||||
impl AstNode for FnDef {
|
impl AstNode for Fn {
|
||||||
fn can_cast(kind: SyntaxKind) -> bool { kind == FN_DEF }
|
fn can_cast(kind: SyntaxKind) -> bool { kind == FN }
|
||||||
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
||||||
if Self::can_cast(syntax.kind()) {
|
if Self::can_cast(syntax.kind()) {
|
||||||
Some(Self { syntax })
|
Some(Self { syntax })
|
||||||
|
@ -1727,6 +1730,28 @@ impl AstNode for BlockExpr {
|
||||||
}
|
}
|
||||||
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
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 {
|
impl AstNode for RecordFieldDefList {
|
||||||
fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_FIELD_DEF_LIST }
|
fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_FIELD_DEF_LIST }
|
||||||
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
||||||
|
@ -2673,28 +2698,6 @@ impl AstNode for LetStmt {
|
||||||
}
|
}
|
||||||
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
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 {
|
impl AstNode for PathSegment {
|
||||||
fn can_cast(kind: SyntaxKind) -> bool { kind == PATH_SEGMENT }
|
fn can_cast(kind: SyntaxKind) -> bool { kind == PATH_SEGMENT }
|
||||||
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
||||||
|
@ -2784,8 +2787,8 @@ impl From<ExternBlock> for Item {
|
||||||
impl From<ExternCrate> for Item {
|
impl From<ExternCrate> for Item {
|
||||||
fn from(node: ExternCrate) -> Item { Item::ExternCrate(node) }
|
fn from(node: ExternCrate) -> Item { Item::ExternCrate(node) }
|
||||||
}
|
}
|
||||||
impl From<FnDef> for Item {
|
impl From<Fn> for Item {
|
||||||
fn from(node: FnDef) -> Item { Item::FnDef(node) }
|
fn from(node: Fn) -> Item { Item::Fn(node) }
|
||||||
}
|
}
|
||||||
impl From<ImplDef> for Item {
|
impl From<ImplDef> for Item {
|
||||||
fn from(node: ImplDef) -> Item { Item::ImplDef(node) }
|
fn from(node: ImplDef) -> Item { Item::ImplDef(node) }
|
||||||
|
@ -2817,7 +2820,7 @@ impl From<Use> for Item {
|
||||||
impl AstNode for Item {
|
impl AstNode for Item {
|
||||||
fn can_cast(kind: SyntaxKind) -> bool {
|
fn can_cast(kind: SyntaxKind) -> bool {
|
||||||
match kind {
|
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 => {
|
| MODULE | STATIC_DEF | STRUCT_DEF | TRAIT_DEF | TYPE_ALIAS_DEF | UNION_DEF | USE => {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
@ -2830,7 +2833,7 @@ impl AstNode for Item {
|
||||||
ENUM_DEF => Item::EnumDef(EnumDef { syntax }),
|
ENUM_DEF => Item::EnumDef(EnumDef { syntax }),
|
||||||
EXTERN_BLOCK => Item::ExternBlock(ExternBlock { syntax }),
|
EXTERN_BLOCK => Item::ExternBlock(ExternBlock { syntax }),
|
||||||
EXTERN_CRATE => Item::ExternCrate(ExternCrate { syntax }),
|
EXTERN_CRATE => Item::ExternCrate(ExternCrate { syntax }),
|
||||||
FN_DEF => Item::FnDef(FnDef { syntax }),
|
FN => Item::Fn(Fn { syntax }),
|
||||||
IMPL_DEF => Item::ImplDef(ImplDef { syntax }),
|
IMPL_DEF => Item::ImplDef(ImplDef { syntax }),
|
||||||
MACRO_CALL => Item::MacroCall(MacroCall { syntax }),
|
MACRO_CALL => Item::MacroCall(MacroCall { syntax }),
|
||||||
MODULE => Item::Module(Module { syntax }),
|
MODULE => Item::Module(Module { syntax }),
|
||||||
|
@ -2850,7 +2853,7 @@ impl AstNode for Item {
|
||||||
Item::EnumDef(it) => &it.syntax,
|
Item::EnumDef(it) => &it.syntax,
|
||||||
Item::ExternBlock(it) => &it.syntax,
|
Item::ExternBlock(it) => &it.syntax,
|
||||||
Item::ExternCrate(it) => &it.syntax,
|
Item::ExternCrate(it) => &it.syntax,
|
||||||
Item::FnDef(it) => &it.syntax,
|
Item::Fn(it) => &it.syntax,
|
||||||
Item::ImplDef(it) => &it.syntax,
|
Item::ImplDef(it) => &it.syntax,
|
||||||
Item::MacroCall(it) => &it.syntax,
|
Item::MacroCall(it) => &it.syntax,
|
||||||
Item::Module(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 {
|
impl From<RecordFieldDefList> for FieldDefList {
|
||||||
fn from(node: RecordFieldDefList) -> FieldDefList { FieldDefList::RecordFieldDefList(node) }
|
fn from(node: RecordFieldDefList) -> FieldDefList { FieldDefList::RecordFieldDefList(node) }
|
||||||
}
|
}
|
||||||
|
@ -3157,8 +3255,8 @@ impl AstNode for Expr {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl From<FnDef> for AssocItem {
|
impl From<Fn> for AssocItem {
|
||||||
fn from(node: FnDef) -> AssocItem { AssocItem::FnDef(node) }
|
fn from(node: Fn) -> AssocItem { AssocItem::Fn(node) }
|
||||||
}
|
}
|
||||||
impl From<TypeAliasDef> for AssocItem {
|
impl From<TypeAliasDef> for AssocItem {
|
||||||
fn from(node: TypeAliasDef) -> AssocItem { AssocItem::TypeAliasDef(node) }
|
fn from(node: TypeAliasDef) -> AssocItem { AssocItem::TypeAliasDef(node) }
|
||||||
|
@ -3172,13 +3270,13 @@ impl From<MacroCall> for AssocItem {
|
||||||
impl AstNode for AssocItem {
|
impl AstNode for AssocItem {
|
||||||
fn can_cast(kind: SyntaxKind) -> bool {
|
fn can_cast(kind: SyntaxKind) -> bool {
|
||||||
match kind {
|
match kind {
|
||||||
FN_DEF | TYPE_ALIAS_DEF | CONST_DEF | MACRO_CALL => true,
|
FN | TYPE_ALIAS_DEF | CONST_DEF | MACRO_CALL => true,
|
||||||
_ => false,
|
_ => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
||||||
let res = match syntax.kind() {
|
let res = match syntax.kind() {
|
||||||
FN_DEF => AssocItem::FnDef(FnDef { syntax }),
|
FN => AssocItem::Fn(Fn { syntax }),
|
||||||
TYPE_ALIAS_DEF => AssocItem::TypeAliasDef(TypeAliasDef { syntax }),
|
TYPE_ALIAS_DEF => AssocItem::TypeAliasDef(TypeAliasDef { syntax }),
|
||||||
CONST_DEF => AssocItem::ConstDef(ConstDef { syntax }),
|
CONST_DEF => AssocItem::ConstDef(ConstDef { syntax }),
|
||||||
MACRO_CALL => AssocItem::MacroCall(MacroCall { syntax }),
|
MACRO_CALL => AssocItem::MacroCall(MacroCall { syntax }),
|
||||||
|
@ -3188,108 +3286,13 @@ impl AstNode for AssocItem {
|
||||||
}
|
}
|
||||||
fn syntax(&self) -> &SyntaxNode {
|
fn syntax(&self) -> &SyntaxNode {
|
||||||
match self {
|
match self {
|
||||||
AssocItem::FnDef(it) => &it.syntax,
|
AssocItem::Fn(it) => &it.syntax,
|
||||||
AssocItem::TypeAliasDef(it) => &it.syntax,
|
AssocItem::TypeAliasDef(it) => &it.syntax,
|
||||||
AssocItem::ConstDef(it) => &it.syntax,
|
AssocItem::ConstDef(it) => &it.syntax,
|
||||||
AssocItem::MacroCall(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 {
|
impl From<LetStmt> for Stmt {
|
||||||
fn from(node: LetStmt) -> Stmt { Stmt::LetStmt(node) }
|
fn from(node: LetStmt) -> Stmt { Stmt::LetStmt(node) }
|
||||||
}
|
}
|
||||||
|
@ -3346,8 +3349,8 @@ impl AstNode for AttrInput {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl From<FnDef> for ExternItem {
|
impl From<Fn> for ExternItem {
|
||||||
fn from(node: FnDef) -> ExternItem { ExternItem::FnDef(node) }
|
fn from(node: Fn) -> ExternItem { ExternItem::Fn(node) }
|
||||||
}
|
}
|
||||||
impl From<StaticDef> for ExternItem {
|
impl From<StaticDef> for ExternItem {
|
||||||
fn from(node: StaticDef) -> ExternItem { ExternItem::StaticDef(node) }
|
fn from(node: StaticDef) -> ExternItem { ExternItem::StaticDef(node) }
|
||||||
|
@ -3355,13 +3358,13 @@ impl From<StaticDef> for ExternItem {
|
||||||
impl AstNode for ExternItem {
|
impl AstNode for ExternItem {
|
||||||
fn can_cast(kind: SyntaxKind) -> bool {
|
fn can_cast(kind: SyntaxKind) -> bool {
|
||||||
match kind {
|
match kind {
|
||||||
FN_DEF | STATIC_DEF => true,
|
FN | STATIC_DEF => true,
|
||||||
_ => false,
|
_ => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
||||||
let res = match syntax.kind() {
|
let res = match syntax.kind() {
|
||||||
FN_DEF => ExternItem::FnDef(FnDef { syntax }),
|
FN => ExternItem::Fn(Fn { syntax }),
|
||||||
STATIC_DEF => ExternItem::StaticDef(StaticDef { syntax }),
|
STATIC_DEF => ExternItem::StaticDef(StaticDef { syntax }),
|
||||||
_ => return None,
|
_ => return None,
|
||||||
};
|
};
|
||||||
|
@ -3369,7 +3372,7 @@ impl AstNode for ExternItem {
|
||||||
}
|
}
|
||||||
fn syntax(&self) -> &SyntaxNode {
|
fn syntax(&self) -> &SyntaxNode {
|
||||||
match self {
|
match self {
|
||||||
ExternItem::FnDef(it) => &it.syntax,
|
ExternItem::Fn(it) => &it.syntax,
|
||||||
ExternItem::StaticDef(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)
|
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 {
|
impl std::fmt::Display for FieldDefList {
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
std::fmt::Display::fmt(self.syntax(), f)
|
std::fmt::Display::fmt(self.syntax(), f)
|
||||||
|
@ -3432,11 +3440,6 @@ impl std::fmt::Display for AssocItem {
|
||||||
std::fmt::Display::fmt(self.syntax(), f)
|
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 {
|
impl std::fmt::Display for Stmt {
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
std::fmt::Display::fmt(self.syntax(), f)
|
std::fmt::Display::fmt(self.syntax(), f)
|
||||||
|
@ -3487,7 +3490,7 @@ impl std::fmt::Display for ExternCrate {
|
||||||
std::fmt::Display::fmt(self.syntax(), f)
|
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 {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
std::fmt::Display::fmt(self.syntax(), f)
|
std::fmt::Display::fmt(self.syntax(), f)
|
||||||
}
|
}
|
||||||
|
@ -3607,6 +3610,16 @@ impl std::fmt::Display for BlockExpr {
|
||||||
std::fmt::Display::fmt(self.syntax(), f)
|
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 {
|
impl std::fmt::Display for RecordFieldDefList {
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
std::fmt::Display::fmt(self.syntax(), f)
|
std::fmt::Display::fmt(self.syntax(), f)
|
||||||
|
@ -4037,16 +4050,6 @@ impl std::fmt::Display for LetStmt {
|
||||||
std::fmt::Display::fmt(self.syntax(), f)
|
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 {
|
impl std::fmt::Display for PathSegment {
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
std::fmt::Display::fmt(self.syntax(), f)
|
std::fmt::Display::fmt(self.syntax(), f)
|
||||||
|
|
|
@ -294,7 +294,7 @@ pub fn fn_def(
|
||||||
type_params: Option<ast::TypeParamList>,
|
type_params: Option<ast::TypeParamList>,
|
||||||
params: ast::ParamList,
|
params: ast::ParamList,
|
||||||
body: ast::BlockExpr,
|
body: ast::BlockExpr,
|
||||||
) -> ast::FnDef {
|
) -> ast::Fn {
|
||||||
let type_params =
|
let type_params =
|
||||||
if let Some(type_params) = type_params { format!("<{}>", type_params) } else { "".into() };
|
if let Some(type_params) = type_params { format!("<{}>", type_params) } else { "".into() };
|
||||||
let visibility = match visibility {
|
let visibility = match visibility {
|
||||||
|
|
|
@ -474,7 +474,7 @@ impl ast::TokenTree {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ast::DocCommentsOwner for ast::SourceFile {}
|
impl ast::DocCommentsOwner for ast::SourceFile {}
|
||||||
impl ast::DocCommentsOwner for ast::FnDef {}
|
impl ast::DocCommentsOwner for ast::Fn {}
|
||||||
impl ast::DocCommentsOwner for ast::StructDef {}
|
impl ast::DocCommentsOwner for ast::StructDef {}
|
||||||
impl ast::DocCommentsOwner for ast::UnionDef {}
|
impl ast::DocCommentsOwner for ast::UnionDef {}
|
||||||
impl ast::DocCommentsOwner for ast::RecordFieldDef {}
|
impl ast::DocCommentsOwner for ast::RecordFieldDef {}
|
||||||
|
|
|
@ -255,11 +255,11 @@ fn api_walkthrough() {
|
||||||
let mut func = None;
|
let mut func = None;
|
||||||
for item in file.items() {
|
for item in file.items() {
|
||||||
match item {
|
match item {
|
||||||
ast::Item::FnDef(f) => func = Some(f),
|
ast::Item::Fn(f) => func = Some(f),
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let func: ast::FnDef = func.unwrap();
|
let func: ast::Fn = func.unwrap();
|
||||||
|
|
||||||
// Each AST node has a bunch of getters for children. All getters return
|
// Each AST node has a bunch of getters for children. All getters return
|
||||||
// `Option`s though, to account for incomplete code. Some getters are common
|
// `Option`s though, to account for incomplete code. Some getters are common
|
||||||
|
@ -316,7 +316,7 @@ fn api_walkthrough() {
|
||||||
);
|
);
|
||||||
|
|
||||||
// As well as some iterator helpers:
|
// As well as some iterator helpers:
|
||||||
let f = expr_syntax.ancestors().find_map(ast::FnDef::cast);
|
let f = expr_syntax.ancestors().find_map(ast::Fn::cast);
|
||||||
assert_eq!(f, Some(func));
|
assert_eq!(f, Some(func));
|
||||||
assert!(expr_syntax.siblings_with_tokens(Direction::Next).any(|it| it.kind() == T!['}']));
|
assert!(expr_syntax.siblings_with_tokens(Direction::Next).any(|it| it.kind() == T!['}']));
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
|
|
|
@ -146,7 +146,7 @@ fn n_attached_trivias<'a>(
|
||||||
trivias: impl Iterator<Item = (SyntaxKind, &'a str)>,
|
trivias: impl Iterator<Item = (SyntaxKind, &'a str)>,
|
||||||
) -> usize {
|
) -> usize {
|
||||||
match kind {
|
match kind {
|
||||||
MACRO_CALL | CONST_DEF | TYPE_ALIAS_DEF | STRUCT_DEF | ENUM_DEF | ENUM_VARIANT | FN_DEF
|
MACRO_CALL | CONST_DEF | TYPE_ALIAS_DEF | STRUCT_DEF | ENUM_DEF | ENUM_VARIANT | FN
|
||||||
| TRAIT_DEF | MODULE | RECORD_FIELD_DEF | STATIC_DEF => {
|
| TRAIT_DEF | MODULE | RECORD_FIELD_DEF | STATIC_DEF => {
|
||||||
let mut res = 0;
|
let mut res = 0;
|
||||||
let mut trivias = trivias.enumerate().peekable();
|
let mut trivias = trivias.enumerate().peekable();
|
||||||
|
|
|
@ -4,7 +4,7 @@ mod block;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
ast, match_ast, AstNode, SyntaxError,
|
ast, match_ast, AstNode, SyntaxError,
|
||||||
SyntaxKind::{BYTE, BYTE_STRING, CHAR, CONST_DEF, FN_DEF, INT_NUMBER, STRING, TYPE_ALIAS_DEF},
|
SyntaxKind::{BYTE, BYTE_STRING, CHAR, CONST_DEF, FN, INT_NUMBER, STRING, TYPE_ALIAS_DEF},
|
||||||
SyntaxNode, SyntaxToken, TextSize, T,
|
SyntaxNode, SyntaxToken, TextSize, T,
|
||||||
};
|
};
|
||||||
use rustc_lexer::unescape::{
|
use rustc_lexer::unescape::{
|
||||||
|
@ -200,7 +200,7 @@ fn validate_visibility(vis: ast::Visibility, errors: &mut Vec<SyntaxError>) {
|
||||||
None => return,
|
None => return,
|
||||||
};
|
};
|
||||||
match parent.kind() {
|
match parent.kind() {
|
||||||
FN_DEF | CONST_DEF | TYPE_ALIAS_DEF => (),
|
FN | CONST_DEF | TYPE_ALIAS_DEF => (),
|
||||||
_ => return,
|
_ => return,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ use crate::{
|
||||||
pub(crate) fn validate_block_expr(block: ast::BlockExpr, errors: &mut Vec<SyntaxError>) {
|
pub(crate) fn validate_block_expr(block: ast::BlockExpr, errors: &mut Vec<SyntaxError>) {
|
||||||
if let Some(parent) = block.syntax().parent() {
|
if let Some(parent) = block.syntax().parent() {
|
||||||
match parent.kind() {
|
match parent.kind() {
|
||||||
FN_DEF | EXPR_STMT | BLOCK_EXPR => return,
|
FN | EXPR_STMT | BLOCK_EXPR => return,
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
SOURCE_FILE@0..54
|
SOURCE_FILE@0..54
|
||||||
FN_DEF@0..31
|
FN@0..31
|
||||||
ATTR@0..18
|
ATTR@0..18
|
||||||
POUND@0..1 "#"
|
POUND@0..1 "#"
|
||||||
L_BRACK@1..2 "["
|
L_BRACK@1..2 "["
|
||||||
|
|
|
@ -12,7 +12,7 @@ SOURCE_FILE@0..31
|
||||||
ERROR@14..15
|
ERROR@14..15
|
||||||
R_CURLY@14..15 "}"
|
R_CURLY@14..15 "}"
|
||||||
WHITESPACE@15..17 "\n\n"
|
WHITESPACE@15..17 "\n\n"
|
||||||
FN_DEF@17..27
|
FN@17..27
|
||||||
FN_KW@17..19 "fn"
|
FN_KW@17..19 "fn"
|
||||||
WHITESPACE@19..20 " "
|
WHITESPACE@19..20 " "
|
||||||
NAME@20..23
|
NAME@20..23
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
SOURCE_FILE@0..95
|
SOURCE_FILE@0..95
|
||||||
FN_DEF@0..12
|
FN@0..12
|
||||||
FN_KW@0..2 "fn"
|
FN_KW@0..2 "fn"
|
||||||
WHITESPACE@2..3 " "
|
WHITESPACE@2..3 " "
|
||||||
NAME@3..6
|
NAME@3..6
|
||||||
|
@ -58,7 +58,7 @@ SOURCE_FILE@0..95
|
||||||
WHITESPACE@78..79 "\n"
|
WHITESPACE@78..79 "\n"
|
||||||
R_CURLY@79..80 "}"
|
R_CURLY@79..80 "}"
|
||||||
WHITESPACE@80..82 "\n\n"
|
WHITESPACE@80..82 "\n\n"
|
||||||
FN_DEF@82..94
|
FN@82..94
|
||||||
FN_KW@82..84 "fn"
|
FN_KW@82..84 "fn"
|
||||||
WHITESPACE@84..85 " "
|
WHITESPACE@84..85 " "
|
||||||
NAME@85..88
|
NAME@85..88
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
SOURCE_FILE@0..42
|
SOURCE_FILE@0..42
|
||||||
FN_DEF@0..41
|
FN@0..41
|
||||||
FN_KW@0..2 "fn"
|
FN_KW@0..2 "fn"
|
||||||
WHITESPACE@2..3 " "
|
WHITESPACE@2..3 " "
|
||||||
NAME@3..7
|
NAME@3..7
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
SOURCE_FILE@0..389
|
SOURCE_FILE@0..389
|
||||||
FN_DEF@0..389
|
FN@0..389
|
||||||
VISIBILITY@0..10
|
VISIBILITY@0..10
|
||||||
PUB_KW@0..3
|
PUB_KW@0..3
|
||||||
L_PAREN@3..4
|
L_PAREN@3..4
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
SOURCE_FILE@0..23
|
SOURCE_FILE@0..23
|
||||||
FN_DEF@0..22
|
FN@0..22
|
||||||
FN_KW@0..2 "fn"
|
FN_KW@0..2 "fn"
|
||||||
WHITESPACE@2..3 " "
|
WHITESPACE@2..3 " "
|
||||||
NAME@3..6
|
NAME@3..6
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
SOURCE_FILE@0..14
|
SOURCE_FILE@0..14
|
||||||
FN_DEF@0..7
|
FN@0..7
|
||||||
FN_KW@0..2 "fn"
|
FN_KW@0..2 "fn"
|
||||||
WHITESPACE@2..3 " "
|
WHITESPACE@2..3 " "
|
||||||
NAME@3..6
|
NAME@3..6
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
SOURCE_FILE@0..56
|
SOURCE_FILE@0..56
|
||||||
FN_DEF@0..55
|
FN@0..55
|
||||||
FN_KW@0..2 "fn"
|
FN_KW@0..2 "fn"
|
||||||
WHITESPACE@2..3 " "
|
WHITESPACE@2..3 " "
|
||||||
NAME@3..6
|
NAME@3..6
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
SOURCE_FILE@0..47
|
SOURCE_FILE@0..47
|
||||||
FN_DEF@0..46
|
FN@0..46
|
||||||
FN_KW@0..2 "fn"
|
FN_KW@0..2 "fn"
|
||||||
WHITESPACE@2..3 " "
|
WHITESPACE@2..3 " "
|
||||||
NAME@3..6
|
NAME@3..6
|
||||||
|
|
|
@ -11,7 +11,7 @@ SOURCE_FILE@0..183
|
||||||
ASSOC_ITEM_LIST@14..182
|
ASSOC_ITEM_LIST@14..182
|
||||||
L_CURLY@14..15 "{"
|
L_CURLY@14..15 "{"
|
||||||
WHITESPACE@15..20 "\n "
|
WHITESPACE@15..20 "\n "
|
||||||
FN_DEF@20..161
|
FN@20..161
|
||||||
FN_KW@20..22 "fn"
|
FN_KW@20..22 "fn"
|
||||||
WHITESPACE@22..23 " "
|
WHITESPACE@22..23 " "
|
||||||
NAME@23..32
|
NAME@23..32
|
||||||
|
@ -116,7 +116,7 @@ SOURCE_FILE@0..183
|
||||||
WHITESPACE@155..160 "\n "
|
WHITESPACE@155..160 "\n "
|
||||||
R_CURLY@160..161 "}"
|
R_CURLY@160..161 "}"
|
||||||
WHITESPACE@161..167 "\n\n "
|
WHITESPACE@161..167 "\n\n "
|
||||||
FN_DEF@167..180
|
FN@167..180
|
||||||
FN_KW@167..169 "fn"
|
FN_KW@167..169 "fn"
|
||||||
WHITESPACE@169..170 " "
|
WHITESPACE@169..170 " "
|
||||||
NAME@170..180
|
NAME@170..180
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
SOURCE_FILE@0..139
|
SOURCE_FILE@0..139
|
||||||
FN_DEF@0..138
|
FN@0..138
|
||||||
FN_KW@0..2 "fn"
|
FN_KW@0..2 "fn"
|
||||||
WHITESPACE@2..3 " "
|
WHITESPACE@2..3 " "
|
||||||
NAME@3..6
|
NAME@3..6
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
SOURCE_FILE@0..16
|
SOURCE_FILE@0..16
|
||||||
FN_DEF@0..2
|
FN@0..2
|
||||||
FN_KW@0..2 "fn"
|
FN_KW@0..2 "fn"
|
||||||
WHITESPACE@2..4 "\n\n"
|
WHITESPACE@2..4 "\n\n"
|
||||||
FN_DEF@4..15
|
FN@4..15
|
||||||
FN_KW@4..6 "fn"
|
FN_KW@4..6 "fn"
|
||||||
WHITESPACE@6..7 " "
|
WHITESPACE@6..7 " "
|
||||||
NAME@7..10
|
NAME@7..10
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
SOURCE_FILE@0..22
|
SOURCE_FILE@0..22
|
||||||
FN_DEF@0..21
|
FN@0..21
|
||||||
FN_KW@0..2 "fn"
|
FN_KW@0..2 "fn"
|
||||||
WHITESPACE@2..3 " "
|
WHITESPACE@2..3 " "
|
||||||
NAME@3..6
|
NAME@3..6
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
SOURCE_FILE@0..112
|
SOURCE_FILE@0..112
|
||||||
FN_DEF@0..33
|
FN@0..33
|
||||||
FN_KW@0..2 "fn"
|
FN_KW@0..2 "fn"
|
||||||
WHITESPACE@2..3 " "
|
WHITESPACE@2..3 " "
|
||||||
NAME@3..4
|
NAME@3..4
|
||||||
|
@ -40,7 +40,7 @@ SOURCE_FILE@0..112
|
||||||
WHITESPACE@31..32 " "
|
WHITESPACE@31..32 " "
|
||||||
R_CURLY@32..33 "}"
|
R_CURLY@32..33 "}"
|
||||||
WHITESPACE@33..34 "\n"
|
WHITESPACE@33..34 "\n"
|
||||||
FN_DEF@34..68
|
FN@34..68
|
||||||
FN_KW@34..36 "fn"
|
FN_KW@34..36 "fn"
|
||||||
WHITESPACE@36..37 " "
|
WHITESPACE@36..37 " "
|
||||||
NAME@37..38
|
NAME@37..38
|
||||||
|
@ -88,7 +88,7 @@ SOURCE_FILE@0..112
|
||||||
WHITESPACE@66..67 " "
|
WHITESPACE@66..67 " "
|
||||||
R_CURLY@67..68 "}"
|
R_CURLY@67..68 "}"
|
||||||
WHITESPACE@68..69 "\n"
|
WHITESPACE@68..69 "\n"
|
||||||
FN_DEF@69..111
|
FN@69..111
|
||||||
FN_KW@69..71 "fn"
|
FN_KW@69..71 "fn"
|
||||||
WHITESPACE@71..72 " "
|
WHITESPACE@71..72 " "
|
||||||
NAME@72..73
|
NAME@72..73
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
SOURCE_FILE@0..94
|
SOURCE_FILE@0..94
|
||||||
FN_DEF@0..55
|
FN@0..55
|
||||||
FN_KW@0..2 "fn"
|
FN_KW@0..2 "fn"
|
||||||
WHITESPACE@2..3 " "
|
WHITESPACE@2..3 " "
|
||||||
NAME@3..7
|
NAME@3..7
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
SOURCE_FILE@0..240
|
SOURCE_FILE@0..240
|
||||||
FN_DEF@0..53
|
FN@0..53
|
||||||
FN_KW@0..2 "fn"
|
FN_KW@0..2 "fn"
|
||||||
WHITESPACE@2..3 " "
|
WHITESPACE@2..3 " "
|
||||||
NAME@3..4
|
NAME@3..4
|
||||||
|
@ -65,7 +65,7 @@ SOURCE_FILE@0..240
|
||||||
L_CURLY@51..52 "{"
|
L_CURLY@51..52 "{"
|
||||||
R_CURLY@52..53 "}"
|
R_CURLY@52..53 "}"
|
||||||
WHITESPACE@53..55 "\n\n"
|
WHITESPACE@53..55 "\n\n"
|
||||||
FN_DEF@55..239
|
FN@55..239
|
||||||
FN_KW@55..57 "fn"
|
FN_KW@55..57 "fn"
|
||||||
WHITESPACE@57..58 " "
|
WHITESPACE@57..58 " "
|
||||||
NAME@58..62
|
NAME@58..62
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
SOURCE_FILE@0..575
|
SOURCE_FILE@0..575
|
||||||
FN_DEF@0..574
|
FN@0..574
|
||||||
FN_KW@0..2 "fn"
|
FN_KW@0..2 "fn"
|
||||||
WHITESPACE@2..3 " "
|
WHITESPACE@2..3 " "
|
||||||
NAME@3..7
|
NAME@3..7
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
SOURCE_FILE@0..30
|
SOURCE_FILE@0..30
|
||||||
FN_DEF@0..29
|
FN@0..29
|
||||||
FN_KW@0..2 "fn"
|
FN_KW@0..2 "fn"
|
||||||
WHITESPACE@2..3 " "
|
WHITESPACE@2..3 " "
|
||||||
NAME@3..6
|
NAME@3..6
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
SOURCE_FILE@0..24
|
SOURCE_FILE@0..24
|
||||||
FN_DEF@0..23
|
FN@0..23
|
||||||
FN_KW@0..2 "fn"
|
FN_KW@0..2 "fn"
|
||||||
WHITESPACE@2..3 " "
|
WHITESPACE@2..3 " "
|
||||||
NAME@3..6
|
NAME@3..6
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
SOURCE_FILE@0..350
|
SOURCE_FILE@0..350
|
||||||
FN_DEF@0..349
|
FN@0..349
|
||||||
FN_KW@0..2 "fn"
|
FN_KW@0..2 "fn"
|
||||||
WHITESPACE@2..3 " "
|
WHITESPACE@2..3 " "
|
||||||
NAME@3..8
|
NAME@3..8
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
SOURCE_FILE@0..293
|
SOURCE_FILE@0..293
|
||||||
FN_DEF@0..292
|
FN@0..292
|
||||||
FN_KW@0..2 "fn"
|
FN_KW@0..2 "fn"
|
||||||
WHITESPACE@2..3 " "
|
WHITESPACE@2..3 " "
|
||||||
NAME@3..6
|
NAME@3..6
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
SOURCE_FILE@0..89
|
SOURCE_FILE@0..89
|
||||||
FN_DEF@0..88
|
FN@0..88
|
||||||
FN_KW@0..2 "fn"
|
FN_KW@0..2 "fn"
|
||||||
WHITESPACE@2..3 " "
|
WHITESPACE@2..3 " "
|
||||||
NAME@3..6
|
NAME@3..6
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
SOURCE_FILE@0..91
|
SOURCE_FILE@0..91
|
||||||
FN_DEF@0..89
|
FN@0..89
|
||||||
FN_KW@0..2 "fn"
|
FN_KW@0..2 "fn"
|
||||||
WHITESPACE@2..3 " "
|
WHITESPACE@2..3 " "
|
||||||
NAME@3..7
|
NAME@3..7
|
||||||
|
|
|
@ -34,7 +34,7 @@ SOURCE_FILE@0..48
|
||||||
USE@34..37
|
USE@34..37
|
||||||
USE_KW@34..37 "use"
|
USE_KW@34..37 "use"
|
||||||
WHITESPACE@37..38 "\n"
|
WHITESPACE@37..38 "\n"
|
||||||
FN_DEF@38..47
|
FN@38..47
|
||||||
FN_KW@38..40 "fn"
|
FN_KW@38..40 "fn"
|
||||||
WHITESPACE@40..41 " "
|
WHITESPACE@40..41 " "
|
||||||
NAME@41..42
|
NAME@41..42
|
||||||
|
|
|
@ -17,7 +17,7 @@ SOURCE_FILE@0..118
|
||||||
ASSOC_ITEM_LIST@14..117
|
ASSOC_ITEM_LIST@14..117
|
||||||
L_CURLY@14..15 "{"
|
L_CURLY@14..15 "{"
|
||||||
WHITESPACE@15..20 "\n "
|
WHITESPACE@15..20 "\n "
|
||||||
FN_DEF@20..31
|
FN@20..31
|
||||||
FN_KW@20..22 "fn"
|
FN_KW@20..22 "fn"
|
||||||
WHITESPACE@22..23 " "
|
WHITESPACE@22..23 " "
|
||||||
NAME@23..26
|
NAME@23..26
|
||||||
|
@ -30,7 +30,7 @@ SOURCE_FILE@0..118
|
||||||
L_CURLY@29..30 "{"
|
L_CURLY@29..30 "{"
|
||||||
R_CURLY@30..31 "}"
|
R_CURLY@30..31 "}"
|
||||||
WHITESPACE@31..36 "\n "
|
WHITESPACE@31..36 "\n "
|
||||||
FN_DEF@36..51
|
FN@36..51
|
||||||
VISIBILITY@36..39
|
VISIBILITY@36..39
|
||||||
PUB_KW@36..39 "pub"
|
PUB_KW@36..39 "pub"
|
||||||
WHITESPACE@39..40 " "
|
WHITESPACE@39..40 " "
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
SOURCE_FILE@0..33
|
SOURCE_FILE@0..33
|
||||||
FN_DEF@0..32
|
FN@0..32
|
||||||
FN_KW@0..2 "fn"
|
FN_KW@0..2 "fn"
|
||||||
WHITESPACE@2..3 " "
|
WHITESPACE@2..3 " "
|
||||||
NAME@3..7
|
NAME@3..7
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
SOURCE_FILE@0..83
|
SOURCE_FILE@0..83
|
||||||
FN_DEF@0..82
|
FN@0..82
|
||||||
FN_KW@0..2 "fn"
|
FN_KW@0..2 "fn"
|
||||||
WHITESPACE@2..3 " "
|
WHITESPACE@2..3 " "
|
||||||
NAME@3..6
|
NAME@3..6
|
||||||
|
|
|
@ -136,7 +136,7 @@ SOURCE_FILE@0..239
|
||||||
R_PAREN@147..148 ")"
|
R_PAREN@147..148 ")"
|
||||||
SEMICOLON@148..149 ";"
|
SEMICOLON@148..149 ";"
|
||||||
WHITESPACE@149..150 "\n"
|
WHITESPACE@149..150 "\n"
|
||||||
FN_DEF@150..238
|
FN@150..238
|
||||||
FN_KW@150..152 "fn"
|
FN_KW@150..152 "fn"
|
||||||
WHITESPACE@152..153 " "
|
WHITESPACE@152..153 " "
|
||||||
NAME@153..164
|
NAME@153..164
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
SOURCE_FILE@0..83
|
SOURCE_FILE@0..83
|
||||||
FN_DEF@0..82
|
FN@0..82
|
||||||
FN_KW@0..2 "fn"
|
FN_KW@0..2 "fn"
|
||||||
WHITESPACE@2..3 " "
|
WHITESPACE@2..3 " "
|
||||||
NAME@3..7
|
NAME@3..7
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
FN_DEF@0..11
|
FN@0..11
|
||||||
FN_KW@0..2 "fn"
|
FN_KW@0..2 "fn"
|
||||||
WHITESPACE@2..3 " "
|
WHITESPACE@2..3 " "
|
||||||
NAME@3..6
|
NAME@3..6
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
SOURCE_FILE@0..30
|
SOURCE_FILE@0..30
|
||||||
FN_DEF@0..29
|
FN@0..29
|
||||||
FN_KW@0..2 "fn"
|
FN_KW@0..2 "fn"
|
||||||
WHITESPACE@2..3 " "
|
WHITESPACE@2..3 " "
|
||||||
NAME@3..7
|
NAME@3..7
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
SOURCE_FILE@0..33
|
SOURCE_FILE@0..33
|
||||||
FN_DEF@0..10
|
FN@0..10
|
||||||
FN_KW@0..2 "fn"
|
FN_KW@0..2 "fn"
|
||||||
WHITESPACE@2..3 " "
|
WHITESPACE@2..3 " "
|
||||||
NAME@3..6
|
NAME@3..6
|
||||||
|
@ -19,7 +19,7 @@ SOURCE_FILE@0..33
|
||||||
WHITESPACE@19..20 " "
|
WHITESPACE@19..20 " "
|
||||||
R_CURLY@20..21 "}"
|
R_CURLY@20..21 "}"
|
||||||
WHITESPACE@21..22 " "
|
WHITESPACE@21..22 " "
|
||||||
FN_DEF@22..32
|
FN@22..32
|
||||||
FN_KW@22..24 "fn"
|
FN_KW@22..24 "fn"
|
||||||
WHITESPACE@24..25 " "
|
WHITESPACE@24..25 " "
|
||||||
NAME@25..28
|
NAME@25..28
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
SOURCE_FILE@0..30
|
SOURCE_FILE@0..30
|
||||||
FN_DEF@0..29
|
FN@0..29
|
||||||
FN_KW@0..2 "fn"
|
FN_KW@0..2 "fn"
|
||||||
WHITESPACE@2..3 " "
|
WHITESPACE@2..3 " "
|
||||||
NAME@3..6
|
NAME@3..6
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
SOURCE_FILE@0..21
|
SOURCE_FILE@0..21
|
||||||
FN_DEF@0..20
|
FN@0..20
|
||||||
FN_KW@0..2 "fn"
|
FN_KW@0..2 "fn"
|
||||||
WHITESPACE@2..3 " "
|
WHITESPACE@2..3 " "
|
||||||
NAME@3..6
|
NAME@3..6
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
SOURCE_FILE@0..48
|
SOURCE_FILE@0..48
|
||||||
FN_DEF@0..47
|
FN@0..47
|
||||||
FN_KW@0..2 "fn"
|
FN_KW@0..2 "fn"
|
||||||
WHITESPACE@2..3 " "
|
WHITESPACE@2..3 " "
|
||||||
NAME@3..6
|
NAME@3..6
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
SOURCE_FILE@0..47
|
SOURCE_FILE@0..47
|
||||||
FN_DEF@0..46
|
FN@0..46
|
||||||
FN_KW@0..2 "fn"
|
FN_KW@0..2 "fn"
|
||||||
WHITESPACE@2..3 " "
|
WHITESPACE@2..3 " "
|
||||||
NAME@3..6
|
NAME@3..6
|
||||||
|
|
|
@ -2,7 +2,7 @@ SOURCE_FILE@0..50
|
||||||
ERROR@0..6
|
ERROR@0..6
|
||||||
UNSAFE_KW@0..6 "unsafe"
|
UNSAFE_KW@0..6 "unsafe"
|
||||||
WHITESPACE@6..7 " "
|
WHITESPACE@6..7 " "
|
||||||
FN_DEF@7..24
|
FN@7..24
|
||||||
ASYNC_KW@7..12 "async"
|
ASYNC_KW@7..12 "async"
|
||||||
WHITESPACE@12..13 " "
|
WHITESPACE@12..13 " "
|
||||||
FN_KW@13..15 "fn"
|
FN_KW@13..15 "fn"
|
||||||
|
|
|
@ -35,7 +35,7 @@ SOURCE_FILE@0..62
|
||||||
NAME_REF@40..47
|
NAME_REF@40..47
|
||||||
IDENT@40..47 "default"
|
IDENT@40..47 "default"
|
||||||
WHITESPACE@47..48 " "
|
WHITESPACE@47..48 " "
|
||||||
FN_DEF@48..59
|
FN@48..59
|
||||||
FN_KW@48..50 "fn"
|
FN_KW@48..50 "fn"
|
||||||
WHITESPACE@50..51 " "
|
WHITESPACE@50..51 " "
|
||||||
NAME@51..54
|
NAME@51..54
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
SOURCE_FILE@0..45
|
SOURCE_FILE@0..45
|
||||||
FN_DEF@0..44
|
FN@0..44
|
||||||
FN_KW@0..2 "fn"
|
FN_KW@0..2 "fn"
|
||||||
WHITESPACE@2..3 " "
|
WHITESPACE@2..3 " "
|
||||||
NAME@3..7
|
NAME@3..7
|
||||||
|
|
|
@ -41,7 +41,7 @@ SOURCE_FILE@0..83
|
||||||
IDENT@41..44 "i32"
|
IDENT@41..44 "i32"
|
||||||
SEMICOLON@44..45 ";"
|
SEMICOLON@44..45 ";"
|
||||||
WHITESPACE@45..50 "\n "
|
WHITESPACE@45..50 "\n "
|
||||||
FN_DEF@50..61
|
FN@50..61
|
||||||
FN_KW@50..52 "fn"
|
FN_KW@50..52 "fn"
|
||||||
WHITESPACE@52..53 " "
|
WHITESPACE@52..53 " "
|
||||||
NAME@53..56
|
NAME@53..56
|
||||||
|
@ -54,7 +54,7 @@ SOURCE_FILE@0..83
|
||||||
L_CURLY@59..60 "{"
|
L_CURLY@59..60 "{"
|
||||||
R_CURLY@60..61 "}"
|
R_CURLY@60..61 "}"
|
||||||
WHITESPACE@61..66 "\n "
|
WHITESPACE@61..66 "\n "
|
||||||
FN_DEF@66..80
|
FN@66..80
|
||||||
FN_KW@66..68 "fn"
|
FN_KW@66..68 "fn"
|
||||||
WHITESPACE@68..69 " "
|
WHITESPACE@68..69 " "
|
||||||
NAME@69..72
|
NAME@69..72
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
SOURCE_FILE@0..54
|
SOURCE_FILE@0..54
|
||||||
FN_DEF@0..53
|
FN@0..53
|
||||||
FN_KW@0..2 "fn"
|
FN_KW@0..2 "fn"
|
||||||
WHITESPACE@2..3 " "
|
WHITESPACE@2..3 " "
|
||||||
NAME@3..12
|
NAME@3..12
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
SOURCE_FILE@0..28
|
SOURCE_FILE@0..28
|
||||||
FN_DEF@0..27
|
FN@0..27
|
||||||
FN_KW@0..2 "fn"
|
FN_KW@0..2 "fn"
|
||||||
WHITESPACE@2..3 " "
|
WHITESPACE@2..3 " "
|
||||||
NAME@3..6
|
NAME@3..6
|
||||||
|
|
|
@ -11,7 +11,7 @@ SOURCE_FILE@0..128
|
||||||
ASSOC_ITEM_LIST@7..127
|
ASSOC_ITEM_LIST@7..127
|
||||||
L_CURLY@7..8 "{"
|
L_CURLY@7..8 "{"
|
||||||
WHITESPACE@8..13 "\n "
|
WHITESPACE@8..13 "\n "
|
||||||
FN_DEF@13..26
|
FN@13..26
|
||||||
FN_KW@13..15 "fn"
|
FN_KW@13..15 "fn"
|
||||||
WHITESPACE@15..16 " "
|
WHITESPACE@15..16 " "
|
||||||
NAME@16..17
|
NAME@16..17
|
||||||
|
@ -26,7 +26,7 @@ SOURCE_FILE@0..128
|
||||||
L_CURLY@24..25 "{"
|
L_CURLY@24..25 "{"
|
||||||
R_CURLY@25..26 "}"
|
R_CURLY@25..26 "}"
|
||||||
WHITESPACE@26..31 "\n "
|
WHITESPACE@26..31 "\n "
|
||||||
FN_DEF@31..46
|
FN@31..46
|
||||||
FN_KW@31..33 "fn"
|
FN_KW@31..33 "fn"
|
||||||
WHITESPACE@33..34 " "
|
WHITESPACE@33..34 " "
|
||||||
NAME@34..35
|
NAME@34..35
|
||||||
|
@ -43,7 +43,7 @@ SOURCE_FILE@0..128
|
||||||
L_CURLY@44..45 "{"
|
L_CURLY@44..45 "{"
|
||||||
R_CURLY@45..46 "}"
|
R_CURLY@45..46 "}"
|
||||||
WHITESPACE@46..51 "\n "
|
WHITESPACE@46..51 "\n "
|
||||||
FN_DEF@51..69
|
FN@51..69
|
||||||
FN_KW@51..53 "fn"
|
FN_KW@51..53 "fn"
|
||||||
WHITESPACE@53..54 " "
|
WHITESPACE@53..54 " "
|
||||||
NAME@54..55
|
NAME@54..55
|
||||||
|
@ -62,7 +62,7 @@ SOURCE_FILE@0..128
|
||||||
L_CURLY@67..68 "{"
|
L_CURLY@67..68 "{"
|
||||||
R_CURLY@68..69 "}"
|
R_CURLY@68..69 "}"
|
||||||
WHITESPACE@69..74 "\n "
|
WHITESPACE@69..74 "\n "
|
||||||
FN_DEF@74..103
|
FN@74..103
|
||||||
FN_KW@74..76 "fn"
|
FN_KW@74..76 "fn"
|
||||||
WHITESPACE@76..77 " "
|
WHITESPACE@76..77 " "
|
||||||
NAME@77..78
|
NAME@77..78
|
||||||
|
@ -95,7 +95,7 @@ SOURCE_FILE@0..128
|
||||||
L_CURLY@101..102 "{"
|
L_CURLY@101..102 "{"
|
||||||
R_CURLY@102..103 "}"
|
R_CURLY@102..103 "}"
|
||||||
WHITESPACE@103..108 "\n "
|
WHITESPACE@103..108 "\n "
|
||||||
FN_DEF@108..125
|
FN@108..125
|
||||||
FN_KW@108..110 "fn"
|
FN_KW@108..110 "fn"
|
||||||
WHITESPACE@110..111 " "
|
WHITESPACE@110..111 " "
|
||||||
NAME@111..112
|
NAME@111..112
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
SOURCE_FILE@0..103
|
SOURCE_FILE@0..103
|
||||||
FN_DEF@0..102
|
FN@0..102
|
||||||
FN_KW@0..2 "fn"
|
FN_KW@0..2 "fn"
|
||||||
WHITESPACE@2..3 " "
|
WHITESPACE@2..3 " "
|
||||||
NAME@3..6
|
NAME@3..6
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
SOURCE_FILE@0..26
|
SOURCE_FILE@0..26
|
||||||
FN_DEF@0..25
|
FN@0..25
|
||||||
FN_KW@0..2 "fn"
|
FN_KW@0..2 "fn"
|
||||||
WHITESPACE@2..3 " "
|
WHITESPACE@2..3 " "
|
||||||
NAME@3..6
|
NAME@3..6
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
SOURCE_FILE@0..48
|
SOURCE_FILE@0..48
|
||||||
FN_DEF@0..47
|
FN@0..47
|
||||||
FN_KW@0..2 "fn"
|
FN_KW@0..2 "fn"
|
||||||
WHITESPACE@2..3 " "
|
WHITESPACE@2..3 " "
|
||||||
NAME@3..6
|
NAME@3..6
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
SOURCE_FILE@0..69
|
SOURCE_FILE@0..69
|
||||||
FN_DEF@0..68
|
FN@0..68
|
||||||
FN_KW@0..2 "fn"
|
FN_KW@0..2 "fn"
|
||||||
WHITESPACE@2..3 " "
|
WHITESPACE@2..3 " "
|
||||||
NAME@3..6
|
NAME@3..6
|
||||||
|
|
|
@ -11,7 +11,7 @@ SOURCE_FILE@0..69
|
||||||
ASSOC_ITEM_LIST@7..68
|
ASSOC_ITEM_LIST@7..68
|
||||||
L_CURLY@7..8 "{"
|
L_CURLY@7..8 "{"
|
||||||
WHITESPACE@8..13 "\n "
|
WHITESPACE@8..13 "\n "
|
||||||
FN_DEF@13..33
|
FN@13..33
|
||||||
FN_KW@13..15 "fn"
|
FN_KW@13..15 "fn"
|
||||||
WHITESPACE@15..16 " "
|
WHITESPACE@15..16 " "
|
||||||
NAME@16..17
|
NAME@16..17
|
||||||
|
@ -35,7 +35,7 @@ SOURCE_FILE@0..69
|
||||||
L_CURLY@31..32 "{"
|
L_CURLY@31..32 "{"
|
||||||
R_CURLY@32..33 "}"
|
R_CURLY@32..33 "}"
|
||||||
WHITESPACE@33..38 "\n "
|
WHITESPACE@33..38 "\n "
|
||||||
FN_DEF@38..66
|
FN@38..66
|
||||||
FN_KW@38..40 "fn"
|
FN_KW@38..40 "fn"
|
||||||
WHITESPACE@40..41 " "
|
WHITESPACE@40..41 " "
|
||||||
NAME@41..42
|
NAME@41..42
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
SOURCE_FILE@0..44
|
SOURCE_FILE@0..44
|
||||||
FN_DEF@0..43
|
FN@0..43
|
||||||
FN_KW@0..2 "fn"
|
FN_KW@0..2 "fn"
|
||||||
WHITESPACE@2..3 " "
|
WHITESPACE@2..3 " "
|
||||||
NAME@3..6
|
NAME@3..6
|
||||||
|
|
|
@ -45,7 +45,7 @@ SOURCE_FILE@0..89
|
||||||
INT_NUMBER@46..48 "92"
|
INT_NUMBER@46..48 "92"
|
||||||
SEMICOLON@48..49 ";"
|
SEMICOLON@48..49 ";"
|
||||||
WHITESPACE@49..54 "\n "
|
WHITESPACE@49..54 "\n "
|
||||||
FN_DEF@54..65
|
FN@54..65
|
||||||
FN_KW@54..56 "fn"
|
FN_KW@54..56 "fn"
|
||||||
WHITESPACE@56..57 " "
|
WHITESPACE@56..57 " "
|
||||||
NAME@57..60
|
NAME@57..60
|
||||||
|
@ -58,7 +58,7 @@ SOURCE_FILE@0..89
|
||||||
L_CURLY@63..64 "{"
|
L_CURLY@63..64 "{"
|
||||||
R_CURLY@64..65 "}"
|
R_CURLY@64..65 "}"
|
||||||
WHITESPACE@65..70 "\n "
|
WHITESPACE@65..70 "\n "
|
||||||
FN_DEF@70..86
|
FN@70..86
|
||||||
FN_KW@70..72 "fn"
|
FN_KW@70..72 "fn"
|
||||||
WHITESPACE@72..73 " "
|
WHITESPACE@72..73 " "
|
||||||
NAME@73..76
|
NAME@73..76
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
SOURCE_FILE@0..39
|
SOURCE_FILE@0..39
|
||||||
FN_DEF@0..38
|
FN@0..38
|
||||||
FN_KW@0..2 "fn"
|
FN_KW@0..2 "fn"
|
||||||
WHITESPACE@2..3 " "
|
WHITESPACE@2..3 " "
|
||||||
NAME@3..7
|
NAME@3..7
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
SOURCE_FILE@0..97
|
SOURCE_FILE@0..97
|
||||||
FN_DEF@0..96
|
FN@0..96
|
||||||
FN_KW@0..2 "fn"
|
FN_KW@0..2 "fn"
|
||||||
WHITESPACE@2..3 " "
|
WHITESPACE@2..3 " "
|
||||||
NAME@3..6
|
NAME@3..6
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue