Skip to content
Merged
Show file tree
Hide file tree
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
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -225,9 +225,9 @@ unsafe_op_in_unsafe_fn = "deny"
elided_lifetimes_in_paths = "warn"

[workspace.lints.clippy]
# alloc_instead_of_core = "warn"
# std_instead_of_alloc = "warn"
# std_instead_of_core = "warn"
alloc_instead_of_core = "warn"
std_instead_of_alloc = "warn"
std_instead_of_core = "warn"
perf = "warn"
style = "warn"
complexity = "warn"
Expand Down
4 changes: 2 additions & 2 deletions crates/codegen/src/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8328,7 +8328,7 @@ impl Compiler {
}

// Add trailing string
all_strings.push(std::mem::take(&mut current_string));
all_strings.push(core::mem::take(&mut current_string));

// Now build the Template:
// Stack currently has all interpolations from compile_tstring_into calls
Expand Down Expand Up @@ -8372,7 +8372,7 @@ impl Compiler {
}
ast::InterpolatedStringElement::Interpolation(interp) => {
// Finish current string segment
strings.push(std::mem::take(current_string));
strings.push(core::mem::take(current_string));

// Compile the interpolation value
self.compile_expression(&interp.expression)?;
Expand Down
4 changes: 2 additions & 2 deletions crates/common/src/crt_fd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ type BorrowedInner<'fd> = BorrowedFd<'fd>;
#[cfg(windows)]
mod win {
use super::*;
use std::marker::PhantomData;
use std::mem::ManuallyDrop;
use core::marker::PhantomData;
use core::mem::ManuallyDrop;

#[repr(transparent)]
pub(super) struct OwnedInner(i32);
Expand Down
17 changes: 9 additions & 8 deletions crates/common/src/fileutils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ pub fn fstat(fd: crate::crt_fd::Borrowed<'_>) -> std::io::Result<StatStruct> {
pub mod windows {
use crate::crt_fd;
use crate::windows::ToWideString;
use alloc::ffi::CString;
use libc::{S_IFCHR, S_IFDIR, S_IFMT};
use std::ffi::{CString, OsStr, OsString};
use std::ffi::{OsStr, OsString};
use std::os::windows::io::AsRawHandle;
use std::sync::OnceLock;
use windows_sys::Win32::Foundation::{
Expand Down Expand Up @@ -119,17 +120,17 @@ pub mod windows {
});
}

let mut info = unsafe { std::mem::zeroed() };
let mut basic_info: FILE_BASIC_INFO = unsafe { std::mem::zeroed() };
let mut id_info: FILE_ID_INFO = unsafe { std::mem::zeroed() };
let mut info = unsafe { core::mem::zeroed() };
let mut basic_info: FILE_BASIC_INFO = unsafe { core::mem::zeroed() };
let mut id_info: FILE_ID_INFO = unsafe { core::mem::zeroed() };

if unsafe { GetFileInformationByHandle(h as _, &mut info) } == 0
|| unsafe {
GetFileInformationByHandleEx(
h as _,
FileBasicInfo,
&mut basic_info as *mut _ as *mut _,
std::mem::size_of_val(&basic_info) as u32,
core::mem::size_of_val(&basic_info) as u32,
)
} == 0
{
Expand All @@ -141,7 +142,7 @@ pub mod windows {
h as _,
FileIdInfo,
&mut id_info as *mut _ as *mut _,
std::mem::size_of_val(&id_info) as u32,
core::mem::size_of_val(&id_info) as u32,
)
} == 0
{
Expand Down Expand Up @@ -334,8 +335,8 @@ pub mod windows {
.ok_or_else(|| std::io::Error::from_raw_os_error(ERROR_NOT_SUPPORTED as _))?;

let file_name = file_name.to_wide_with_nul();
let file_info_buffer_size = std::mem::size_of::<FILE_STAT_BASIC_INFORMATION>() as u32;
let mut file_info_buffer = std::mem::MaybeUninit::<FILE_STAT_BASIC_INFORMATION>::uninit();
let file_info_buffer_size = core::mem::size_of::<FILE_STAT_BASIC_INFORMATION>() as u32;
let mut file_info_buffer = core::mem::MaybeUninit::<FILE_STAT_BASIC_INFORMATION>::uninit();
unsafe {
if GetFileInformationByName(
file_name.as_ptr(),
Expand Down
2 changes: 1 addition & 1 deletion crates/stdlib/src/_asyncio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ pub(crate) mod _asyncio {
warn,
},
};
use core::sync::atomic::{AtomicBool, AtomicI32, AtomicU64, Ordering};
use crossbeam_utils::atomic::AtomicCell;
use std::sync::atomic::{AtomicBool, AtomicI32, AtomicU64, Ordering};

pub(crate) fn module_exec(vm: &VirtualMachine, module: &Py<PyModule>) -> PyResult<()> {
__module_exec(vm, module);
Expand Down
26 changes: 13 additions & 13 deletions crates/stdlib/src/_sqlite3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ pub(crate) use _sqlite3::module_def;

#[pymodule]
mod _sqlite3 {
use core::{
ffi::{CStr, c_int, c_longlong, c_uint, c_void},
fmt::Debug,
ops::Deref,
ptr::{NonNull, null, null_mut},
};
use libsqlite3_sys::{
SQLITE_BLOB, SQLITE_DETERMINISTIC, SQLITE_FLOAT, SQLITE_INTEGER, SQLITE_NULL,
SQLITE_OPEN_CREATE, SQLITE_OPEN_READWRITE, SQLITE_OPEN_URI, SQLITE_TEXT, SQLITE_TRACE_STMT,
Expand Down Expand Up @@ -70,13 +76,7 @@ mod _sqlite3 {
},
utils::ToCString,
};
use std::{
ffi::{CStr, c_int, c_longlong, c_uint, c_void},
fmt::Debug,
ops::Deref,
ptr::{NonNull, null, null_mut},
thread::ThreadId,
};
use std::thread::ThreadId;

macro_rules! exceptions {
($(($x:ident, $base:expr)),*) => {
Expand Down Expand Up @@ -451,7 +451,7 @@ mod _sqlite3 {
) {
let context = SqliteContext::from(context);
let (func, vm) = unsafe { (*context.user_data::<Self>()).retrieve() };
let args = unsafe { std::slice::from_raw_parts(argv, argc as usize) };
let args = unsafe { core::slice::from_raw_parts(argv, argc as usize) };

let f = || -> PyResult<()> {
let db = context.db_handle();
Expand All @@ -478,7 +478,7 @@ mod _sqlite3 {
) {
let context = SqliteContext::from(context);
let (cls, vm) = unsafe { (*context.user_data::<Self>()).retrieve() };
let args = unsafe { std::slice::from_raw_parts(argv, argc as usize) };
let args = unsafe { core::slice::from_raw_parts(argv, argc as usize) };
let instance = context.aggregate_context::<*const PyObject>();
if unsafe { (*instance).is_null() } {
match cls.call((), vm) {
Expand Down Expand Up @@ -556,7 +556,7 @@ mod _sqlite3 {
) {
let context = SqliteContext::from(context);
let (_, vm) = unsafe { (*context.user_data::<Self>()).retrieve() };
let args = unsafe { std::slice::from_raw_parts(argv, argc as usize) };
let args = unsafe { core::slice::from_raw_parts(argv, argc as usize) };
let instance = context.aggregate_context::<*const PyObject>();
let instance = unsafe { &**instance };

Expand Down Expand Up @@ -882,7 +882,7 @@ mod _sqlite3 {
}

impl Debug for Connection {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> Result<(), core::fmt::Error> {
write!(f, "Sqlite3 Connection")
}
}
Expand Down Expand Up @@ -2077,7 +2077,7 @@ mod _sqlite3 {
} else {
let nbytes = st.column_bytes(i);
let blob = unsafe {
std::slice::from_raw_parts(blob.cast::<u8>(), nbytes as usize)
core::slice::from_raw_parts(blob.cast::<u8>(), nbytes as usize)
};
let blob = vm.ctx.new_bytes(blob.to_vec());
converter.call((blob,), vm)?
Expand Down Expand Up @@ -2684,7 +2684,7 @@ mod _sqlite3 {
}

impl Debug for Statement {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> Result<(), core::fmt::Error> {
write!(
f,
"{} Statement",
Expand Down
4 changes: 2 additions & 2 deletions crates/stdlib/src/math.rs
Original file line number Diff line number Diff line change
Expand Up @@ -732,9 +732,9 @@ mod math {

// Collect current + remaining elements
let p_remaining: Result<Vec<PyObjectRef>, _> =
std::iter::once(Ok(p_i)).chain(p_iter).collect();
core::iter::once(Ok(p_i)).chain(p_iter).collect();
let q_remaining: Result<Vec<PyObjectRef>, _> =
std::iter::once(Ok(q_i)).chain(q_iter).collect();
core::iter::once(Ok(q_i)).chain(q_iter).collect();
let (p_vec, q_vec) = (p_remaining?, q_remaining?);

if p_vec.len() != q_vec.len() {
Expand Down
10 changes: 5 additions & 5 deletions crates/stdlib/src/mmap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ mod mmap {
SetFilePointerEx(
duplicated_handle,
required_size,
std::ptr::null_mut(),
core::ptr::null_mut(),
FILE_BEGIN,
)
};
Expand Down Expand Up @@ -617,7 +617,7 @@ mod mmap {

// Keep the handle alive
let raw = owned_handle.as_raw_handle() as isize;
std::mem::forget(owned_handle);
core::mem::forget(owned_handle);
(raw, mmap)
} else {
// Anonymous mapping
Expand Down Expand Up @@ -1088,7 +1088,7 @@ mod mmap {
SetFilePointerEx(
handle as HANDLE,
required_size,
std::ptr::null_mut(),
core::ptr::null_mut(),
FILE_BEGIN,
)
};
Expand Down Expand Up @@ -1267,7 +1267,7 @@ mod mmap {
#[cfg(windows)]
#[pymethod]
fn __sizeof__(&self) -> usize {
std::mem::size_of::<Self>()
core::mem::size_of::<Self>()
}
}

Expand Down Expand Up @@ -1297,7 +1297,7 @@ mod mmap {
};

// Don't close the file handle - we're borrowing it
std::mem::forget(file);
core::mem::forget(file);

result
}
Expand Down
16 changes: 7 additions & 9 deletions crates/stdlib/src/multiprocessing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,10 @@ mod _multiprocessing {
function::{FuncArgs, KwArgs},
types::Constructor,
};
use alloc::ffi::CString;
use core::sync::atomic::{AtomicI32, AtomicU64, Ordering};
use libc::sem_t;
use nix::errno::Errno;
use std::{
ffi::CString,
sync::atomic::{AtomicI32, AtomicU64, Ordering},
};

/// Error type for sem_timedwait operations
#[cfg(target_vendor = "apple")]
Expand Down Expand Up @@ -92,7 +90,7 @@ mod _multiprocessing {
tv_sec: 0,
tv_usec: 0,
};
if unsafe { libc::gettimeofday(&mut now, std::ptr::null_mut()) } < 0 {
if unsafe { libc::gettimeofday(&mut now, core::ptr::null_mut()) } < 0 {
return Err(SemWaitError::OsError(Errno::last()));
}

Expand Down Expand Up @@ -125,9 +123,9 @@ mod _multiprocessing {
unsafe {
libc::select(
0,
std::ptr::null_mut(),
std::ptr::null_mut(),
std::ptr::null_mut(),
core::ptr::null_mut(),
core::ptr::null_mut(),
core::ptr::null_mut(),
&mut tv_delay,
)
};
Expand Down Expand Up @@ -302,7 +300,7 @@ mod _multiprocessing {
tv_sec: 0,
tv_usec: 0,
};
let res = unsafe { libc::gettimeofday(&mut tv, std::ptr::null_mut()) };
let res = unsafe { libc::gettimeofday(&mut tv, core::ptr::null_mut()) };
if res < 0 {
return Err(vm.new_os_error("gettimeofday failed".to_string()));
}
Expand Down
Loading
Loading