Skip to content

Commit 2cb079b

Browse files
bors[bot]matklad
andauthored
Merge #5672
5672: align names in make r=matklad a=matklad bors r+ 🤖 Co-authored-by: Aleksey Kladov <[email protected]>
2 parents ed4687f + 09d3b7d commit 2cb079b

File tree

12 files changed

+29
-28
lines changed

12 files changed

+29
-28
lines changed

crates/ra_assists/src/ast_transform.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ impl<'a> SubstituteTypeParams<'a> {
6363
let default = k.default(source_scope.db)?;
6464
Some((
6565
k,
66-
ast::make::type_ref(
66+
ast::make::ty(
6767
&default
6868
.display_source_code(source_scope.db, source_scope.module()?.into())
6969
.ok()?,

crates/ra_assists/src/handlers/early_return.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ pub(crate) fn convert_to_guarded_return(acc: &mut Assists, ctx: &AssistContext)
123123
let happy_arm = {
124124
let pat = make::tuple_struct_pat(
125125
path,
126-
once(make::bind_pat(make::name("it")).into()),
126+
once(make::ident_pat(make::name("it")).into()),
127127
);
128128
let expr = {
129129
let name_ref = make::name_ref("it");
@@ -136,15 +136,15 @@ pub(crate) fn convert_to_guarded_return(acc: &mut Assists, ctx: &AssistContext)
136136

137137
let sad_arm = make::match_arm(
138138
// FIXME: would be cool to use `None` or `Err(_)` if appropriate
139-
once(make::placeholder_pat().into()),
139+
once(make::wildcard_pat().into()),
140140
early_expression,
141141
);
142142

143143
make::expr_match(cond_expr, make::match_arm_list(vec![happy_arm, sad_arm]))
144144
};
145145

146146
let let_stmt = make::let_stmt(
147-
make::bind_pat(make::name(&bound_ident.syntax().to_string())).into(),
147+
make::ident_pat(make::name(&bound_ident.syntax().to_string())).into(),
148148
Some(match_expr),
149149
);
150150
let let_stmt = let_stmt.indent(if_indent_level);

crates/ra_assists/src/handlers/expand_glob_import.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ fn replace_ast(
173173
replace_node(replacement);
174174
},
175175
ast::Use(use_item) => {
176-
builder.replace_ast(use_item, ast::make::use_item(replacement.left_or_else(|ut| ast::make::use_tree(path, Some(ut), None, false))));
176+
builder.replace_ast(use_item, ast::make::use_(replacement.left_or_else(|ut| ast::make::use_tree(path, Some(ut), None, false))));
177177
},
178178
_ => {},
179179
}

crates/ra_assists/src/handlers/fill_match_arms.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,12 +197,11 @@ fn build_pat(db: &RootDatabase, module: hir::Module, var: hir::EnumVariant) -> O
197197
// FIXME: use HIR for this; it doesn't currently expose struct vs. tuple vs. unit variants though
198198
let pat: ast::Pat = match var.source(db).value.kind() {
199199
ast::StructKind::Tuple(field_list) => {
200-
let pats =
201-
iter::repeat(make::placeholder_pat().into()).take(field_list.fields().count());
200+
let pats = iter::repeat(make::wildcard_pat().into()).take(field_list.fields().count());
202201
make::tuple_struct_pat(path, pats).into()
203202
}
204203
ast::StructKind::Record(field_list) => {
205-
let pats = field_list.fields().map(|f| make::bind_pat(f.name().unwrap()).into());
204+
let pats = field_list.fields().map(|f| make::ident_pat(f.name().unwrap()).into());
206205
make::record_pat(path, pats).into()
207206
}
208207
ast::StructKind::Unit => make::path_pat(path),

crates/ra_assists/src/handlers/generate_function.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ impl FunctionBuilder {
142142
let fn_body = make::block_expr(vec![], Some(placeholder_expr));
143143
let visibility = if self.needs_pub { Some(make::visibility_pub_crate()) } else { None };
144144
let mut fn_def =
145-
make::fn_def(visibility, self.fn_name, self.type_params, self.params, fn_body);
145+
make::fn_(visibility, self.fn_name, self.type_params, self.params, fn_body);
146146
let leading_ws;
147147
let trailing_ws;
148148

crates/ra_assists/src/handlers/replace_if_let_with_match.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ pub(crate) fn replace_if_let_with_match(acc: &mut Assists, ctx: &AssistContext)
6565
.type_of_pat(&pat)
6666
.and_then(|ty| TryEnum::from_ty(&ctx.sema, &ty))
6767
.map(|it| it.sad_pattern())
68-
.unwrap_or_else(|| make::placeholder_pat().into());
68+
.unwrap_or_else(|| make::wildcard_pat().into());
6969
let else_expr = unwrap_trivial_block(else_block);
7070
make::match_arm(vec![pattern], else_expr)
7171
};

crates/ra_assists/src/handlers/replace_let_with_if_let.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@ pub(crate) fn replace_let_with_if_let(acc: &mut Assists, ctx: &AssistContext) ->
5050
target,
5151
|edit| {
5252
let with_placeholder: ast::Pat = match happy_variant {
53-
None => make::placeholder_pat().into(),
53+
None => make::wildcard_pat().into(),
5454
Some(var_name) => make::tuple_struct_pat(
5555
make::path_unqualified(make::path_segment(make::name_ref(var_name))),
56-
once(make::placeholder_pat().into()),
56+
once(make::wildcard_pat().into()),
5757
)
5858
.into(),
5959
};

crates/ra_assists/src/handlers/replace_unwrap_with_match.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,15 @@ pub(crate) fn replace_unwrap_with_match(acc: &mut Assists, ctx: &AssistContext)
5252
target,
5353
|builder| {
5454
let ok_path = make::path_unqualified(make::path_segment(make::name_ref(happy_variant)));
55-
let it = make::bind_pat(make::name("a")).into();
55+
let it = make::ident_pat(make::name("a")).into();
5656
let ok_tuple = make::tuple_struct_pat(ok_path, iter::once(it)).into();
5757

5858
let bind_path = make::path_unqualified(make::path_segment(make::name_ref("a")));
5959
let ok_arm = make::match_arm(iter::once(ok_tuple), make::expr_path(bind_path));
6060

6161
let unreachable_call = make::expr_unreachable();
6262
let err_arm =
63-
make::match_arm(iter::once(make::placeholder_pat().into()), unreachable_call);
63+
make::match_arm(iter::once(make::wildcard_pat().into()), unreachable_call);
6464

6565
let match_arm_list = make::match_arm_list(vec![ok_arm, err_arm]);
6666
let match_expr = make::expr_match(caller.clone(), match_arm_list)

crates/ra_assists/src/utils.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,10 +181,10 @@ impl TryEnum {
181181
match self {
182182
TryEnum::Result => make::tuple_struct_pat(
183183
make::path_unqualified(make::path_segment(make::name_ref("Err"))),
184-
iter::once(make::placeholder_pat().into()),
184+
iter::once(make::wildcard_pat().into()),
185185
)
186186
.into(),
187-
TryEnum::Option => make::bind_pat(make::name("None")).into(),
187+
TryEnum::Option => make::ident_pat(make::name("None")).into(),
188188
}
189189
}
190190

crates/ra_ide/src/diagnostics.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,10 @@ pub(crate) fn diagnostics(
7878
} else {
7979
let mut field_list = d.ast(db);
8080
for f in d.missed_fields.iter() {
81-
let field =
82-
make::record_field(make::name_ref(&f.to_string()), Some(make::expr_unit()));
81+
let field = make::record_expr_field(
82+
make::name_ref(&f.to_string()),
83+
Some(make::expr_unit()),
84+
);
8385
field_list = field_list.append_field(&field);
8486
}
8587

@@ -178,9 +180,9 @@ fn missing_struct_field_fix(
178180
if new_field_type.is_unknown() {
179181
return None;
180182
}
181-
let new_field = make::record_field_def(
183+
let new_field = make::record_field(
182184
record_expr.field_name()?,
183-
make::type_ref(&new_field_type.display_source_code(sema.db, module.into()).ok()?),
185+
make::ty(&new_field_type.display_source_code(sema.db, module.into()).ok()?),
184186
);
185187

186188
let last_field = record_fields.fields().last()?;

0 commit comments

Comments
 (0)