mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-02 07:22:42 +00:00
Replace if let Some(_) = foo
with if foo.is_some()
This commit is contained in:
parent
eff195852d
commit
f29796da61
@ -1119,7 +1119,7 @@ impl DefWithBody {
|
||||
if let ast::Expr::RecordExpr(record_expr) =
|
||||
&source_ptr.value.to_node(&root)
|
||||
{
|
||||
if let Some(_) = record_expr.record_expr_field_list() {
|
||||
if record_expr.record_expr_field_list().is_some() {
|
||||
acc.push(
|
||||
MissingFields {
|
||||
file: source_ptr.file_id,
|
||||
@ -1143,7 +1143,7 @@ impl DefWithBody {
|
||||
if let Some(expr) = source_ptr.value.as_ref().left() {
|
||||
let root = source_ptr.file_syntax(db.upcast());
|
||||
if let ast::Pat::RecordPat(record_pat) = expr.to_node(&root) {
|
||||
if let Some(_) = record_pat.record_pat_field_list() {
|
||||
if record_pat.record_pat_field_list().is_some() {
|
||||
acc.push(
|
||||
MissingFields {
|
||||
file: source_ptr.file_id,
|
||||
|
@ -156,7 +156,7 @@ fn rename_to_self(sema: &Semantics<RootDatabase>, local: hir::Local) -> RenameRe
|
||||
_ => bail!("Cannot rename local to self outside of function"),
|
||||
};
|
||||
|
||||
if let Some(_) = fn_def.self_param(sema.db) {
|
||||
if fn_def.self_param(sema.db).is_some() {
|
||||
bail!("Method already has a self parameter");
|
||||
}
|
||||
|
||||
|
@ -330,7 +330,7 @@ fn traverse(
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(_) = macro_highlighter.highlight(element_to_highlight.clone()) {
|
||||
if macro_highlighter.highlight(element_to_highlight.clone()).is_some() {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -44,7 +44,7 @@ pub(crate) fn convert_while_to_loop(acc: &mut Assists, ctx: &AssistContext) -> O
|
||||
let cond = while_expr.condition()?;
|
||||
|
||||
// Don't handle while let
|
||||
if let Some(_) = cond.pat() {
|
||||
if cond.pat().is_some() {
|
||||
return None;
|
||||
};
|
||||
|
||||
|
@ -318,7 +318,7 @@ pub fn source_edit_from_references(
|
||||
}
|
||||
|
||||
fn source_edit_from_name(edit: &mut TextEditBuilder, name: &ast::Name, new_name: &str) -> bool {
|
||||
if let Some(_) = ast::RecordPatField::for_field_name(name) {
|
||||
if ast::RecordPatField::for_field_name(name).is_some() {
|
||||
if let Some(ident_pat) = name.syntax().parent().and_then(ast::IdentPat::cast) {
|
||||
cov_mark::hit!(rename_record_pat_field_name_split);
|
||||
// Foo { ref mut field } -> Foo { new_name: ref mut field }
|
||||
|
@ -455,7 +455,7 @@ impl ast::RecordExprField {
|
||||
/// This will either replace the initializer, or in the case that this is a shorthand convert
|
||||
/// the initializer into the name ref and insert the expr as the new initializer.
|
||||
pub fn replace_expr(&self, expr: ast::Expr) {
|
||||
if let Some(_) = self.name_ref() {
|
||||
if self.name_ref().is_some() {
|
||||
match self.expr() {
|
||||
Some(prev) => ted::replace(prev.syntax(), expr.syntax()),
|
||||
None => ted::append_child(self.syntax(), expr.syntax()),
|
||||
|
Loading…
Reference in New Issue
Block a user