From a5dd93d1543da1b5ea47b93591c41a8997b20bb4 Mon Sep 17 00:00:00 2001 From: Stefan Holderbach Date: Thu, 8 Jun 2023 18:49:58 +0200 Subject: [PATCH] Apply nightly clippy fixes (#9381) # Description New lints coming from `cargo +nightly clippy` Manually checked for problems. # User-Facing Changes None # Tests + Formatting (-) --- .../src/dataframe/eager/sql_context.rs | 2 +- crates/nu-color-config/src/color_config.rs | 2 +- crates/nu-color-config/src/text_style.rs | 30 +++++++++---------- crates/nu-command/src/debug/explain.rs | 2 -- crates/nu-command/src/strings/split/words.rs | 2 +- crates/nu-explore/src/lib.rs | 2 +- crates/nu-parser/src/parse_keywords.rs | 2 +- crates/nu-parser/src/parser.rs | 2 +- 8 files changed, 21 insertions(+), 23 deletions(-) diff --git a/crates/nu-cmd-dataframe/src/dataframe/eager/sql_context.rs b/crates/nu-cmd-dataframe/src/dataframe/eager/sql_context.rs index 5aed29f183..640f850694 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/eager/sql_context.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/eager/sql_context.rs @@ -18,7 +18,7 @@ impl SQLContext { pub fn new() -> Self { Self { table_map: HashMap::new(), - dialect: GenericDialect::default(), + dialect: GenericDialect, } } diff --git a/crates/nu-color-config/src/color_config.rs b/crates/nu-color-config/src/color_config.rs index d5dfb6a5a6..6dc81ec792 100644 --- a/crates/nu-color-config/src/color_config.rs +++ b/crates/nu-color-config/src/color_config.rs @@ -107,7 +107,7 @@ mod tests { let style = color_string_to_nustyle(color_string); assert_eq!(style.foreground, Some(Color::Black)); assert_eq!(style.background, Some(Color::White)); - assert_eq!(style.is_bold, true); + assert!(style.is_bold); } #[test] diff --git a/crates/nu-color-config/src/text_style.rs b/crates/nu-color-config/src/text_style.rs index d9753c453f..06170b5bf8 100644 --- a/crates/nu-color-config/src/text_style.rs +++ b/crates/nu-color-config/src/text_style.rs @@ -258,7 +258,7 @@ mod tests { ..Default::default() }), }; - assert_eq!(text_style.is_bold(), true); + assert!(text_style.is_bold()); } #[test] @@ -270,7 +270,7 @@ mod tests { }), }; let dimmed_style = text_style.dimmed(); - assert_eq!(dimmed_style.is_dimmed(), true); + assert!(dimmed_style.is_dimmed()); } #[test] @@ -282,7 +282,7 @@ mod tests { ..Default::default() }), }; - assert_eq!(text_style.is_dimmed(), true); + assert!(text_style.is_dimmed()); } #[test] @@ -294,7 +294,7 @@ mod tests { }), }; let italic_style = text_style.italic(); - assert_eq!(italic_style.is_italic(), true); + assert!(italic_style.is_italic()); } #[test] @@ -306,7 +306,7 @@ mod tests { ..Default::default() }), }; - assert_eq!(text_style.is_italic(), true); + assert!(text_style.is_italic()); } #[test] @@ -318,7 +318,7 @@ mod tests { }), }; let underline_style = text_style.underline(); - assert_eq!(underline_style.is_underline(), true); + assert!(underline_style.is_underline()); } #[test] @@ -330,7 +330,7 @@ mod tests { ..Default::default() }), }; - assert_eq!(text_style.is_underline(), true); + assert!(text_style.is_underline()); } #[test] @@ -342,7 +342,7 @@ mod tests { }), }; let blink_style = text_style.blink(); - assert_eq!(blink_style.is_blink(), true); + assert!(blink_style.is_blink()); } #[test] @@ -354,7 +354,7 @@ mod tests { ..Default::default() }), }; - assert_eq!(text_style.is_blink(), true); + assert!(text_style.is_blink()); } #[test] @@ -366,7 +366,7 @@ mod tests { }), }; let reverse_style = text_style.reverse(); - assert_eq!(reverse_style.is_reverse(), true); + assert!(reverse_style.is_reverse()); } #[test] @@ -378,7 +378,7 @@ mod tests { ..Default::default() }), }; - assert_eq!(text_style.is_reverse(), true); + assert!(text_style.is_reverse()); } #[test] @@ -390,7 +390,7 @@ mod tests { }), }; let hidden_style = text_style.hidden(); - assert_eq!(hidden_style.is_hidden(), true); + assert!(hidden_style.is_hidden()); } #[test] @@ -402,7 +402,7 @@ mod tests { ..Default::default() }), }; - assert_eq!(text_style.is_hidden(), true); + assert!(text_style.is_hidden()); } #[test] @@ -414,7 +414,7 @@ mod tests { }), }; let strikethrough_style = text_style.strikethrough(); - assert_eq!(strikethrough_style.is_strikethrough(), true); + assert!(strikethrough_style.is_strikethrough()); } #[test] @@ -426,6 +426,6 @@ mod tests { ..Default::default() }), }; - assert_eq!(text_style.is_strikethrough(), true); + assert!(text_style.is_strikethrough()); } } diff --git a/crates/nu-command/src/debug/explain.rs b/crates/nu-command/src/debug/explain.rs index 6285077bd8..a40812f305 100644 --- a/crates/nu-command/src/debug/explain.rs +++ b/crates/nu-command/src/debug/explain.rs @@ -176,7 +176,6 @@ fn get_arguments(engine_state: &EngineState, stack: &mut Stack, call: Call) -> V span: name.span, }; arg_value.push(rec); - } else { }; if let Some(expression) = opt_expr { @@ -207,7 +206,6 @@ fn get_arguments(engine_state: &EngineState, stack: &mut Stack, call: Call) -> V span: expression.span, }; arg_value.push(rec); - } else { }; } Argument::Positional(inner_expr) => { diff --git a/crates/nu-command/src/strings/split/words.rs b/crates/nu-command/src/strings/split/words.rs index fe534f4e1d..0affdf8c6a 100644 --- a/crates/nu-command/src/strings/split/words.rs +++ b/crates/nu-command/src/strings/split/words.rs @@ -117,7 +117,7 @@ fn split_words( // let ignore_punctuation = call.has_flag("ignore-punctuation"); let word_length: Option = call.get_flag(engine_state, stack, "min-word-length")?; - if matches!(word_length, None) { + if word_length.is_none() { if call.has_flag("grapheme-clusters") { return Err(ShellError::IncompatibleParametersSingle { msg: "--grapheme-clusters (-g) requires --min-word-length (-l)".to_string(), diff --git a/crates/nu-explore/src/lib.rs b/crates/nu-explore/src/lib.rs index f4e789bc82..bf4890ce55 100644 --- a/crates/nu-explore/src/lib.rs +++ b/crates/nu-explore/src/lib.rs @@ -111,7 +111,7 @@ pub fn create_commands(registry: &mut CommandRegistry) { registry.register_command_view(ConfigCmd::default(), true); registry.register_command_view(HelpCmd::default(), true); - registry.register_command_reactive(QuitCmd::default()); + registry.register_command_reactive(QuitCmd); registry.register_command_reactive(TweakCmd::default()); } diff --git a/crates/nu-parser/src/parse_keywords.rs b/crates/nu-parser/src/parse_keywords.rs index 9435d892e3..72f716b6a5 100644 --- a/crates/nu-parser/src/parse_keywords.rs +++ b/crates/nu-parser/src/parse_keywords.rs @@ -464,7 +464,7 @@ pub fn parse_def( *declaration = signature.clone().into_block_command(block_id); - let mut block = working_set.get_block_mut(block_id); + let block = working_set.get_block_mut(block_id); let calls_itself = block_calls_itself(block, decl_id); block.recursive = Some(calls_itself); block.signature = signature; diff --git a/crates/nu-parser/src/parser.rs b/crates/nu-parser/src/parser.rs index a9e63c5318..21db2da380 100644 --- a/crates/nu-parser/src/parser.rs +++ b/crates/nu-parser/src/parser.rs @@ -1587,7 +1587,7 @@ pub fn parse_brace_expr( .get(1) .map(|token| working_set.get_span_contents(token.span)); - if matches!(second_token, None) { + if second_token.is_none() { // If we're empty, that means an empty record or closure if matches!(shape, SyntaxShape::Closure(_)) { parse_closure_expression(working_set, shape, span)