mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-27 13:33:31 +00:00
cleanup
This commit is contained in:
parent
8e3bbaa57b
commit
8cac16b62e
2 changed files with 4 additions and 18 deletions
|
@ -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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue