From f56070cbcd1c1c0ba79439f49850793ad8b9e28f Mon Sep 17 00:00:00 2001 From: Stefan Holderbach Date: Wed, 20 Mar 2024 02:46:39 +0100 Subject: [PATCH] Respond to nightly clippy (#12174) Babe, wake up new nightly clippy just dropped - Move `catch_unwind` block out of `match` scrutinee - Remove unused members in `PluginExecutionContext` --- crates/nu-cli/src/repl.rs | 5 +++-- crates/nu-plugin/src/plugin/context.rs | 22 +--------------------- 2 files changed, 4 insertions(+), 23 deletions(-) diff --git a/crates/nu-cli/src/repl.rs b/crates/nu-cli/src/repl.rs index e1825e0cbc..b5d7170ea2 100644 --- a/crates/nu-cli/src/repl.rs +++ b/crates/nu-cli/src/repl.rs @@ -143,7 +143,7 @@ pub fn evaluate_repl( let temp_file_cloned = temp_file.clone(); let mut nu_prompt_cloned = nu_prompt.clone(); - match catch_unwind(AssertUnwindSafe(move || { + let iteration_panic_state = catch_unwind(AssertUnwindSafe(move || { let (continue_loop, current_stack, line_editor) = loop_iteration(LoopContext { engine_state: &mut current_engine_state, stack: current_stack, @@ -161,7 +161,8 @@ pub fn evaluate_repl( current_stack, line_editor, ) - })) { + })); + match iteration_panic_state { Ok((continue_loop, es, s, le)) => { // setup state for the next iteration of the repl loop previous_engine_state = es; diff --git a/crates/nu-plugin/src/plugin/context.rs b/crates/nu-plugin/src/plugin/context.rs index 18c50a6024..f50fb1159b 100644 --- a/crates/nu-plugin/src/plugin/context.rs +++ b/crates/nu-plugin/src/plugin/context.rs @@ -8,17 +8,13 @@ use nu_engine::get_eval_block_with_early_return; use nu_protocol::{ ast::Call, engine::{Closure, EngineState, Redirection, Stack}, - Config, IntoSpanned, IoStream, PipelineData, PluginIdentity, ShellError, Span, Spanned, Value, + Config, IntoSpanned, IoStream, PipelineData, PluginIdentity, ShellError, Spanned, Value, }; use crate::util::MutableCow; /// Object safe trait for abstracting operations required of the plugin context. pub(crate) trait PluginExecutionContext: Send + Sync { - /// The [Span] for the command execution (`call.head`) - fn command_span(&self) -> Span; - /// The name of the command being executed - fn command_name(&self) -> &str; /// The interrupt signal, if present fn ctrlc(&self) -> Option<&Arc>; /// Get engine configuration @@ -71,14 +67,6 @@ impl<'a> PluginExecutionCommandContext<'a> { } impl<'a> PluginExecutionContext for PluginExecutionCommandContext<'a> { - fn command_span(&self) -> Span { - self.call.head - } - - fn command_name(&self) -> &str { - self.engine_state.get_decl(self.call.decl_id).name() - } - fn ctrlc(&self) -> Option<&Arc> { self.engine_state.ctrlc.as_ref() } @@ -220,14 +208,6 @@ pub(crate) struct PluginExecutionBogusContext; #[cfg(test)] impl PluginExecutionContext for PluginExecutionBogusContext { - fn command_span(&self) -> Span { - Span::test_data() - } - - fn command_name(&self) -> &str { - "bogus" - } - fn ctrlc(&self) -> Option<&Arc> { None }