Skip to content

panicked at: 'Not sure how to get the size of VoidType' #10

Closed
@Badel2

Description

I wanted to test if a simple function can panic:

pub fn panic_if_not_zero(x: u32) {
    assert_eq!(x, 0);
}

But haybale panicked at 'Not sure how to get the size of VoidType'. I guess that's because the function returns void and that's not supported.

I tried to patch it by setting the size of VoidType to 0 and it seems to work:

diff --git a/src/project.rs b/src/project.rs
index 058c5ff..d171e2d 100644
--- a/src/project.rs
+++ b/src/project.rs
@@ -350,6 +350,7 @@ impl Project {
                 (NamedStructDef::Opaque, _) => None,
                 (NamedStructDef::Defined(ty), _) => self.size_in_bits(&ty),
             },
+            Type::VoidType => Some(0),
             ty => panic!("Not sure how to get the size of {:?}", ty),
         }
     }

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions