This commit is contained in:
soruh 2022-06-15 02:59:32 +02:00
parent 8e3bbaa57b
commit 8cac16b62e
2 changed files with 4 additions and 18 deletions

View file

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

View file

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