Skip to content

Commit 9d3a702

Browse files
committed
build, clippy misc
1 parent 278e6b9 commit 9d3a702

File tree

14 files changed

+90
-94
lines changed

14 files changed

+90
-94
lines changed

.github/workflows/artifact.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ env:
77
FORCE_COLOR: "1"
88
ORJSON_BUILD_FREETHREADED: "1"
99
PIP_DISABLE_PIP_VERSION_CHECK: "1"
10-
RUST_TOOLCHAIN: "nightly-2025-12-01"
10+
RUST_TOOLCHAIN: "nightly-2026-01-15"
1111
RUST_TOOLCHAIN_STABLE: "1.89"
1212
UNSAFE_PYO3_BUILD_FREE_THREADED: "1"
1313
UNSAFE_PYO3_SKIP_VERSION_CHECK: "1"
@@ -287,7 +287,7 @@ jobs:
287287
- name: Test
288288
uses: addnab/docker-run-action@v3
289289
with:
290-
image: "quay.io/pypa/musllinux_1_2_${{ matrix.platform.arch }}:2025.07.25-1"
290+
image: "quay.io/pypa/musllinux_1_2_${{ matrix.platform.arch }}:2026.01.16-1"
291291
options: -v ${{ github.workspace }}:/io -w /io
292292
run: |
293293
apk add tzdata
@@ -362,7 +362,7 @@ jobs:
362362
- name: Test
363363
uses: addnab/docker-run-action@v3
364364
with:
365-
image: "quay.io/pypa/musllinux_1_2_${{ matrix.platform.arch }}:2025.07.25-1"
365+
image: "quay.io/pypa/musllinux_1_2_${{ matrix.platform.arch }}:2026.01.16-1"
366366
options: -v ${{ github.workspace }}:/io -w /io
367367
run: |
368368
apk add tzdata

Cargo.lock

