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`
This commit is contained in:
Stefan Holderbach 2024-03-20 02:46:39 +01:00 committed by GitHub
parent b267a9c1ba
commit f56070cbcd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 4 additions and 23 deletions

View file

@ -143,7 +143,7 @@ pub fn evaluate_repl(
let temp_file_cloned = temp_file.clone(); let temp_file_cloned = temp_file.clone();
let mut nu_prompt_cloned = nu_prompt.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 { let (continue_loop, current_stack, line_editor) = loop_iteration(LoopContext {
engine_state: &mut current_engine_state, engine_state: &mut current_engine_state,
stack: current_stack, stack: current_stack,
@ -161,7 +161,8 @@ pub fn evaluate_repl(
current_stack, current_stack,
line_editor, line_editor,
) )
})) { }));
match iteration_panic_state {
Ok((continue_loop, es, s, le)) => { Ok((continue_loop, es, s, le)) => {
// setup state for the next iteration of the repl loop // setup state for the next iteration of the repl loop
previous_engine_state = es; previous_engine_state = es;

View file

@ -8,17 +8,13 @@ use nu_engine::get_eval_block_with_early_return;
use nu_protocol::{ use nu_protocol::{
ast::Call, ast::Call,
engine::{Closure, EngineState, Redirection, Stack}, 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; use crate::util::MutableCow;
/// Object safe trait for abstracting operations required of the plugin context. /// Object safe trait for abstracting operations required of the plugin context.
pub(crate) trait PluginExecutionContext: Send + Sync { 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 /// The interrupt signal, if present
fn ctrlc(&self) -> Option<&Arc<AtomicBool>>; fn ctrlc(&self) -> Option<&Arc<AtomicBool>>;
/// Get engine configuration /// Get engine configuration
@ -71,14 +67,6 @@ impl<'a> PluginExecutionCommandContext<'a> {
} }
impl<'a> PluginExecutionContext for 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<AtomicBool>> { fn ctrlc(&self) -> Option<&Arc<AtomicBool>> {
self.engine_state.ctrlc.as_ref() self.engine_state.ctrlc.as_ref()
} }
@ -220,14 +208,6 @@ pub(crate) struct PluginExecutionBogusContext;
#[cfg(test)] #[cfg(test)]
impl PluginExecutionContext for PluginExecutionBogusContext { impl PluginExecutionContext for PluginExecutionBogusContext {
fn command_span(&self) -> Span {
Span::test_data()
}
fn command_name(&self) -> &str {
"bogus"
}
fn ctrlc(&self) -> Option<&Arc<AtomicBool>> { fn ctrlc(&self) -> Option<&Arc<AtomicBool>> {
None None
} }