From 8604dc722c504d943791a2b4039308bb05cbb728 Mon Sep 17 00:00:00 2001
From: Keqian Zhu <zhukeqian1@huawei.com>
Date: Wed, 1 Mar 2023 09:17:04 +0800
Subject: [PATCH] util/byte_code: Fix UT failure under high version rustc

The memory layout of high version rustc is different, use
repr C to fix the layout.

Signed-off-by: Keqian Zhu <zhukeqian1@huawei.com>
---
 util/src/byte_code.rs | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/util/src/byte_code.rs b/util/src/byte_code.rs
index cd460459..0bdfe086 100644
--- a/util/src/byte_code.rs
+++ b/util/src/byte_code.rs
@@ -75,6 +75,7 @@ impl ByteCode for i128 {}
 mod test {
     use super::*;
 
+    #[repr(C)]
     #[allow(dead_code)]
     #[derive(Copy, Clone, Default)]
     struct TestData {
@@ -105,9 +106,9 @@ mod test {
         };
 
         let mut target = Vec::new();
+        target.extend_from_slice(b"bytecode");
         target.extend_from_slice(&[0x79, 0x56, 0x34, 0x12]);
         target.extend_from_slice(&[0_u8; 4]);
-        target.extend_from_slice(b"bytecode");
         assert_eq!(data.as_bytes().to_vec(), target);
 
         // Convert failed because byte stream's length is not equal to size of struct.
-- 
2.33.0

