Skip to content

Commit 1142112

Browse files
committed
Rename FnDef -> Fn
1 parent 3e1e622 commit 1142112

File tree

244 files changed

+682
-674
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

244 files changed

+682
-674
lines changed

crates/ra_assists/src/handlers/add_missing_impl_members.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ fn add_missing_impl_members_inner(
118118

119119
let def_name = |item: &ast::AssocItem| -> Option<SmolStr> {
120120
match item {
121-
ast::AssocItem::FnDef(def) => def.name(),
121+
ast::AssocItem::Fn(def) => def.name(),
122122
ast::AssocItem::TypeAliasDef(def) => def.name(),
123123
ast::AssocItem::ConstDef(def) => def.name(),
124124
ast::AssocItem::MacroCall(_) => None,
@@ -129,13 +129,13 @@ fn add_missing_impl_members_inner(
129129
let missing_items = get_missing_assoc_items(&ctx.sema, &impl_def)
130130
.iter()
131131
.map(|i| match i {
132-
hir::AssocItem::Function(i) => ast::AssocItem::FnDef(i.source(ctx.db()).value),
132+
hir::AssocItem::Function(i) => ast::AssocItem::Fn(i.source(ctx.db()).value),
133133
hir::AssocItem::TypeAlias(i) => ast::AssocItem::TypeAliasDef(i.source(ctx.db()).value),
134134
hir::AssocItem::Const(i) => ast::AssocItem::ConstDef(i.source(ctx.db()).value),
135135
})
136136
.filter(|t| def_name(&t).is_some())
137137
.filter(|t| match t {
138-
ast::AssocItem::FnDef(def) => match mode {
138+
ast::AssocItem::Fn(def) => match mode {
139139
AddMissingImplMembersMode::DefaultMethodsOnly => def.body().is_some(),
140140
AddMissingImplMembersMode::NoDefaultMethods => def.body().is_none(),
141141
},
@@ -158,7 +158,7 @@ fn add_missing_impl_members_inner(
158158
.into_iter()
159159
.map(|it| ast_transform::apply(&*ast_transform, it))
160160
.map(|it| match it {
161-
ast::AssocItem::FnDef(def) => ast::AssocItem::FnDef(add_body(def)),
161+
ast::AssocItem::Fn(def) => ast::AssocItem::Fn(add_body(def)),
162162
ast::AssocItem::TypeAliasDef(def) => {
163163
ast::AssocItem::TypeAliasDef(def.remove_bounds())
164164
}
@@ -174,7 +174,7 @@ fn add_missing_impl_members_inner(
174174
Some(cap) => {
175175
let mut cursor = Cursor::Before(first_new_item.syntax());
176176
let placeholder;
177-
if let ast::AssocItem::FnDef(func) = &first_new_item {
177+
if let ast::AssocItem::Fn(func) = &first_new_item {
178178
if let Some(m) = func.syntax().descendants().find_map(ast::MacroCall::cast) {
179179
if m.syntax().text() == "todo!()" {
180180
placeholder = m;
@@ -192,7 +192,7 @@ fn add_missing_impl_members_inner(
192192
})
193193
}
194194

195-
fn add_body(fn_def: ast::FnDef) -> ast::FnDef {
195+
fn add_body(fn_def: ast::Fn) -> ast::Fn {
196196
if fn_def.body().is_some() {
197197
return fn_def;
198198
}

crates/ra_assists/src/handlers/change_return_type_to_result.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use test_utils::mark;
2020
pub(crate) fn change_return_type_to_result(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
2121
let ret_type = ctx.find_node_at_offset::<ast::RetType>()?;
2222
// FIXME: extend to lambdas as well
23-
let fn_def = ret_type.syntax().parent().and_then(ast::FnDef::cast)?;
23+
let fn_def = ret_type.syntax().parent().and_then(ast::Fn::cast)?;
2424

2525
let type_ref = &ret_type.type_ref()?;
2626
let ret_type_str = type_ref.syntax().text().to_string();

crates/ra_assists/src/handlers/change_visibility.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use ra_syntax::{
22
ast::{self, NameOwner, VisibilityOwner},
33
AstNode,
44
SyntaxKind::{
5-
CONST_DEF, ENUM_DEF, FN_DEF, MODULE, STATIC_DEF, STRUCT_DEF, TRAIT_DEF, VISIBILITY,
5+
CONST_DEF, ENUM_DEF, FN, MODULE, STATIC_DEF, STRUCT_DEF, TRAIT_DEF, VISIBILITY,
66
},
77
T,
88
};
@@ -38,7 +38,7 @@ fn add_vis(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
3838

3939
let (offset, target) = if let Some(keyword) = item_keyword {
4040
let parent = keyword.parent();
41-
let def_kws = vec![CONST_DEF, STATIC_DEF, FN_DEF, MODULE, STRUCT_DEF, ENUM_DEF, TRAIT_DEF];
41+
let def_kws = vec![CONST_DEF, STATIC_DEF, FN, MODULE, STRUCT_DEF, ENUM_DEF, TRAIT_DEF];
4242
// Parent is not a definition, can't add visibility
4343
if !def_kws.iter().any(|&def_kw| def_kw == parent.kind()) {
4444
return None;

crates/ra_assists/src/handlers/early_return.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use ra_syntax::{
88
make,
99
},
1010
AstNode,
11-
SyntaxKind::{FN_DEF, LOOP_EXPR, L_CURLY, R_CURLY, WHILE_EXPR, WHITESPACE},
11+
SyntaxKind::{FN, LOOP_EXPR, L_CURLY, R_CURLY, WHILE_EXPR, WHITESPACE},
1212
SyntaxNode,
1313
};
1414

@@ -88,7 +88,7 @@ pub(crate) fn convert_to_guarded_return(acc: &mut Assists, ctx: &AssistContext)
8888

8989
let early_expression: ast::Expr = match parent_container.kind() {
9090
WHILE_EXPR | LOOP_EXPR => make::expr_continue(),
91-
FN_DEF => make::expr_return(),
91+
FN => make::expr_return(),
9292
_ => return None,
9393
};
9494

crates/ra_assists/src/handlers/generate_function.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ struct FunctionTemplate {
8282
insert_offset: TextSize,
8383
placeholder_expr: ast::MacroCall,
8484
leading_ws: String,
85-
fn_def: ast::FnDef,
85+
fn_def: ast::Fn,
8686
trailing_ws: String,
8787
file: FileId,
8888
}

crates/ra_assists/src/handlers/generate_new.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ fn find_struct_impl(ctx: &AssistContext, strukt: &ast::StructDef) -> Option<Opti
160160
fn has_new_fn(imp: &ast::ImplDef) -> bool {
161161
if let Some(il) = imp.assoc_item_list() {
162162
for item in il.assoc_items() {
163-
if let ast::AssocItem::FnDef(f) = item {
163+
if let ast::AssocItem::Fn(f) = item {
164164
if let Some(name) = f.name() {
165165
if name.text().eq_ignore_ascii_case("new") {
166166
return true;

crates/ra_assists/src/handlers/introduce_named_lifetime.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ pub(crate) fn introduce_named_lifetime(acc: &mut Assists, ctx: &AssistContext) -
3838
let lifetime_token = ctx
3939
.find_token_at_offset(SyntaxKind::LIFETIME)
4040
.filter(|lifetime| lifetime.text() == "'_")?;
41-
if let Some(fn_def) = lifetime_token.ancestors().find_map(ast::FnDef::cast) {
41+
if let Some(fn_def) = lifetime_token.ancestors().find_map(ast::Fn::cast) {
4242
generate_fn_def_assist(acc, &fn_def, lifetime_token.text_range())
4343
} else if let Some(impl_def) = lifetime_token.ancestors().find_map(ast::ImplDef::cast) {
4444
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) -
5050
/// Generate the assist for the fn def case
5151
fn generate_fn_def_assist(
5252
acc: &mut Assists,
53-
fn_def: &ast::FnDef,
53+
fn_def: &ast::Fn,
5454
lifetime_loc: TextRange,
5555
) -> Option<()> {
5656
let param_list: ast::ParamList = fn_def.param_list()?;

crates/ra_assists/src/handlers/move_bounds.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ pub(crate) fn move_bounds_to_where_clause(acc: &mut Assists, ctx: &AssistContext
3737

3838
let anchor = match_ast! {
3939
match parent {
40-
ast::FnDef(it) => it.body()?.syntax().clone().into(),
40+
ast::Fn(it) => it.body()?.syntax().clone().into(),
4141
ast::TraitDef(it) => it.assoc_item_list()?.syntax().clone().into(),
4242
ast::ImplDef(it) => it.assoc_item_list()?.syntax().clone().into(),
4343
ast::EnumDef(it) => it.variant_list()?.syntax().clone().into(),

crates/ra_assists/src/utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ pub fn get_missing_assoc_items(
6666
if let Some(item_list) = impl_def.assoc_item_list() {
6767
for item in item_list.assoc_items() {
6868
match item {
69-
ast::AssocItem::FnDef(f) => {
69+
ast::AssocItem::Fn(f) => {
7070
if let Some(n) = f.name() {
7171
impl_fns_consts.insert(n.syntax().to_string());
7272
}

crates/ra_hir/src/has_source.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ impl HasSource for EnumVariant {
8181
}
8282
}
8383
impl HasSource for Function {
84-
type Ast = ast::FnDef;
85-
fn source(self, db: &dyn HirDatabase) -> InFile<ast::FnDef> {
84+
type Ast = ast::Fn;
85+
fn source(self, db: &dyn HirDatabase) -> InFile<ast::Fn> {
8686
self.id.lookup(db.upcast()).source(db.upcast())
8787
}
8888
}

0 commit comments

Comments
 (0)