]> git.lizzy.rs Git - rust.git/commitdiff
cleanup
authorsoruh <mail@soruh.de>
Wed, 15 Jun 2022 00:59:32 +0000 (02:59 +0200)
committersoruh <mail@soruh.de>
Wed, 15 Jun 2022 00:59:32 +0000 (02:59 +0200)
crates/ide-assists/src/handlers/generate_new.rs
crates/ide-diagnostics/src/handlers/missing_fields.rs

index fc17c5626e1a861b74c11e3c99b224803f2a26b8..31e36a51e8d8b057baf77953d26efaec18bf5e86 100644 (file)
@@ -29,12 +29,7 @@ pub fn use_trivial_constructor(
                         )),
                     );
 
-                    use hir::StructKind::*;
-                    let is_record = match variant.kind(db) {
-                        Record => true,
-                        Tuple => false,
-                        Unit => false,
-                    };
+                    let is_record = variant.kind(db) == hir::StructKind::Record;
 
                     return Some(if is_record {
                         ast::Expr::RecordExpr(syntax::ast::make::record_expr(
@@ -48,9 +43,7 @@ pub fn use_trivial_constructor(
             }
         }
         Some(hir::Adt::Struct(x)) => {
-            let fields = x.fields(db);
-
-            if fields.is_empty() {
+            if x.fields(db).is_empty() {
                 return Some(syntax::ast::make::expr_path(path));
             }
         }
index ff7d8de8fdc6ab75e4ecf40aa1f048f212e3b83c..5739a8785382ed4c126986c654131b07c031dbce 100644 (file)
@@ -38,12 +38,7 @@ pub fn use_trivial_constructor(
                         )),
                     );
 
-                    use hir::StructKind::*;
-                    let is_record = match variant.kind(db) {
-                        Record => true,
-                        Tuple => false,
-                        Unit => false,
-                    };
+                    let is_record = variant.kind(db) == hir::StructKind::Record;
 
                     return Some(if is_record {
                         ast::Expr::RecordExpr(syntax::ast::make::record_expr(
@@ -57,9 +52,7 @@ pub fn use_trivial_constructor(
             }
         }
         Some(hir::Adt::Struct(x)) => {
-            let fields = x.fields(db);
-
-            if fields.is_empty() {
+            if x.fields(db).is_empty() {
                 return Some(syntax::ast::make::expr_path(path));
             }
         }