From bc1e1aa944e450c322512b55c187bdbc0fbeae56 Mon Sep 17 00:00:00 2001 From: JT <547158+jntrnr@users.noreply.github.com> Date: Fri, 14 Jan 2022 06:40:25 +1100 Subject: [PATCH] Clippy fixes for Rust 1.58 (#733) * Clippy fixes for Rust 1.58 * Try different message --- .../src/dataframe/values/nu_dataframe/operations.rs | 2 +- crates/nu-command/src/filters/empty.rs | 2 +- crates/nu-command/src/filters/flatten.rs | 2 +- crates/nu-command/src/platform/ansi/command.rs | 2 +- crates/nu-command/src/platform/ansi/gradient.rs | 2 +- crates/nu-command/src/platform/ansi/strip.rs | 2 +- crates/nu-command/src/platform/kill.rs | 2 +- crates/nu-command/src/viewers/griddle.rs | 6 +----- crates/nu-protocol/src/ty.rs | 2 +- crates/nu_plugin_inc/src/inc.rs | 6 +----- src/tests.rs | 2 +- 11 files changed, 11 insertions(+), 19 deletions(-) diff --git a/crates/nu-command/src/dataframe/values/nu_dataframe/operations.rs b/crates/nu-command/src/dataframe/values/nu_dataframe/operations.rs index beee980f14..95258c5da7 100644 --- a/crates/nu-command/src/dataframe/values/nu_dataframe/operations.rs +++ b/crates/nu-command/src/dataframe/values/nu_dataframe/operations.rs @@ -196,7 +196,7 @@ impl NuDataFrame { let df_new = DataFrame::new(new_cols).map_err(|e| { ShellError::SpannedLabeledError( "Error appending dataframe".into(), - format!("Unable to append dataframes: {}", e.to_string()), + format!("Unable to append dataframes: {}", e), span, ) })?; diff --git a/crates/nu-command/src/filters/empty.rs b/crates/nu-command/src/filters/empty.rs index b0e454550f..e1b366b6e8 100644 --- a/crates/nu-command/src/filters/empty.rs +++ b/crates/nu-command/src/filters/empty.rs @@ -162,7 +162,7 @@ fn process_row( } } else { let mut obj = input.clone(); - for column in column_paths.clone() { + for column in column_paths { let path = column.into_string(); let data = input.get_data_by_key(&path); let is_empty = match data { diff --git a/crates/nu-command/src/filters/flatten.rs b/crates/nu-command/src/filters/flatten.rs index 055b230ccf..d6dc85ccd2 100644 --- a/crates/nu-command/src/filters/flatten.rs +++ b/crates/nu-command/src/filters/flatten.rs @@ -153,7 +153,7 @@ fn flat_value(columns: &[CellPath], item: &Value, _name_tag: Span) -> Vec for (k, v) in cols.into_iter().zip(vals.into_iter()) { if out.contains_key(&k) { - out.insert(format!("{}_{}", column.to_string(), k), v.clone()); + out.insert(format!("{}_{}", column, k), v.clone()); } else { out.insert(k, v.clone()); } diff --git a/crates/nu-command/src/platform/ansi/command.rs b/crates/nu-command/src/platform/ansi/command.rs index 4bf298f9ca..4c2b0532e3 100644 --- a/crates/nu-command/src/platform/ansi/command.rs +++ b/crates/nu-command/src/platform/ansi/command.rs @@ -389,7 +389,7 @@ Format: # "attr" => nu_style.attr = Some(v.as_string()?), _ => { return Err(ShellError::IncompatibleParametersSingle( - format!("problem with key: {}", k.to_string()), + format!("problem with key: {}", k), code.span().expect("error with span"), )) } diff --git a/crates/nu-command/src/platform/ansi/gradient.rs b/crates/nu-command/src/platform/ansi/gradient.rs index 1b1c269a8b..92defdcf87 100644 --- a/crates/nu-command/src/platform/ansi/gradient.rs +++ b/crates/nu-command/src/platform/ansi/gradient.rs @@ -275,7 +275,7 @@ fn action( } } other => { - let got = format!("value is {}, not string", other.get_type().to_string()); + let got = format!("value is {}, not string", other.get_type()); Value::Error { error: ShellError::TypeMismatch(got, other.span().unwrap_or(*command_span)), diff --git a/crates/nu-command/src/platform/ansi/strip.rs b/crates/nu-command/src/platform/ansi/strip.rs index d3032fa2b6..b69e1b06ae 100644 --- a/crates/nu-command/src/platform/ansi/strip.rs +++ b/crates/nu-command/src/platform/ansi/strip.rs @@ -90,7 +90,7 @@ fn action(input: &Value, command_span: &Span) -> Value { Value::string(stripped_string, *span) } other => { - let got = format!("value is {}, not string", other.get_type().to_string()); + let got = format!("value is {}, not string", other.get_type()); Value::Error { error: ShellError::TypeMismatch(got, other.span().unwrap_or(*command_span)), diff --git a/crates/nu-command/src/platform/kill.rs b/crates/nu-command/src/platform/kill.rs index 5f291a9e89..405e19caa4 100644 --- a/crates/nu-command/src/platform/kill.rs +++ b/crates/nu-command/src/platform/kill.rs @@ -111,7 +111,7 @@ impl Command for Kill { } cmd.arg("-9"); } else if let Some(signal_value) = signal { - cmd.arg(format!("-{}", signal_value.item.to_string())); + cmd.arg(format!("-{}", signal_value.item)); } cmd.arg(pid.to_string()); diff --git a/crates/nu-command/src/viewers/griddle.rs b/crates/nu-command/src/viewers/griddle.rs index bb9c4694f5..1da6f0829e 100644 --- a/crates/nu-command/src/viewers/griddle.rs +++ b/crates/nu-command/src/viewers/griddle.rs @@ -193,11 +193,7 @@ fn create_grid_output( .unwrap_or_default(); // eprintln!("ansi_style: {:?}", &ansi_style); - let item = format!( - "{} {}", - icon_style.apply(icon).to_string(), - ansi_style.apply(value).to_string() - ); + let item = format!("{} {}", icon_style.apply(icon), ansi_style.apply(value)); let mut cell = Cell::from(item); cell.alignment = Alignment::Left; diff --git a/crates/nu-protocol/src/ty.rs b/crates/nu-protocol/src/ty.rs index b01d74dc84..568a09b6af 100644 --- a/crates/nu-protocol/src/ty.rs +++ b/crates/nu-protocol/src/ty.rs @@ -44,7 +44,7 @@ impl Display for Type { "record<{}>", fields .iter() - .map(|(x, y)| format!("{}: {}", x, y.to_string())) + .map(|(x, y)| format!("{}: {}", x, y)) .collect::>() .join(", "), ), diff --git a/crates/nu_plugin_inc/src/inc.rs b/crates/nu_plugin_inc/src/inc.rs index a221fa4fed..9846a65388 100644 --- a/crates/nu_plugin_inc/src/inc.rs +++ b/crates/nu_plugin_inc/src/inc.rs @@ -92,11 +92,7 @@ impl Inc { x => { let msg = x.as_string().map_err(|e| LabeledError { label: "Unable to extract string".into(), - msg: format!( - "value cannot be converted to string {:?} - {}", - x, - e.to_string() - ), + msg: format!("value cannot be converted to string {:?} - {}", x, e), span: Some(head), })?; diff --git a/src/tests.rs b/src/tests.rs index 35cc4e9665..e767ce58a3 100644 --- a/src/tests.rs +++ b/src/tests.rs @@ -76,7 +76,7 @@ pub fn fail_test(input: &str, expected: &str) -> TestResult { #[cfg(test)] pub fn not_found_msg() -> &'static str { if cfg!(windows) { - "cannot find" + "not found" } else { "No such" }