Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: updates for Rust 1.83 #176

Merged
merged 1 commit into from
Dec 2, 2024
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
30 changes: 15 additions & 15 deletions crates/jiter/src/python.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ struct PythonParser<'j, StringCache, KeyCheck, ParseNumber> {
partial_mode: PartialMode,
}

impl<'j, StringCache: StringMaybeCache, KeyCheck: MaybeKeyCheck, ParseNumber: MaybeParseNumber>
PythonParser<'j, StringCache, KeyCheck, ParseNumber>
impl<StringCache: StringMaybeCache, KeyCheck: MaybeKeyCheck, ParseNumber: MaybeParseNumber>
PythonParser<'_, StringCache, KeyCheck, ParseNumber>
{
fn parse<'py>(
py: Python<'py>,
Expand Down Expand Up @@ -143,13 +143,13 @@ impl<'j, StringCache: StringMaybeCache, KeyCheck: MaybeKeyCheck, ParseNumber: Ma
Peek::Array => {
let peek_first = match self.parser.array_first() {
Ok(Some(peek)) => peek,
Err(e) if !self._allow_partial_err(&e) => return Err(e),
Err(e) if !self.allow_partial_err(&e) => return Err(e),
Ok(None) | Err(_) => return Ok(PyList::empty(py).into_any()),
};

let mut vec: SmallVec<[Bound<'_, PyAny>; 8]> = SmallVec::with_capacity(8);
if let Err(e) = self._parse_array(py, peek_first, &mut vec) {
if !self._allow_partial_err(&e) {
if let Err(e) = self.parse_array(py, peek_first, &mut vec) {
if !self.allow_partial_err(&e) {
return Err(e);
}
}
Expand All @@ -160,8 +160,8 @@ impl<'j, StringCache: StringMaybeCache, KeyCheck: MaybeKeyCheck, ParseNumber: Ma
}
Peek::Object => {
let dict = PyDict::new(py);
if let Err(e) = self._parse_object(py, &dict) {
if !self._allow_partial_err(&e) {
if let Err(e) = self.parse_object(py, &dict) {
if !self.allow_partial_err(&e) {
return Err(e);
}
}
Expand All @@ -171,22 +171,22 @@ impl<'j, StringCache: StringMaybeCache, KeyCheck: MaybeKeyCheck, ParseNumber: Ma
}
}

fn _parse_array<'py>(
fn parse_array<'py>(
&mut self,
py: Python<'py>,
peek_first: Peek,
vec: &mut SmallVec<[Bound<'py, PyAny>; 8]>,
) -> JsonResult<()> {
let v = self._check_take_value(py, peek_first)?;
let v = self.check_take_value(py, peek_first)?;
vec.push(v);
while let Some(peek) = self.parser.array_step()? {
let v = self._check_take_value(py, peek)?;
let v = self.check_take_value(py, peek)?;
vec.push(v);
}
Ok(())
}

fn _parse_object<'py>(&mut self, py: Python<'py>, dict: &Bound<'py, PyDict>) -> JsonResult<()> {
fn parse_object<'py>(&mut self, py: Python<'py>, dict: &Bound<'py, PyDict>) -> JsonResult<()> {
let set_item = |key: Bound<'py, PyString>, value: Bound<'py, PyAny>| {
let r = unsafe { ffi::PyDict_SetItem(dict.as_ptr(), key.as_ptr(), value.as_ptr()) };
// AFAIK this shouldn't happen since the key will always be a string which is hashable
Expand All @@ -200,29 +200,29 @@ impl<'j, StringCache: StringMaybeCache, KeyCheck: MaybeKeyCheck, ParseNumber: Ma
check_keys.check(first_key_s, self.parser.index)?;
let first_key = StringCache::get_key(py, first_key_s, first_key.ascii_only());
let peek = self.parser.peek()?;
let first_value = self._check_take_value(py, peek)?;
let first_value = self.check_take_value(py, peek)?;
set_item(first_key, first_value);
while let Some(key) = self.parser.object_step::<StringDecoder>(&mut self.tape)? {
let key_s = key.as_str();
check_keys.check(key_s, self.parser.index)?;
let key = StringCache::get_key(py, key_s, key.ascii_only());
let peek = self.parser.peek()?;
let value = self._check_take_value(py, peek)?;
let value = self.check_take_value(py, peek)?;
set_item(key, value);
}
}
Ok(())
}

fn _allow_partial_err(&self, e: &JsonError) -> bool {
fn allow_partial_err(&self, e: &JsonError) -> bool {
if self.partial_mode.is_active() {
e.allowed_if_partial()
} else {
false
}
}

fn _check_take_value<'py>(&mut self, py: Python<'py>, peek: Peek) -> JsonResult<Bound<'py, PyAny>> {
fn check_take_value<'py>(&mut self, py: Python<'py>, peek: Peek) -> JsonResult<Bound<'py, PyAny>> {
self.recursion_limit = match self.recursion_limit.checked_sub(1) {
Some(limit) => limit,
None => return json_err!(RecursionLimitExceeded, self.parser.index),
Expand Down
6 changes: 3 additions & 3 deletions crates/jiter/src/string_decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,16 @@ impl From<StringOutput<'_, '_>> for String {
}
}

impl<'t, 'j> From<StringOutput<'t, 'j>> for Cow<'j, str> {
fn from(val: StringOutput<'t, 'j>) -> Self {
impl<'j> From<StringOutput<'_, 'j>> for Cow<'j, str> {
fn from(val: StringOutput<'_, 'j>) -> Self {
match val {
StringOutput::Tape(s, _) => s.to_owned().into(),
StringOutput::Data(s, _) => s.into(),
}
}
}

impl<'t, 'j> StringOutput<'t, 'j> {
impl<'t> StringOutput<'t, '_> {
pub fn as_str(&self) -> &'t str {
match self {
Self::Tape(s, _) => s,
Expand Down
Loading