File tree Expand file tree Collapse file tree 4 files changed +13
-8
lines changed Expand file tree Collapse file tree 4 files changed +13
-8
lines changed Original file line number Diff line number Diff line change @@ -476,9 +476,10 @@ pub struct ComponentDefinedTypeId {
476
476
alias_id : u32 ,
477
477
}
478
478
479
- const _: ( ) = {
479
+ #[ test]
480
+ fn assert_defined_type_small ( ) {
480
481
assert ! ( core:: mem:: size_of:: <ComponentDefinedTypeId >( ) <= 8 ) ;
481
- } ;
482
+ }
482
483
483
484
impl TypeIdentifier for ComponentDefinedTypeId {
484
485
type Data = ComponentDefinedType ;
Original file line number Diff line number Diff line change @@ -252,9 +252,10 @@ enum MaybeType<T = ValType> {
252
252
// The validator is pretty performance-sensitive and `MaybeType` is the main
253
253
// unit of storage, so assert that it doesn't exceed 4 bytes which is the
254
254
// current expected size.
255
- const _: ( ) = {
255
+ #[ test]
256
+ fn assert_maybe_type_small ( ) {
256
257
assert ! ( core:: mem:: size_of:: <MaybeType >( ) == 4 ) ;
257
- } ;
258
+ }
258
259
259
260
impl core:: fmt:: Display for MaybeType {
260
261
fn fmt ( & self , f : & mut core:: fmt:: Formatter < ' _ > ) -> core:: fmt:: Result {
Original file line number Diff line number Diff line change @@ -89,6 +89,7 @@ macro_rules! define_type_id {
89
89
}
90
90
}
91
91
92
+
92
93
// The size of type IDs was seen to have a large-ish impact in #844, so
93
94
// this assert ensures that it stays relatively small.
94
95
const _: ( ) = {
@@ -106,9 +107,10 @@ pub struct CoreTypeId {
106
107
index : u32 ,
107
108
}
108
109
109
- const _: ( ) = {
110
+ #[ test]
111
+ fn assert_core_type_id_small ( ) {
110
112
assert ! ( core:: mem:: size_of:: <CoreTypeId >( ) <= 4 ) ;
111
- } ;
113
+ }
112
114
113
115
impl TypeIdentifier for CoreTypeId {
114
116
type Data = SubType ;
Original file line number Diff line number Diff line change @@ -1208,11 +1208,12 @@ instructions! {
1208
1208
// since big `*.wat` files will have a lot of these. This is a small ratchet to
1209
1209
// make sure that this enum doesn't become larger than it already is, although
1210
1210
// ideally it also wouldn't be as large as it is now.
1211
- const _: ( ) = {
1211
+ #[ test]
1212
+ fn assert_instruction_not_too_large ( ) {
1212
1213
let size = std:: mem:: size_of :: < Instruction < ' _ > > ( ) ;
1213
1214
let pointer = std:: mem:: size_of :: < u64 > ( ) ;
1214
1215
assert ! ( size <= pointer * 11 ) ;
1215
- } ;
1216
+ }
1216
1217
1217
1218
impl < ' a > Instruction < ' a > {
1218
1219
pub ( crate ) fn needs_data_count ( & self ) -> bool {
You can’t perform that action at this time.
0 commit comments