add better default behavior on fill struct fields diagnostic

Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
This commit is contained in:
Benjamin Coenen 2022-01-04 15:59:00 +01:00
parent df6fa50f92
commit 336c899a07
6 changed files with 123 additions and 13 deletions

View file

@ -59,8 +59,27 @@ pub mod ext {
pub fn expr_todo() -> ast::Expr {
expr_from_text("todo!()")
}
pub fn expr_default() -> ast::Expr {
expr_from_text("Default::default()")
pub fn expr_ty_default(ty: &ast::Type) -> ast::Expr {
expr_from_text(&format!("{}::default()", ty))
}
pub fn expr_ty_new(ty: &ast::Type) -> ast::Expr {
expr_from_text(&format!("{}::new()", ty))
}
pub fn zero_number() -> ast::Expr {
expr_from_text("0")
}
pub fn zero_float() -> ast::Expr {
expr_from_text("0.0")
}
pub fn empty_str() -> ast::Expr {
expr_from_text(r#""""#)
}
pub fn empty_char() -> ast::Expr {
expr_from_text("''")
}
pub fn default_bool() -> ast::Expr {
expr_from_text("false")
}
pub fn empty_block_expr() -> ast::BlockExpr {
block_expr(None, None)