Skip to content

Commit e27538f

Browse files
morealyouknowone
authored andcommitted
Correct PyInner<T> fields order
Because `PyInner<T>` struct follows C langauge's representation, when passing `impl From<PyRef<T>> for PyObjectRef`, the unsafe function, `NonNull::cast`, harms the `slots` fields. This reorders the fields to make `payload` field go to the last.
1 parent e7b39bd commit e27538f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

vm/src/object/core.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,9 @@ struct PyInner<T> {
114114
typ: PyRwLock<PyTypeRef>, // __class__ member
115115
dict: Option<InstanceDict>,
116116
weak_list: WeakRefList,
117+
slots: Box<[PyRwLock<Option<PyObjectRef>>]>,
117118

118119
payload: T,
119-
slots: Box<[PyRwLock<Option<PyObjectRef>>]>,
120120
}
121121

122122
impl<T: fmt::Debug> fmt::Debug for PyInner<T> {

0 commit comments

Comments
 (0)