X Tutup
Skip to content
Merged

rustfmt #7390

Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 12 additions & 19 deletions crates/vm/src/object/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -331,8 +331,7 @@ const _: () = assert!(core::mem::align_of::<ObjExt>() >= core::mem::align_of::<P
const _: () = assert!(
core::mem::size_of::<WeakRefList>().is_multiple_of(core::mem::align_of::<WeakRefList>())
);
const _: () =
assert!(core::mem::align_of::<WeakRefList>() >= core::mem::align_of::<PyInner<()>>());
const _: () = assert!(core::mem::align_of::<WeakRefList>() >= core::mem::align_of::<PyInner<()>>());

/// This is an actual python object. It consists of a `typ` which is the
/// python class, and carries some rust payload optionally. This rust
Expand Down Expand Up @@ -375,8 +374,7 @@ impl<T> PyInner<T> {
#[inline(always)]
pub(super) fn ext_ref(&self) -> Option<&ObjExt> {
let (flags, member_count) = self.read_type_flags();
let has_ext =
flags.has_feature(crate::types::PyTypeFlags::HAS_DICT) || member_count > 0;
let has_ext = flags.has_feature(crate::types::PyTypeFlags::HAS_DICT) || member_count > 0;
if !has_ext {
return None;
}
Expand All @@ -387,8 +385,7 @@ impl<T> PyInner<T> {
EXT_OFFSET
};
let self_addr = (self as *const Self as *const u8).addr();
let ext_ptr =
core::ptr::with_exposed_provenance::<ObjExt>(self_addr.wrapping_sub(offset));
let ext_ptr = core::ptr::with_exposed_provenance::<ObjExt>(self_addr.wrapping_sub(offset));
Some(unsafe { &*ext_ptr })
}

Expand Down Expand Up @@ -957,8 +954,8 @@ impl<T: PyPayload> PyInner<T> {
unsafe fn dealloc(ptr: *mut Self) {
unsafe {
let (flags, member_count) = (*ptr).read_type_flags();
let has_ext = flags.has_feature(crate::types::PyTypeFlags::HAS_DICT)
|| member_count > 0;
let has_ext =
flags.has_feature(crate::types::PyTypeFlags::HAS_DICT) || member_count > 0;
let has_weakref = flags.has_feature(crate::types::PyTypeFlags::HAS_WEAKREF);

if has_ext || has_weakref {
Expand All @@ -977,9 +974,8 @@ impl<T: PyPayload> PyInner<T> {
.unwrap()
.0;
}
let (combined, inner_offset) = layout
.extend(core::alloc::Layout::new::<Self>())
.unwrap();
let (combined, inner_offset) =
layout.extend(core::alloc::Layout::new::<Self>()).unwrap();
let combined = combined.pad_to_align();

let alloc_ptr = (ptr as *mut u8).sub(inner_offset);
Expand Down Expand Up @@ -1045,9 +1041,8 @@ impl<T: PyPayload + core::fmt::Debug> PyInner<T> {
None
};

let (combined, inner_offset) = layout
.extend(core::alloc::Layout::new::<Self>())
.unwrap();
let (combined, inner_offset) =
layout.extend(core::alloc::Layout::new::<Self>()).unwrap();
let combined = combined.pad_to_align();

let alloc_ptr = unsafe { alloc::alloc::alloc(combined) };
Expand Down Expand Up @@ -1757,8 +1752,7 @@ impl PyObject {
// the pointer without clearing dict contents. The dict may still be
// referenced by other live objects (e.g. function.__globals__).
let (flags, member_count) = obj.0.read_type_flags();
let has_ext = flags.has_feature(crate::types::PyTypeFlags::HAS_DICT)
|| member_count > 0;
let has_ext = flags.has_feature(crate::types::PyTypeFlags::HAS_DICT) || member_count > 0;
if has_ext {
let has_weakref = flags.has_feature(crate::types::PyTypeFlags::HAS_WEAKREF);
let offset = if has_weakref {
Expand All @@ -1767,9 +1761,8 @@ impl PyObject {
EXT_OFFSET
};
let self_addr = (ptr as *const u8).addr();
let ext_ptr = core::ptr::with_exposed_provenance_mut::<ObjExt>(
self_addr.wrapping_sub(offset),
);
let ext_ptr =
core::ptr::with_exposed_provenance_mut::<ObjExt>(self_addr.wrapping_sub(offset));
let ext = unsafe { &mut *ext_ptr };
if let Some(old_dict) = ext.dict.take() {
// Get the dict ref before dropping InstanceDict
Expand Down
Loading
X Tutup