Skip to content

Apply some clippy lints #6045

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

Merged
merged 5 commits into from
Jul 30, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
Apply some clipy lints
  • Loading branch information
ShaharNaveh committed Jul 29, 2025
commit d602a26f831e4c4326b1575659a434b51ae6bd3f
2 changes: 1 addition & 1 deletion common/src/boxvec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ impl<T> BoxVec<T> {
if index >= self.len() {
None
} else {
self.drain(index..index + 1).next()
self.drain(index..=index).next()
}
}

Expand Down
4 changes: 2 additions & 2 deletions common/src/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ impl FormatSpec {

fn insert_separator(mut magnitude_str: String, inter: i32, sep: char, sep_cnt: i32) -> String {
let magnitude_len = magnitude_str.len() as i32;
for i in 1..sep_cnt + 1 {
for i in 1..=sep_cnt {
magnitude_str.insert((magnitude_len - inter * i) as usize, sep);
}
magnitude_str
Expand Down Expand Up @@ -754,7 +754,7 @@ impl FormatSpec {
let inter = self.get_separator_interval().try_into().unwrap();
let len = magnitude_str.len() as i32;
let separated_magnitude =
FormatSpec::add_magnitude_separators_for_char(magnitude_str, inter, sep, len);
Self::add_magnitude_separators_for_char(magnitude_str, inter, sep, len);
Ok(separated_magnitude)
}
None => Ok(magnitude_str),
Expand Down
14 changes: 7 additions & 7 deletions compiler/codegen/src/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ impl Compiler {
fblock: Vec::with_capacity(MAXBLOCKS),
symbol_table_index: 0, // Module is always the first symbol table
};
Compiler {
Self {
code_stack: vec![module_code],
symbol_table_stack: Vec::new(),
source_file,
Expand All @@ -380,7 +380,7 @@ impl Compiler {

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

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

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

// Prepare defaults before entering function
Expand Down Expand Up @@ -4577,7 +4577,7 @@ impl Compiler {
let have_kwdefaults = !kw_with_defaults.is_empty();
if have_kwdefaults {
let default_kw_count = kw_with_defaults.len();
for (arg, default) in kw_with_defaults.iter() {
for (arg, default) in &kw_with_defaults {
self.emit_load_const(ConstantData::Str {
value: arg.name.as_str().into(),
});
Expand Down
2 changes: 1 addition & 1 deletion compiler/codegen/src/unparse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ impl<'a, 'b, 'c> Unparser<'a, 'b, 'c> {
if let Some(vararg) = &args.vararg {
self.unparse_arg(vararg)?;
}
for kwarg in args.kwonlyargs.iter() {
for kwarg in &args.kwonlyargs {
self.p_delim(&mut first, ", ")?;
self.unparse_function_arg(kwarg)?;
}
Expand Down
Loading
Loading