Skip to content

Commit 1d6b32c

Browse files
committed
Fix clippy/wasm errors
1 parent d2a302c commit 1d6b32c

File tree

4 files changed

+18
-5
lines changed

4 files changed

+18
-5
lines changed

common/src/lock/cell_lock.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,8 @@ fn deadlock(lockkind: &str, ty: &str) -> ! {
200200
}
201201

202202
pub struct SingleThreadId(());
203-
impl GetThreadId for SingleThreadId {
204-
pub const INIT: Self = SingleThreadId(());
203+
unsafe impl GetThreadId for SingleThreadId {
204+
const INIT: Self = SingleThreadId(());
205205
fn nonzero_thread_id(&self) -> NonZeroUsize {
206206
NonZeroUsize::new(1).unwrap()
207207
}

common/src/lock/thread_mutex.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ pub struct RawThreadMutex<R: RawMutex, G: GetThreadId> {
1717
}
1818

1919
impl<R: RawMutex, G: GetThreadId> RawThreadMutex<R, G> {
20+
#[allow(clippy::declare_interior_mutable_const)]
2021
pub const INIT: Self = RawThreadMutex {
2122
owner: AtomicUsize::new(0),
2223
mutex: R::INIT,
@@ -53,6 +54,12 @@ impl<R: RawMutex, G: GetThreadId> RawThreadMutex<R, G> {
5354
self.lock_internal(|| self.mutex.try_lock())
5455
}
5556

57+
/// Unlocks this mutex. The inner mutex may not be unlocked if
58+
/// this mutex was acquired previously in the current thread.
59+
///
60+
/// # Safety
61+
///
62+
/// This method may only be called if the mutex is held by the current thread.
5663
pub unsafe fn unlock(&self) {
5764
self.owner.store(0, Ordering::Relaxed);
5865
self.mutex.unlock();

vm/src/builtins/pytype.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ impl PyValue for PyType {
6060
}
6161

6262
impl PyType {
63-
pub fn tp_name<'s>(&'s self) -> PyMappedRwLockReadGuard<'s, str> {
63+
pub fn tp_name(&self) -> PyMappedRwLockReadGuard<str> {
6464
let opt_name = self.slots.name.upgradable_read();
6565
let read_guard = if opt_name.is_some() {
6666
PyRwLockUpgradableReadGuard::downgrade(opt_name)

vm/src/stdlib/io.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
/*
22
* I/O core tools.
33
*/
4-
use super::os::Offset;
4+
cfg_if::cfg_if! {
5+
if #[cfg(any(not(target_arch = "wasm32"), target_os = "wasi"))] {
6+
use super::os::Offset;
7+
} else {
8+
type Offset = i64;
9+
}
10+
}
511
use crate::pyobject::PyObjectRef;
612
use crate::VirtualMachine;
713
pub(crate) use _io::io_open as open;
@@ -2788,7 +2794,7 @@ mod fileio {
27882794
flags |= libc::O_CLOEXEC
27892795
}
27902796

2791-
Ok((mode, flags))
2797+
Ok((mode, flags as _))
27922798
}
27932799

27942800
#[pyattr]

0 commit comments

Comments
 (0)