10000 fix: add missing `cfg(not(gc))` · RustPython/RustPython@7b57c2b · GitHub
[go: up one dir, main page]

Skip to content

Commit 7b57c2b

Browse files
committed
fix: add missing cfg(not(gc))
1 parent ef8d3b1 commit 7b57c2b

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

vm/src/builtins/iter.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,14 @@ use super::{PyInt, PyTupleRef, PyType};
66
use crate::{
77
class::PyClassImpl,
88
function::ArgCallable,
9-
object::gc::GcTrace,
9+
1010
protocol::{PyIterReturn, PySequence, PySequenceMethods},
1111
types::{IterNext, IterNextIterable},
1212
Context, Py, PyObject, PyObjectRef, PyPayload, PyResult, VirtualMachine,
1313
};
14+
15+
#[cfg(feature = "gc")]
16+
use crate::object::gc::GcTrace;
1417
use rustpython_common::{
1518
lock::{PyMutex, PyRwLock, PyRwLockUpgradableReadGuard},
1619
static_cell,

vm/src/object/core.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ impl PyObjVTable {
110110
/// payload can be a rust float or rust int in case of float and int objects.
111111
#[repr(C)]
112112
struct PyInner<T> {
113+
#[cfg(not(feature = "gc"))]
113114
ref_count: RefCount,
114115
#[cfg(feature = "gc")]
115116
header: GcHeader,
@@ -642,6 +643,7 @@ impl<T: PyObjectPayload> PyInner<T> {
642643
fn new(payload: T, typ: PyTypeRef, dict: Option<PyDictRef>) -> Box<Self> {
643644
let member_count = typ.slots.member_count;
644645
Box::new(PyInner {
646+
#[cfg(not(feature = "gc"))]
645647
ref_count: RefCount::new(),
646648
#[cfg(feature = "gc")]
647649
header: GcHeader::new(),
@@ -1315,6 +1317,7 @@ impl<T: PyObjectPayload> PyRef<T> {
13151317

13161318
pub fn leak(pyref: Self) -> &'static Py<T> {
13171319
// FIXME(discord9): make sure leak this rc is ok
1320+
#[cfg(feature = "gc")]
13181321
pyref.header().leak();
13191322
let ptr = pyref.ptr;
13201323
std::mem::forget(pyref);
@@ -1478,6 +1481,7 @@ pub(crate) fn init_type_hierarchy() -> (PyTypeRef, PyTypeRef, PyTypeRef) {
14781481
};
14791482
let type_type_ptr = Box::into_raw(Box::new(partially_init!(
14801483
PyInner::<PyType> {
1484+
#[cfg(not(feature = "gc"))]
14811485
ref_count: RefCount::new(),
14821486
#[cfg(feature = "gc")]
14831487
header: GcHeader::new(),
@@ -1492,6 +1496,7 @@ pub(crate) fn init_type_hierarchy() -> (PyTypeRef, PyTypeRef, PyTypeRef) {
14921496
)));
14931497
let object_type_ptr = Box::into_raw(Box::new(partially_init!(
14941498
PyInner::<PyType> {
1499+
#[cfg(not(feature = "gc"))]
14951500
ref_count: RefCount::new(),
14961501
#[cfg(feature = "gc")]
14971502
header: GcHeader::new(),

vm/src/object/gc/header.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use std::sync::atomic::Ordering;
33
use crate::object::gc::{CcSync, GLOBAL_COLLECTOR, IS_GC_THREAD};
44
use rustpython_common::{atomic::PyAtomic, lock::PyMutex, rc::PyRc};
55

6+
#[repr(C)]
67
pub struct GcHeader {
78
ref_cnt: PyAtomic<usize>,
89
color: PyMutex<Color>,

0 commit comments

Comments
 (0)
0