Skip to content

Commit 191187a

Browse files
authored
ci: lint fixes for rust 1.91 (#1869)
1 parent 4d4975a commit 191187a

File tree

6 files changed

+10
-15
lines changed

6 files changed

+10
-15
lines changed

src/errors/location.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ impl From<String> for LocItem {
4141

4242
impl From<&String> for LocItem {
4343
fn from(s: &String) -> Self {
44-
s.to_string().into()
44+
s.clone().into()
4545
}
4646
}
4747

@@ -87,22 +87,17 @@ impl Serialize for LocItem {
8787
/// Note: location in List is stored in **REVERSE** so adding an "outer" item to location involves
8888
/// pushing to the vec which is faster than inserting and shifting everything along.
8989
/// Then when "using" location in `Display` and `ToPyObject` order has to be reversed
90-
#[derive(Clone)]
90+
#[derive(Clone, Default)]
9191
#[cfg_attr(debug_assertions, derive(Debug))]
9292
pub enum Location {
9393
// no location, avoid creating an unnecessary vec
94+
#[default]
9495
Empty,
9596
// store the in a vec of LocItems, Note: this is the REVERSE of location, see above
9697
// we could perhaps use a smallvec or similar here, probably only worth it if we store a Cow in LocItem
9798
List(Vec<LocItem>),
9899
}
99100

100-
impl Default for Location {
101-
fn default() -> Self {
102-
Self::Empty
103-
}
104-
}
105-
106101
static EMPTY_TUPLE: PyOnceLock<Py<PyTuple>> = PyOnceLock::new();
107102

108103
impl<'py> IntoPyObject<'py> for &'_ Location {

src/serializers/config.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,23 +191,23 @@ impl TemporalMode {
191191

192192
pub fn datetime_json_key<'py>(self, datetime: &Bound<'_, PyDateTime>) -> PyResult<Cow<'py, str>> {
193193
match self {
194-
Self::Iso8601 => Ok(datetime_to_string(datetime)?.to_string().into()),
194+
Self::Iso8601 => Ok(datetime_to_string(datetime)?.into()),
195195
Self::Seconds => Ok(datetime_to_seconds(datetime)?.to_string().into()),
196196
Self::Milliseconds => Ok(datetime_to_milliseconds(datetime)?.to_string().into()),
197197
}
198198
}
199199

200200
pub fn date_json_key<'py>(self, date: &Bound<'_, PyDate>) -> PyResult<Cow<'py, str>> {
201201
match self {
202-
Self::Iso8601 => Ok(date_to_string(date)?.to_string().into()),
202+
Self::Iso8601 => Ok(date_to_string(date)?.into()),
203203
Self::Seconds => Ok(date_to_seconds(date)?.to_string().into()),
204204
Self::Milliseconds => Ok(date_to_milliseconds(date)?.to_string().into()),
205205
}
206206
}
207207

208208
pub fn time_json_key<'py>(self, time: &Bound<'_, PyTime>) -> PyResult<Cow<'py, str>> {
209209
match self {
210-
Self::Iso8601 => Ok(time_to_string(time)?.to_string().into()),
210+
Self::Iso8601 => Ok(time_to_string(time)?.into()),
211211
Self::Seconds => Ok(time_to_seconds(time)?.to_string().into()),
212212
Self::Milliseconds => Ok(time_to_milliseconds(time)?.to_string().into()),
213213
}

src/serializers/extra.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,7 @@ impl CollectWarnings {
514514
return Ok(());
515515
}
516516

517-
let formatted_warnings: Vec<String> = self.warnings.iter().map(|w| w.__repr__(py).to_string()).collect();
517+
let formatted_warnings: Vec<String> = self.warnings.iter().map(|w| w.__repr__(py)).collect();
518518

519519
let message = format!("Pydantic serializer warnings:\n {}", formatted_warnings.join("\n "));
520520
if self.mode == WarningsMode::Warn {

src/serializers/infer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,7 @@ pub(crate) fn infer_json_key_known<'a, 'py>(
552552
}
553553
ObType::MultiHostUrl => {
554554
let py_url: PyMultiHostUrl = key.extract()?;
555-
Ok(Cow::Owned(py_url.__str__(key.py()).to_string()))
555+
Ok(Cow::Owned(py_url.__str__(key.py())))
556556
}
557557
ObType::Tuple => {
558558
let mut key_build = super::type_serializers::tuple::KeyBuilder::new();

src/validators/dataclass.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ impl Validator for DataclassArgsValidator {
403403
return Err(ValError::new_with_loc(
404404
ErrorTypeDefaults::FrozenField,
405405
field_value,
406-
field.name.to_string(),
406+
&field.name,
407407
));
408408
}
409409
// by using dict but removing the field in question, we match V1 behaviour

src/validators/model_fields.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ impl Validator for ModelFieldsValidator {
433433
return Err(ValError::new_with_loc(
434434
ErrorTypeDefaults::FrozenField,
435435
field_value,
436-
field.name.to_string(),
436+
&field.name,
437437
));
438438
}
439439

0 commit comments

Comments
 (0)