Skip to content

Commit 92139da

Browse files
committed
Clippy lints
1 parent aa12acc commit 92139da

File tree

8 files changed

+20
-21
lines changed

8 files changed

+20
-21
lines changed

crates/vm/src/builtins/type.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2103,9 +2103,8 @@ impl Constructor for PyType {
21032103
.map_err(|e| vm.new_type_error(e))?;
21042104

21052105
if let Some(ref slots) = heaptype_slots {
2106-
let mut offset = base_member_count;
21072106
let class_name = typ.name().to_string();
2108-
for member in slots.as_slice() {
2107+
for (offset, member) in (base_member_count..).zip(slots.as_slice().iter()) {
21092108
// Apply name mangling for private attributes (__x -> _ClassName__x)
21102109
let member_str = member
21112110
.to_str()
@@ -2131,7 +2130,6 @@ impl Constructor for PyType {
21312130
// __slots__ attributes always get a member descriptor
21322131
// (this overrides any inherited attribute from MRO)
21332132
typ.set_attr(attr_name, member_descriptor.into());
2134-
offset += 1;
21352133
}
21362134
}
21372135

crates/vm/src/builtins/union.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ impl Hashable for PyUnion {
517517
Err(e) => return Err(e),
518518
}
519519
}
520-
let set = PyFrozenSet::from_iter(vm, args_to_hash.into_iter())?;
520+
let set = PyFrozenSet::from_iter(vm, args_to_hash)?;
521521
PyFrozenSet::hash(&set.into_ref(&vm.ctx), vm)
522522
}
523523
}

crates/vm/src/codecs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,7 @@ impl<'a> DecodeErrorHandler<PyDecodeContext<'a>> for SurrogatePass {
532532
.ok_or_else(|| ctx.error_decoding(byte_range.clone(), reason))?;
533533

534534
let s = ctx.full_data();
535-
debug_assert!(byte_range.start <= 0.max(s.len() - 1));
535+
debug_assert!(byte_range.start <= s.len().saturating_sub(1));
536536
debug_assert!(byte_range.end >= 1.min(s.len()));
537537
debug_assert!(byte_range.end <= s.len());
538538

crates/vm/src/stdlib/_abc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ mod _abc {
191191
}
192192

193193
// Set __abstractmethods__
194-
let abstracts_set = PyFrozenSet::from_iter(vm, abstracts.into_iter())?;
194+
let abstracts_set = PyFrozenSet::from_iter(vm, abstracts)?;
195195
cls.set_attr("__abstractmethods__", abstracts_set.into_pyobject(vm), vm)?;
196196

197197
Ok(())

crates/vm/src/stdlib/_ctypes/simple.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -301,16 +301,17 @@ impl PyCSimpleType {
301301
// 4. Try to convert value based on type code
302302
match type_code.as_deref() {
303303
// Integer types: accept integers
304-
Some(tc @ ("b" | "B" | "h" | "H" | "i" | "I" | "l" | "L" | "q" | "Q")) => {
305-
if value.try_int(vm).is_ok() {
306-
return create_simple_with_value(tc, &value);
307-
}
304+
Some(tc @ ("b" | "B" | "h" | "H" | "i" | "I" | "l" | "L" | "q" | "Q"))
305+
if value.try_int(vm).is_ok() =>
306+
{
307+
return create_simple_with_value(tc, &value);
308308
}
309+
309310
// Float types: accept numbers
310-
Some(tc @ ("f" | "d" | "g")) => {
311-
if value.try_float(vm).is_ok() || value.try_int(vm).is_ok() {
312-
return create_simple_with_value(tc, &value);
313-
}
311+
Some(tc @ ("f" | "d" | "g"))
312+
if (value.try_float(vm).is_ok() || value.try_int(vm).is_ok()) =>
313+
{
314+
return create_simple_with_value(tc, &value);
314315
}
315316
// c_char: 1 byte character
316317
Some("c") => {

crates/vm/src/stdlib/_winapi.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ mod _winapi {
417417
// Deduplicate case-insensitive keys, keeping the last value
418418
use std::collections::HashMap;
419419
let mut last_entry: HashMap<String, widestring::WideString> = HashMap::new();
420-
for (k, v) in keys.into_iter().zip(values.into_iter()) {
420+
for (k, v) in keys.into_iter().zip(values) {
421421
let k = PyStrRef::try_from_object(vm, k)?;
422422
let k = k.expect_str();
423423
let v = PyStrRef::try_from_object(vm, v)?;

crates/vm/src/stdlib/time.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1441,6 +1441,8 @@ mod platform {
14411441
let zone = widestring::decode_utf16_lossy(name.iter().copied())
14421442
.take_while(|&c| c != '\0')
14431443
.collect::<String>();
1444+
1445+
#[allow(clippy::unnecessary_cast, reason = "info.Bias is not always i32")]
14441446
let gmtoff = -((info.Bias + bias) as i32) * 60;
14451447

14461448
Ok(struct_time_from_tm(vm, tm, &zone, gmtoff))

crates/vm/src/types/slot.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1394,12 +1394,10 @@ impl PyType {
13941394
SlotAccessor::SqLength => {
13951395
update_sub_slot!(as_sequence, length, sequence_len_wrapper, SeqLength)
13961396
}
1397-
SlotAccessor::SqConcat | SlotAccessor::SqInplaceConcat => {
1398-
// Sequence concat uses sq_concat slot - no generic wrapper needed
1399-
// (handled by number protocol fallback)
1400-
if !ADD {
1401-
accessor.inherit_from_mro(self);
1402-
}
1397+
// Sequence concat uses sq_concat slot - no generic wrapper needed
1398+
// (handled by number protocol fallback)
1399+
SlotAccessor::SqConcat | SlotAccessor::SqInplaceConcat if !ADD => {
1400+
accessor.inherit_from_mro(self);
14031401
}
14041402
SlotAccessor::SqRepeat => {
14051403
update_sub_slot!(as_sequence, repeat, sequence_repeat_wrapper, SeqRepeat)

0 commit comments

Comments
 (0)