Skip to content

Commit f3d30c2

Browse files
committed
Replace if let Some(_) = foo with if let foo.is_some()
1 parent eff1958 commit f3d30c2

File tree

6 files changed

+7
-7
lines changed

6 files changed

+7
-7
lines changed

crates/hir/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1119,7 +1119,7 @@ impl DefWithBody {
11191119
if let ast::Expr::RecordExpr(record_expr) =
11201120
&source_ptr.value.to_node(&root)
11211121
{
1122-
if let Some(_) = record_expr.record_expr_field_list() {
1122+
if record_expr.record_expr_field_list().is_some() {
11231123
acc.push(
11241124
MissingFields {
11251125
file: source_ptr.file_id,
@@ -1143,7 +1143,7 @@ impl DefWithBody {
11431143
if let Some(expr) = source_ptr.value.as_ref().left() {
11441144
let root = source_ptr.file_syntax(db.upcast());
11451145
if let ast::Pat::RecordPat(record_pat) = expr.to_node(&root) {
1146-
if let Some(_) = record_pat.record_pat_field_list() {
1146+
if record_pat.record_pat_field_list().is_some() {
11471147
acc.push(
11481148
MissingFields {
11491149
file: source_ptr.file_id,

crates/ide/src/rename.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ fn rename_to_self(sema: &Semantics<RootDatabase>, local: hir::Local) -> RenameRe
156156
_ => bail!("Cannot rename local to self outside of function"),
157157
};
158158

159-
if let Some(_) = fn_def.self_param(sema.db) {
159+
if fn_def.self_param(sema.db).is_some() {
160160
bail!("Method already has a self parameter");
161161
}
162162

crates/ide/src/syntax_highlighting.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ fn traverse(
330330
}
331331
}
332332

333-
if let Some(_) = macro_highlighter.highlight(element_to_highlight.clone()) {
333+
if macro_highlighter.highlight(element_to_highlight.clone()).is_some() {
334334
continue;
335335
}
336336

crates/ide_assists/src/handlers/convert_while_to_loop.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ pub(crate) fn convert_while_to_loop(acc: &mut Assists, ctx: &AssistContext) -> O
4444
let cond = while_expr.condition()?;
4545

4646
// Don't handle while let
47-
if let Some(_) = cond.pat() {
47+
if cond.pat().is_some() {
4848
return None;
4949
};
5050

crates/ide_db/src/rename.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ pub fn source_edit_from_references(
318318
}
319319

320320
fn source_edit_from_name(edit: &mut TextEditBuilder, name: &ast::Name, new_name: &str) -> bool {
321-
if let Some(_) = ast::RecordPatField::for_field_name(name) {
321+
if ast::RecordPatField::for_field_name(name).is_some() {
322322
if let Some(ident_pat) = name.syntax().parent().and_then(ast::IdentPat::cast) {
323323
cov_mark::hit!(rename_record_pat_field_name_split);
324324
// Foo { ref mut field } -> Foo { new_name: ref mut field }

crates/syntax/src/ast/edit_in_place.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ impl ast::RecordExprField {
455455
/// This will either replace the initializer, or in the case that this is a shorthand convert
456456
/// the initializer into the name ref and insert the expr as the new initializer.
457457
pub fn replace_expr(&self, expr: ast::Expr) {
458-
if let Some(_) = self.name_ref() {
458+
if self.name_ref().is_some() {
459459
match self.expr() {
460460
Some(prev) => ted::replace(prev.syntax(), expr.syntax()),
461461
None => ted::append_child(self.syntax(), expr.syntax()),

0 commit comments

Comments
 (0)