From 575ddbd4ef208a1c8dd461820be9ce12d2dbab48 Mon Sep 17 00:00:00 2001 From: JT <547158+jntrnr@users.noreply.github.com> Date: Sun, 26 Jun 2022 08:20:28 +1200 Subject: [PATCH] Clippy and remove unused is_binary (#5879) --- crates/nu-cli/tests/alias.rs | 6 ++--- crates/nu-cli/tests/file_completions.rs | 28 ++++++++++++------------ crates/nu-engine/src/eval.rs | 6 ----- crates/nu-parser/tests/test_parser.rs | 2 +- crates/nu-protocol/src/engine/command.rs | 4 ---- 5 files changed, 18 insertions(+), 28 deletions(-) diff --git a/crates/nu-cli/tests/alias.rs b/crates/nu-cli/tests/alias.rs index a112aae32c..78d1dd0199 100644 --- a/crates/nu-cli/tests/alias.rs +++ b/crates/nu-cli/tests/alias.rs @@ -10,7 +10,7 @@ fn alias_of_command_and_flags() { // Create an alias let alias = r#"alias ll = ls -l"#; - assert!(support::merge_input(alias.as_bytes(), &mut engine, &mut stack, dir.clone()).is_ok()); + assert!(support::merge_input(alias.as_bytes(), &mut engine, &mut stack, dir).is_ok()); let mut completer = NuCompleter::new(std::sync::Arc::new(engine), stack); @@ -29,7 +29,7 @@ fn alias_of_basic_command() { // Create an alias let alias = r#"alias ll = ls "#; - assert!(support::merge_input(alias.as_bytes(), &mut engine, &mut stack, dir.clone()).is_ok()); + assert!(support::merge_input(alias.as_bytes(), &mut engine, &mut stack, dir).is_ok()); let mut completer = NuCompleter::new(std::sync::Arc::new(engine), stack); @@ -51,7 +51,7 @@ fn alias_of_another_alias() { assert!(support::merge_input(alias.as_bytes(), &mut engine, &mut stack, dir.clone()).is_ok()); // Create the second alias let alias = r#"alias lf = ll -f"#; - assert!(support::merge_input(alias.as_bytes(), &mut engine, &mut stack, dir.clone()).is_ok()); + assert!(support::merge_input(alias.as_bytes(), &mut engine, &mut stack, dir).is_ok()); let mut completer = NuCompleter::new(std::sync::Arc::new(engine), stack); diff --git a/crates/nu-cli/tests/file_completions.rs b/crates/nu-cli/tests/file_completions.rs index ad8aa8e856..6e36063637 100644 --- a/crates/nu-cli/tests/file_completions.rs +++ b/crates/nu-cli/tests/file_completions.rs @@ -47,8 +47,8 @@ fn command_ls_completion() { let mut completer = NuCompleter::new(std::sync::Arc::new(engine), stack); - let target_dir = format!("ls "); - let suggestions = completer.complete(&target_dir, target_dir.len()); + let target_dir = "ls "; + let suggestions = completer.complete(target_dir, target_dir.len()); #[cfg(windows)] let expected_paths: Vec = vec![ @@ -79,8 +79,8 @@ fn command_open_completion() { let mut completer = NuCompleter::new(std::sync::Arc::new(engine), stack); - let target_dir = format!("open "); - let suggestions = completer.complete(&target_dir, target_dir.len()); + let target_dir = "open "; + let suggestions = completer.complete(target_dir, target_dir.len()); #[cfg(windows)] let expected_paths: Vec = vec![ @@ -112,8 +112,8 @@ fn command_rm_completion() { let mut completer = NuCompleter::new(std::sync::Arc::new(engine), stack); - let target_dir = format!("rm "); - let suggestions = completer.complete(&target_dir, target_dir.len()); + let target_dir = "rm "; + let suggestions = completer.complete(target_dir, target_dir.len()); #[cfg(windows)] let expected_paths: Vec = vec![ @@ -145,8 +145,8 @@ fn command_cp_completion() { let mut completer = NuCompleter::new(std::sync::Arc::new(engine), stack); - let target_dir = format!("cp "); - let suggestions = completer.complete(&target_dir, target_dir.len()); + let target_dir = "cp "; + let suggestions = completer.complete(target_dir, target_dir.len()); #[cfg(windows)] let expected_paths: Vec = vec![ @@ -178,8 +178,8 @@ fn command_save_completion() { let mut completer = NuCompleter::new(std::sync::Arc::new(engine), stack); - let target_dir = format!("save "); - let suggestions = completer.complete(&target_dir, target_dir.len()); + let target_dir = "save "; + let suggestions = completer.complete(target_dir, target_dir.len()); #[cfg(windows)] let expected_paths: Vec = vec![ @@ -211,8 +211,8 @@ fn command_touch_completion() { let mut completer = NuCompleter::new(std::sync::Arc::new(engine), stack); - let target_dir = format!("touch "); - let suggestions = completer.complete(&target_dir, target_dir.len()); + let target_dir = "touch "; + let suggestions = completer.complete(target_dir, target_dir.len()); #[cfg(windows)] let expected_paths: Vec = vec![ @@ -244,8 +244,8 @@ fn command_watch_completion() { let mut completer = NuCompleter::new(std::sync::Arc::new(engine), stack); - let target_dir = format!("watch "); - let suggestions = completer.complete(&target_dir, target_dir.len()); + let target_dir = "watch "; + let suggestions = completer.complete(target_dir, target_dir.len()); #[cfg(windows)] let expected_paths: Vec = vec![ diff --git a/crates/nu-engine/src/eval.rs b/crates/nu-engine/src/eval.rs index c7039e5200..a6f0852af3 100644 --- a/crates/nu-engine/src/eval.rs +++ b/crates/nu-engine/src/eval.rs @@ -1033,12 +1033,6 @@ pub fn create_scope( span, }); - cols.push("is_binary".to_string()); - vals.push(Value::Bool { - val: decl.is_binary(), - span, - }); - cols.push("is_builtin".to_string()); // we can only be a is_builtin or is_custom, not both vals.push(Value::Bool { diff --git a/crates/nu-parser/tests/test_parser.rs b/crates/nu-parser/tests/test_parser.rs index a09c11223b..c9bbcf94ae 100644 --- a/crates/nu-parser/tests/test_parser.rs +++ b/crates/nu-parser/tests/test_parser.rs @@ -986,7 +986,7 @@ mod input_types { fn add_declations(engine_state: &mut EngineState) { let delta = { - let mut working_set = StateWorkingSet::new(&engine_state); + let mut working_set = StateWorkingSet::new(engine_state); working_set.add_decl(Box::new(Let)); working_set.add_decl(Box::new(AggCustom)); working_set.add_decl(Box::new(GroupByCustom)); diff --git a/crates/nu-protocol/src/engine/command.rs b/crates/nu-protocol/src/engine/command.rs index 53ca5acb85..6ccd669808 100644 --- a/crates/nu-protocol/src/engine/command.rs +++ b/crates/nu-protocol/src/engine/command.rs @@ -23,10 +23,6 @@ pub trait Command: Send + Sync + CommandClone { input: PipelineData, ) -> Result; - fn is_binary(&self) -> bool { - false - } - fn examples(&self) -> Vec { Vec::new() }