Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions c2rust-transpile/src/c_ast/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2679,6 +2679,10 @@ impl CTypeKind {
matches!(self, Float | Double | LongDouble | Half | BFloat16)
}

pub fn is_scalar(&self) -> bool {
self.is_integral_type() || self.is_floating_type() || self.is_enum() || self.is_pointer()
}

pub fn as_underlying_decl(&self) -> Option<CDeclId> {
use CTypeKind::*;
match *self {
Expand Down
10 changes: 1 addition & 9 deletions c2rust-transpile/src/translator/literals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,18 +247,10 @@ impl<'c> Translation<'c> {
CTypeKind::Union(union_id) => {
self.convert_union_literal(ctx, union_id, ids.as_ref(), ty, opt_union_field_id)
}
CTypeKind::Pointer(_) => {
let id = ids.first().unwrap();
self.convert_expr(ctx.used(), *id, None)
}
CTypeKind::Enum(_) => {
let id = ids.first().unwrap();
self.convert_expr(ctx.used(), *id, None)
}
CTypeKind::Vector(CQualTypeId { ctype, .. }, len) => {
self.vector_list_initializer(ctx, ids, ctype, len)
}
ref kind if kind.is_integral_type() => {
ref kind if kind.is_scalar() => {
let id = ids.first().unwrap();
self.convert_expr(ctx.used(), *id, None)
}
Expand Down
Loading