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

@ -1685,6 +1685,26 @@ impl BuiltinType {
pub fn name(self) -> Name {
self.inner.as_name()
}
pub fn is_int(&self) -> bool {
matches!(self.inner, hir_def::builtin_type::BuiltinType::Int(_))
}
pub fn is_uint(&self) -> bool {
matches!(self.inner, hir_def::builtin_type::BuiltinType::Uint(_))
}
pub fn is_float(&self) -> bool {
matches!(self.inner, hir_def::builtin_type::BuiltinType::Float(_))
}
pub fn is_char(&self) -> bool {
matches!(self.inner, hir_def::builtin_type::BuiltinType::Char)
}
pub fn is_str(&self) -> bool {
matches!(self.inner, hir_def::builtin_type::BuiltinType::Str)
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
@ -2573,6 +2593,10 @@ impl Type {
matches!(&self.ty.kind(Interner), TyKind::FnDef(..) | TyKind::Function { .. })
}
pub fn is_array(&self) -> bool {
matches!(&self.ty.kind(Interner), TyKind::Array(..))
}
pub fn is_packed(&self, db: &dyn HirDatabase) -> bool {
let adt_id = match *self.ty.kind(Interner) {
TyKind::Adt(hir_ty::AdtId(adt_id), ..) => adt_id,