Skip to content

Commit 4bf32a0

Browse files
authored
Apply some clipy lints (#6045)
1 parent f402dee commit 4bf32a0

32 files changed

+198
-100
lines changed

common/src/boxvec.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ impl<T> BoxVec<T> {
165165
if index >= self.len() {
166166
None
167167
} else {
168-
self.drain(index..index + 1).next()
168+
self.drain(index..=index).next()
169169
}
170170
}
171171

common/src/format.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ impl FormatSpec {
389389

390390
fn insert_separator(mut magnitude_str: String, inter: i32, sep: char, sep_cnt: i32) -> String {
391391
let magnitude_len = magnitude_str.len() as i32;
392-
for i in 1..sep_cnt + 1 {
392+
for i in 1..=sep_cnt {
393393
magnitude_str.insert((magnitude_len - inter * i) as usize, sep);
394394
}
395395
magnitude_str
@@ -754,7 +754,7 @@ impl FormatSpec {
754754
let inter = self.get_separator_interval().try_into().unwrap();
755755
let len = magnitude_str.len() as i32;
756756
let separated_magnitude =
757-
FormatSpec::add_magnitude_separators_for_char(magnitude_str, inter, sep, len);
757+
Self::add_magnitude_separators_for_char(magnitude_str, inter, sep, len);
758758
Ok(separated_magnitude)
759759
}
760760
None => Ok(magnitude_str),

compiler/codegen/src/compile.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ impl Compiler {
360360
fblock: Vec::with_capacity(MAXBLOCKS),
361361
symbol_table_index: 0, // Module is always the first symbol table
362362
};
363-
Compiler {
363+
Self {
364364
code_stack: vec![module_code],
365365
symbol_table_stack: Vec::new(),
366366
source_file,
@@ -380,7 +380,7 @@ impl Compiler {
380380

381381
/// Check if the slice is a two-element slice (no step)
382382
// = is_two_element_slice
383-
fn is_two_element_slice(slice: &Expr) -> bool {
383+
const fn is_two_element_slice(slice: &Expr) -> bool {
384384
matches!(slice, Expr::Slice(s) if s.step.is_none())
385385
}
386386

@@ -882,7 +882,7 @@ impl Compiler {
882882
self._name_inner(name, |i| &mut i.metadata.names)
883883
}
884884
fn varname(&mut self, name: &str) -> CompileResult<bytecode::NameIdx> {
885-
if Compiler::is_forbidden_arg_name(name) {
885+
if Self::is_forbidden_arg_name(name) {
886886
return Err(self.error(CodegenErrorType::SyntaxError(format!(
887887
"cannot assign to {name}",
888888
))));
@@ -3435,7 +3435,7 @@ impl Compiler {
34353435

34363436
// Create a new tuple of attribute names.
34373437
let mut attr_names = vec![];
3438-
for name in kwd_attrs.iter() {
3438+
for name in &kwd_attrs {
34393439
// Py_NewRef(name) is emulated by cloning the name into a PyObject.
34403440
attr_names.push(ConstantData::Str {
34413441
value: name.as_str().to_string().into(),
@@ -3667,7 +3667,7 @@ impl Compiler {
36673667
pc.stores.insert(insert_pos + j, elem);
36683668
}
36693669
// Also perform the same rotation on the evaluation stack.
3670-
for _ in 0..(i_stores + 1) {
3670+
for _ in 0..=i_stores {
36713671
self.pattern_helper_rotate(i_control + 1)?;
36723672
}
36733673
}
@@ -4547,7 +4547,7 @@ impl Compiler {
45474547
}) => {
45484548
let prev_ctx = self.ctx;
45494549
let name = "<lambda>".to_owned();
4550-
let default_params = Default::default();
4550+
let default_params = Parameters::default();
45514551
let params = parameters.as_deref().unwrap_or(&default_params);
45524552

45534553
// Prepare defaults before entering function
@@ -4577,7 +4577,7 @@ impl Compiler {
45774577
let have_kwdefaults = !kw_with_defaults.is_empty();
45784578
if have_kwdefaults {
45794579
let default_kw_count = kw_with_defaults.len();
4580-
for (arg, default) in kw_with_defaults.iter() {
4580+
for (arg, default) in &kw_with_defaults {
45814581
self.emit_load_const(ConstantData::Str {
45824582
value: arg.name.as_str().into(),
45834583
});

compiler/codegen/src/unparse.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ impl<'a, 'b, 'c> Unparser<'a, 'b, 'c> {
464464
if let Some(vararg) = &args.vararg {
465465
self.unparse_arg(vararg)?;
466466
}
467-
for kwarg in args.kwonlyargs.iter() {
467+
for kwarg in &args.kwonlyargs {
468468
self.p_delim(&mut first, ", ")?;
469469
self.unparse_function_arg(kwarg)?;
470470
}

0 commit comments

Comments
 (0)