Fix clippy::needless_pass_by_value (pedantic)

“this argument is passed by value, but not consumed in the function
body”

https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_value

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
This commit is contained in:
Anders Kaseorg
2022-11-21 18:28:13 -08:00
committed by Charlie Marsh
parent 348ff509c0
commit 517ca2604a
6 changed files with 9 additions and 5 deletions

View File

@@ -20,7 +20,7 @@ fn check_import_blocks(
let mut checks = vec![];
for block in tracker.into_iter() {
if !block.is_empty() {
if let Some(check) = isort::plugins::check_imports(block, locator, settings, autofix) {
if let Some(check) = isort::plugins::check_imports(&block, locator, settings, autofix) {
checks.push(check);
}
}

View File

@@ -29,6 +29,7 @@ pub struct Settings {
}
impl Settings {
#[allow(clippy::needless_pass_by_value)]
pub fn from_options(options: Options) -> Self {
Self {
mypy_init_return: options.mypy_init_return.unwrap_or_default(),

View File

@@ -1,3 +1,4 @@
#[derive(Clone, Copy)]
pub enum ShadowingType {
Variable,
Argument,

View File

@@ -30,13 +30,13 @@ fn extract_indentation(body: &[&Stmt], locator: &SourceCodeLocator) -> String {
/// I001
pub fn check_imports(
body: Vec<&Stmt>,
body: &[&Stmt],
locator: &SourceCodeLocator,
settings: &Settings,
autofix: &fixer::Mode,
) -> Option<Check> {
let range = extract_range(&body);
let indentation = extract_indentation(&body, locator);
let range = extract_range(body);
let indentation = extract_indentation(body, locator);
// Extract comments. Take care to grab any inline comments from the last line.
let comments = comments::collect_comments(
@@ -53,7 +53,7 @@ pub fn check_imports(
// Generate the sorted import block.
let expected = format_imports(
&body,
body,
comments,
settings.line_length - indentation.len(),
&settings.src,

View File

@@ -14,6 +14,7 @@ pub struct Settings {
}
impl Settings {
#[allow(clippy::needless_pass_by_value)]
pub fn from_options(options: Options) -> Self {
Self {
max_complexity: options.max_complexity.unwrap_or_default(),

View File

@@ -1596,6 +1596,7 @@ static CONFUSABLES: Lazy<FxHashMap<u32, u32>> = Lazy::new(|| {
])
});
#[derive(Clone, Copy)]
pub enum Context {
String,
Docstring,