Skip to content

Commit 0720f6a

Browse files
committed
fix test
1 parent fae24e5 commit 0720f6a

3 files changed

Lines changed: 7 additions & 18 deletions

File tree

‎tests/unit/inline_container_fields.cpp‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#include <array>
22
#include <cassert>
3-
#include <string>
43
#include <vector>
54

65
// Arrays and vectors in fields are stored inline in their structs, including
@@ -16,7 +15,6 @@ struct State {
1615
int count;
1716
int grid[2][3];
1817
std::array<int, 3> arr;
19-
std::string name;
2018
std::vector<Elem> elems;
2119
std::vector<std::vector<int>> rows;
2220
};
@@ -46,7 +44,7 @@ int main() {
4644
State s{};
4745
fill(&s);
4846
assert(s.grid[1][2] == 5 && sum(s.grid[1], 3) == 12);
49-
assert(s.arr[1] == 7 && s.name.empty());
47+
assert(s.arr[1] == 7);
5048

5149
// Pointers into containers in elements of a vector field, kept and used
5250
// while other fields of the struct change.
@@ -71,7 +69,7 @@ int main() {
7169
t.grid[0][0] = 100;
7270
t.rows[0][0] = 100;
7371
assert(s.elems[2].hist[0] == 0 && s.grid[0][0] == 0 && s.rows[0][0] == 1);
74-
assert(t.elems[2].coeffs[1] == 7 && t.name.empty());
72+
assert(t.elems[2].coeffs[1] == 7);
7573

7674
// Elements of array and vector fields reached through pointers.
7775
State *p = &t;

‎tests/unit/out/refcount/inline_container_fields.rs‎

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ impl Default for Elem {
3030
}
3131
}
3232
#[derive(Clone, Record, ByteRepr, VaArg, FnPtrArg)]
33-
#[byte_size(120)]
33+
#[byte_size(88)]
3434
pub struct State {
3535
#[offset(0)]
3636
pub count: i32,
@@ -41,12 +41,9 @@ pub struct State {
4141
#[byte_size(12)]
4242
pub arr: Vec<i32>,
4343
#[offset(40)]
44-
#[byte_size(32)]
45-
pub name: Vec<i8>,
46-
#[offset(72)]
4744
#[byte_size(24)]
4845
pub elems: Vec<Elem>,
49-
#[offset(96)]
46+
#[offset(64)]
5047
#[byte_size(24)]
5148
pub rows: Vec<Vec<i32>>,
5249
}
@@ -59,7 +56,6 @@ impl Default for State {
5956
.map(|_| (0..3).map(|_| 0_i32).collect::<Box<[i32]>>())
6057
.collect::<Box<[Box<[i32]>]>>(),
6158
arr: std::array::from_fn::<_, 3, _>(|_| Default::default()).to_vec(),
62-
name: vec![0],
6359
elems: Default::default(),
6460
rows: Default::default(),
6561
}
@@ -126,9 +122,7 @@ fn main_0() -> i32 {
126122
)
127123
}) == 12)
128124
);
129-
assert!(
130-
((vec_elem!(s.as_pointer(), arr, 1_usize).read()) == 7) && ((*s.borrow()).name.len() <= 1)
131-
);
125+
assert!(((vec_elem!(s.as_pointer(), arr, 1_usize).read()) == 7));
132126
let mut e: Ptr<Elem> =
133127
((field_ref!(s.as_pointer(), elems).as_pointer() as Ptr<Elem>).offset(2_usize));
134128
let mut h: Ptr<i32> = (array_field_ptr!(e, hist) as Ptr<i32>);
@@ -197,7 +191,6 @@ fn main_0() -> i32 {
197191
)
198192
.read()) as i32)
199193
== 7)
200-
&& ((*t.borrow()).name.len() <= 1)
201194
);
202195
let mut p: Ptr<State> = (t.as_pointer());
203196
let __rhs = ({ (*p.upgrade().deref()).grid[(1) as usize][(1) as usize] } + {

‎tests/unit/out/unsafe/inline_container_fields.rs‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ pub struct State {
1919
pub count: i32,
2020
pub grid: [[i32; 3]; 2],
2121
pub arr: Vec<i32>,
22-
pub name: Vec<libc::c_char>,
2322
pub elems: Vec<Elem>,
2423
pub rows: Vec<Vec<i32>>,
2524
}
@@ -30,7 +29,6 @@ impl Default for State {
3029
count: 0_i32,
3130
grid: [[0_i32; 3]; 2],
3231
arr: std::array::from_fn::<_, 3, _>(|_| Default::default()).to_vec(),
33-
name: vec![0],
3432
elems: Default::default(),
3533
rows: Default::default(),
3634
}
@@ -91,7 +89,7 @@ unsafe fn main_0() -> i32 {
9189
((s.grid[(1) as usize][(2) as usize]) == (5))
9290
&& ((unsafe { sum_0((s.grid[(1) as usize].as_mut_ptr()).cast_const(), 3,) }) == (12))
9391
);
94-
assert!(((s.arr[(1_usize)]) == (7)) && (s.name.len() <= 1));
92+
assert!(((s.arr[(1_usize)]) == (7)));
9593
let mut e: *mut Elem = (&mut s.elems[(2_usize)] as *mut Elem);
9694
let mut h: *mut i32 = (*e).hist.as_mut_ptr();
9795
let mut c: *mut i16 = (&mut (&mut (*e)).coeffs[(1_usize)] as *mut i16);
@@ -125,7 +123,7 @@ unsafe fn main_0() -> i32 {
125123
&& ((s.grid[(0) as usize][(0) as usize]) == (0)))
126124
&& ((s.rows[(0_usize)][(0_usize)]) == (1))
127125
);
128-
assert!(((t.elems[(2_usize)].coeffs[(1_usize)] as i32) == (7)) && (t.name.len() <= 1));
126+
assert!(((t.elems[(2_usize)].coeffs[(1_usize)] as i32) == (7)));
129127
let mut p: *mut State = (&mut t as *mut State);
130128
(&mut (*p)).elems[(0_usize)].hist[(3) as usize] =
131129
(((*p).grid[(1) as usize][(1) as usize]) + ((&mut (*p)).arr[(1_usize)]));

0 commit comments

Comments
 (0)