Lines changed: 37 additions & 31 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1076,7 +1076,7 @@ The recommended build command is:
10761076
maturin build --release --strip
10771077
```
10781078

1079-
The project's own CI tests against `nightly-2025-12-01` and stable 1.89. It
1079+
The project's own CI tests against `nightly-2026-01-15` and stable 1.89. It
10801080
is prudent to pin the nightly version because that channel can introduce
10811081
breaking changes. There is a significant performance benefit to using
10821082
nightly.

src/deserialize/backend/yyjson.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,9 @@ pub(crate) fn deserialize(
105105
if doc.is_null() {
106106
ffi!(PyMem_Free(buffer_ptr));
107107
let msg: Cow<str> = unsafe { core::ffi::CStr::from_ptr(err.msg).to_string_lossy() };
108-
return Err(DeserializeError::from_yyjson(msg, err.pos as i64, data));
108+
#[allow(clippy::cast_possible_wrap)]
109+
let pos = err.pos as i64;
110+
return Err(DeserializeError::from_yyjson(msg, pos, data));
109111
}
110112
let val = yyjson_doc_get_root(doc);
111113
let pyval = {

src/deserialize/deserializer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ impl Deserializer {
3030
return Ok(nonnull!(ffi!(PyList_New(0))));
3131
}
3232
b"{}" => {
33-
return Ok(nonnull!(ffi!(PyDict_New())));
33+
return Ok(nonnull!(unsafe { crate::ffi::PyDict_New(0) }));
3434
}
3535
b"\"\"" => {
3636
return Ok(PyStrRef::empty().as_non_null_ptr());

src/deserialize/error.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// SPDX-License-Identifier: (Apache-2.0 OR MIT)
2-
// Copyright ijl (2022-2025), Eric Jolibois (2021)
2+
// Copyright ijl (2022-2026), Eric Jolibois (2021)
33

44
use std::borrow::Cow;
55

@@ -33,7 +33,13 @@ impl<'a> DeserializeError<'a> {
3333
#[cfg_attr(feature = "optimize", optimize(size))]
3434
pub fn pos(&self) -> i64 {
3535
match self.data {
36-
Some(as_str) => as_str[0..self.pos as usize].chars().count() as i64,
36+
Some(as_str) => {
37+
#[allow(clippy::cast_sign_loss)]
38+
let pos = self.pos as usize;
39+
#[allow(clippy::cast_possible_wrap)]
40+
let res = as_str[0..pos].chars().count() as i64; // stmt_expr_attributes
41+
res
42+
}
3743
None => 0,
3844
}
3945
}

src/ffi/buffer.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
use crate::ffi::{Py_buffer, Py_hash_t, Py_ssize_t, PyObject, PyVarObject};
55
use core::ffi::c_int;
66

7-
#[cfg(CPython)]
87
#[repr(C)]
98
pub(crate) struct _PyManagedBufferObject {
109
pub ob_base: *mut PyObject,
@@ -13,7 +12,6 @@ pub(crate) struct _PyManagedBufferObject {
1312
pub master: *mut Py_buffer,
1413
}
1514

16-
#[cfg(CPython)]
1715
#[repr(C)]
1816
pub(crate) struct PyMemoryViewObject {
1917
pub ob_base: PyVarObject,
@@ -26,7 +24,6 @@ pub(crate) struct PyMemoryViewObject {
2624
pub ob_array: [Py_ssize_t; 1],
2725
}
2826

29-
#[cfg(CPython)]
3027
#[allow(non_snake_case)]
3128
#[inline(always)]
3229
pub(crate) unsafe fn PyMemoryView_GET_BUFFER(op: *mut PyObject) -> *const Py_buffer {

src/ffi/bytes.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// SPDX-License-Identifier: MPL-2.0
2-
// Copyright ijl (2022-2025)
2+
// Copyright ijl (2022-2026)
33

44
use crate::ffi::{Py_ssize_t, PyObject};
55
use core::ffi::c_char;
@@ -23,5 +23,5 @@ pub(crate) unsafe fn PyBytes_AS_STRING(op: *mut PyObject) -> *const c_char {
2323
#[allow(non_snake_case)]
2424
#[inline(always)]
2525
pub(crate) unsafe fn PyBytes_GET_SIZE(op: *mut PyObject) -> Py_ssize_t {
26-
unsafe { super::compat::Py_SIZE(op.cast::<crate::ffi::PyVarObject>()) }
26+
unsafe { super::compat::Py_SIZE(op) }
2727
}

src/ffi/compat.rs

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,10 @@ pub(crate) unsafe fn _Py_IsImmortal(op: *mut pyo3_ffi::PyObject) -> core::ffi::c
5656
#[cfg(CPython)]
5757
#[inline(always)]
5858
#[allow(non_snake_case)]
59-
pub(crate) unsafe fn _PyDict_NewPresized(len: isize) -> *mut pyo3_ffi::PyObject {
59+
pub(crate) unsafe fn PyDict_New(len: isize) -> *mut pyo3_ffi::PyObject {
6060
unsafe {
6161
if len > 8 {
62-
pyo3_ffi::_PyDict_NewPresized(len)
62+
_PyDict_NewPresized(len)
6363
} else {
6464
pyo3_ffi::PyDict_New()
6565
}
@@ -69,7 +69,7 @@ pub(crate) unsafe fn _PyDict_NewPresized(len: isize) -> *mut pyo3_ffi::PyObject
6969
#[cfg(not(CPython))]
7070
#[inline(always)]
7171
#[allow(non_snake_case)]
72-
pub(crate) unsafe fn _PyDict_NewPresized(_len: isize) -> *mut pyo3_ffi::PyObject {
72+
pub(crate) unsafe fn PyDict_New(_len: isize) -> *mut pyo3_ffi::PyObject {
7373
unsafe { pyo3_ffi::PyDict_New() }
7474
}
7575

@@ -122,15 +122,15 @@ pub(crate) unsafe fn PyLong_AsByteArray(
122122
#[cfg(CPython)]
123123
#[inline(always)]
124124
#[allow(non_snake_case)]
125-
pub(crate) unsafe fn Py_SIZE(op: *mut pyo3_ffi::PyVarObject) -> pyo3_ffi::Py_ssize_t {
126-
unsafe { (*op).ob_size }
125+
pub(crate) unsafe fn Py_SIZE(op: *mut pyo3_ffi::PyObject) -> pyo3_ffi::Py_ssize_t {
126+
unsafe { (*op.cast::<pyo3_ffi::PyVarObject>()).ob_size }
127127
}
128128

129129
#[cfg(not(CPython))]
130130
#[inline(always)]
131131
#[allow(non_snake_case)]
132-
pub(crate) unsafe fn Py_SIZE(op: *mut pyo3_ffi::PyVarObject) -> pyo3_ffi::Py_ssize_t {
133-
unsafe { pyo3_ffi::Py_SIZE(op.cast::<pyo3_ffi::PyObject>()) }
132+
pub(crate) unsafe fn Py_SIZE(op: *mut pyo3_ffi::PyObject) -> pyo3_ffi::Py_ssize_t {
133+
unsafe { pyo3_ffi::Py_SIZE(op) }
134134
}
135135

136136
#[allow(unused)]
@@ -204,6 +204,13 @@ pub(crate) unsafe fn PyTuple_SET_ITEM(
204204
}
205205

206206
unsafe extern "C" {
207+
208+
#[cfg(CPython)]
209+
pub fn _PyBytes_Resize(
210+
pv: *mut *mut pyo3_ffi::PyObject,
211+
newsize: pyo3_ffi::Py_ssize_t,
212+
) -> core::ffi::c_int;
213+
207214
#[cfg(CPython)]
208215
pub fn _PyDict_Next(
209216
mp: *mut pyo3_ffi::PyObject,
@@ -213,6 +220,9 @@ unsafe extern "C" {
213220
hash: *mut pyo3_ffi::Py_hash_t,
214221
) -> core::ffi::c_int;
215222

223+
#[cfg(CPython)]
224+
pub fn _PyDict_NewPresized(minused: pyo3_ffi::Py_ssize_t) -> *mut pyo3_ffi::PyObject;
225+
216226
#[cfg(CPython)]
217227
pub fn _PyDict_Contains_KnownHash(
218228
op: *mut pyo3_ffi::PyObject,

0 commit comments

Comments
 (0)