Skip to content

Commit a401d94

Browse files
committed
Box ProcType in Type enum
ProcType embeds Function and an optional BlockType directly, making it ~400 bytes while the next-largest variant is 88 bytes. Since the enum size is that of its largest variant, every Type occupied 400 bytes. Boxing the rare Proc variant shrinks Type to 96 bytes and resolves the clippy::large_enum_variant error under -D warnings. https://claude.ai/code/session_01Bb4HnSKGf3PMGo1F8LUpz4
1 parent a12e0e8 commit a401d94

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

rust/ruby-rbs/src/ast/convert.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,12 +154,12 @@ impl<'a> AstConverter<'a> {
154154
ty: Box::new(self.convert_type(&node.type_())),
155155
location: Some(convert_range(node.location())),
156156
}),
157-
Node::ProcType(node) => Type::Proc(ProcType {
157+
Node::ProcType(node) => Type::Proc(Box::new(ProcType {
158158
function: self.convert_function_type(&node.type_()),
159159
block: node.block().map(|block| self.convert_block_type(&block)),
160160
self_type: node.self_type().map(|ty| Box::new(self.convert_type(&ty))),
161161
location: Some(convert_range(node.location())),
162-
}),
162+
})),
163163
Node::RecordType(node) => {
164164
let mut fields = Vec::new();
165165
for (key, value) in node.all_fields().iter() {

rust/ruby-rbs/src/ast/types.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pub enum Type {
1717
Optional(OptionalType),
1818
Union(UnionType),
1919
Intersection(IntersectionType),
20-
Proc(ProcType),
20+
Proc(Box<ProcType>),
2121
Literal(LiteralType),
2222
}
2323

0 commit comments

Comments
 (0)