You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to test a spinlock that uses parking_lot's lock_api with Loom.
To implement lock_api's RawRwLock I need to supply a const initial value, as specified on this line. This works with the standard library's std::sync::atomic::AtomicUsizeconst fn new, but not with Loom's atomic_int! macro which generates a non-const fn new.
I get the following error when running RUSTFLAGS="--cfg loom" cargo test, where rin is one of the fields of the struct I initialize. It does not throw an error with regular cargo test (using std::sync::atomic).
error[E0015]: calls in constants are limited to constant functions, tuple structs and tuple variants
--> src/lib.rs:50:14
|
50 | rin: AtomicUsize::new(0),
| ^^^^^^^^^^^^^^^^^^^
Is it possible to make loom::sync::atomic::AtomicUsize::newconst, or can you recommend another workaround?
The text was updated successfully, but these errors were encountered:
I'm trying to test a spinlock that uses parking_lot's
lock_api
with Loom.To implement
lock_api
'sRawRwLock
I need to supply aconst
initial value, as specified on this line. This works with the standard library'sstd::sync::atomic::AtomicUsize
const fn new
, but not with Loom'satomic_int!
macro which generates a non-constfn new
.I get the following error when running
RUSTFLAGS="--cfg loom" cargo test
, whererin
is one of the fields of the struct I initialize. It does not throw an error with regularcargo test
(usingstd::sync::atomic
).Is it possible to make
loom::sync::atomic::AtomicUsize::new
const
, or can you recommend another workaround?The text was updated successfully, but these errors were encountered: