Skip to content

Commit a9889a0

Browse files
committed
fix the rest of the nits
1 parent f9a144f commit a9889a0

File tree

3 files changed

+18
-20
lines changed

3 files changed

+18
-20
lines changed

crates/ide-assists/src/handlers/add_missing_match_arms.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -205,13 +205,15 @@ pub(crate) fn add_missing_match_arms(acc: &mut Assists, ctx: &AssistContext<'_>)
205205
// having any hidden variants means that we need a catch-all arm
206206
needs_catch_all_arm |= has_hidden_variants;
207207

208-
let missing_arms = missing_pats.filter_map(|(pat, hidden)| {
209-
// filter out hidden patterns because they're handled by the catch-all arm
210-
(!hidden).then(|| {
208+
let missing_arms = missing_pats
209+
.filter(|(_, hidden)| {
210+
// filter out hidden patterns because they're handled by the catch-all arm
211+
!hidden
212+
})
213+
.map(|(pat, _)| {
211214
make::match_arm(iter::once(pat), None, make::ext::expr_todo())
212215
.clone_for_update()
213-
})
214-
});
216+
});
215217

216218
let catch_all_arm = new_match_arm_list
217219
.arms()

crates/ide-assists/src/handlers/fix_visibility.rs

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -100,14 +100,14 @@ fn add_vis_to_referenced_record_field(acc: &mut Assists, ctx: &AssistContext<'_>
100100
let target_module = parent.module(ctx.db());
101101

102102
let in_file_source = record_field_def.source(ctx.db())?;
103-
let (vis_owner, target): (ast::AnyHasVisibility, TextRange) = match in_file_source.value {
103+
let (vis_owner, target) = match in_file_source.value {
104104
hir::FieldSource::Named(it) => {
105-
let s = it.syntax();
106-
(ast::AnyHasVisibility::cast(s.clone()).unwrap(), s.text_range())
105+
let range = it.syntax().text_range();
106+
(ast::AnyHasVisibility::new(it), range)
107107
}
108108
hir::FieldSource::Pos(it) => {
109-
let s = it.syntax();
110-
(ast::AnyHasVisibility::cast(s.clone()).unwrap(), s.text_range())
109+
let range = it.syntax().text_range();
110+
(ast::AnyHasVisibility::new(it), range)
111111
}
112112
};
113113

@@ -152,12 +152,8 @@ fn target_data_for_def(
152152
let source = x.source(db)?;
153153
let in_file_syntax = source.syntax();
154154
let file_id = in_file_syntax.file_id;
155-
let syntax = in_file_syntax.value;
156-
Some((
157-
ast::AnyHasVisibility::cast(syntax.clone()).unwrap(),
158-
syntax.text_range(),
159-
file_id.original_file(db.upcast()),
160-
))
155+
let range = in_file_syntax.value.text_range();
156+
Some((ast::AnyHasVisibility::new(source.value), range, file_id.original_file(db.upcast())))
161157
}
162158

163159
let target_name;
@@ -198,8 +194,8 @@ fn target_data_for_def(
198194
target_name = m.name(db);
199195
let in_file_source = m.declaration_source(db)?;
200196
let file_id = in_file_source.file_id.original_file(db.upcast());
201-
let syntax = in_file_source.value.syntax();
202-
(ast::AnyHasVisibility::cast(syntax.clone()).unwrap(), syntax.text_range(), file_id)
197+
let range = in_file_source.value.syntax().text_range();
198+
(ast::AnyHasVisibility::new(in_file_source.value), range, file_id)
203199
}
204200
// FIXME
205201
hir::ModuleDef::Macro(_) => return None,

crates/ide-assists/src/handlers/promote_local_to_const.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,11 @@ pub(crate) fn promote_local_to_const(acc: &mut Assists, ctx: &AssistContext<'_>)
6767
cov_mark::hit!(promote_local_non_const);
6868
return None;
6969
}
70-
let target = let_stmt.syntax().text_range();
70+
7171
acc.add(
7272
AssistId("promote_local_to_const", AssistKind::Refactor),
7373
"Promote local to constant",
74-
target,
74+
let_stmt.syntax().text_range(),
7575
|edit| {
7676
let name = to_upper_snake_case(&name.to_string());
7777
let usages = Definition::Local(local).usages(&ctx.sema).all();

0 commit comments

Comments
 (0)