From 14a2918bbaba8b4bc77d7537ae275905cde722b9 Mon Sep 17 00:00:00 2001 From: JT <547158+jntrnr@users.noreply.github.com> Date: Sat, 13 Nov 2021 13:42:13 +1300 Subject: [PATCH] Fix some nightly clippy warnings (#329) --- Cargo.lock | 7 ++++--- crates/nu-command/src/math/reducers.rs | 12 ++---------- crates/nu-engine/src/documentation.rs | 11 +---------- crates/nu-parser/src/lib.rs | 2 +- crates/nu-parser/src/parser.rs | 14 ++++---------- 5 files changed, 12 insertions(+), 34 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 03edf85d7..e443b9e7d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -156,9 +156,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.71" +version = "1.0.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79c2681d6594606957bbb8631c4b90a7fcaaa72cdb714743a437b156d6a7eedd" +checksum = "22a9137b95ea06864e018375b72adfb7db6e6f68cfc8df5a04d00288050485ee" [[package]] name = "cfg-if" @@ -807,6 +807,7 @@ dependencies = [ "nu-term-grid", "rand", "rayon", + "regex", "serde", "serde_urlencoded", "serde_yaml", @@ -1227,7 +1228,7 @@ dependencies = [ [[package]] name = "reedline" version = "0.2.0" -source = "git+https://github.com/nushell/reedline?branch=main#1b244992981e392152b86ceed5c583c31150976c" +source = "git+https://github.com/nushell/reedline?branch=main#c11aef2d9b4eaf0c762f1349f641534597815295" dependencies = [ "chrono", "crossterm 0.22.1", diff --git a/crates/nu-command/src/math/reducers.rs b/crates/nu-command/src/math/reducers.rs index 3a7b3273f..68a41ff77 100644 --- a/crates/nu-command/src/math/reducers.rs +++ b/crates/nu-command/src/math/reducers.rs @@ -98,11 +98,7 @@ pub fn sum(data: Vec, head: Span) -> Result { | Value::Float { .. } | Value::Filesize { .. } | Value::Duration { .. } => { - let new_value = acc.add(head, value); - if new_value.is_err() { - return new_value; - } - acc = new_value.expect("This should never trigger") + acc = acc.add(head, value)?; } other => { return Err(ShellError::UnsupportedInput( @@ -133,11 +129,7 @@ pub fn product(data: Vec, head: Span) -> Result { for value in &data { match value { Value::Int { .. } | Value::Float { .. } => { - let new_value = acc.mul(head, value); - if new_value.is_err() { - return new_value; - } - acc = new_value.expect("This should never trigger") + acc = acc.mul(head, value)?; } other => { return Err(ShellError::UnsupportedInput( diff --git a/crates/nu-engine/src/documentation.rs b/crates/nu-engine/src/documentation.rs index ea0bb17e6..caa6af50b 100644 --- a/crates/nu-engine/src/documentation.rs +++ b/crates/nu-engine/src/documentation.rs @@ -4,6 +4,7 @@ use std::collections::HashMap; const COMMANDS_DOCS_DIR: &str = "docs/commands"; +#[derive(Default)] pub struct DocumentationConfig { no_subcommands: bool, //FIXME: add back in color support @@ -12,16 +13,6 @@ pub struct DocumentationConfig { brief: bool, } -impl Default for DocumentationConfig { - fn default() -> Self { - DocumentationConfig { - no_subcommands: false, - no_color: false, - brief: false, - } - } -} - fn generate_doc(name: &str, engine_state: &EngineState) -> (Vec, Vec) { let mut cols = vec![]; let mut vals = vec![]; diff --git a/crates/nu-parser/src/lib.rs b/crates/nu-parser/src/lib.rs index 639c43d5a..400110435 100644 --- a/crates/nu-parser/src/lib.rs +++ b/crates/nu-parser/src/lib.rs @@ -13,7 +13,7 @@ pub use lite_parse::{lite_parse, LiteBlock}; pub use parse_keywords::{ parse_alias, parse_def, parse_def_predecl, parse_let, parse_module, parse_use, }; -pub use parser::{find_captures_in_expr, parse, Import, VarDecl}; +pub use parser::{find_captures_in_expr, parse, Import}; #[cfg(feature = "plugin")] pub use parse_keywords::parse_plugin; diff --git a/crates/nu-parser/src/parser.rs b/crates/nu-parser/src/parser.rs index 57847afd9..e413e28b1 100644 --- a/crates/nu-parser/src/parser.rs +++ b/crates/nu-parser/src/parser.rs @@ -24,12 +24,6 @@ use crate::parse_keywords::parse_plugin; #[derive(Debug, Clone)] pub enum Import {} -#[derive(Debug, Clone)] -pub struct VarDecl { - var_id: VarId, - expression: Expression, -} - pub fn garbage(span: Span) -> Expression { Expression::garbage(span) } @@ -271,7 +265,7 @@ fn parse_short_flags( error = error.or_else(|| { Some(ParseError::UnknownFlag( sig.name.clone(), - format!("-{}", String::from_utf8_lossy(contents).to_string()), + format!("-{}", String::from_utf8_lossy(contents)), *first, )) }); @@ -281,7 +275,7 @@ fn parse_short_flags( error = error.or_else(|| { Some(ParseError::UnknownFlag( sig.name.clone(), - format!("-{}", String::from_utf8_lossy(contents).to_string()), + format!("-{}", String::from_utf8_lossy(contents)), *first, )) }); @@ -291,7 +285,7 @@ fn parse_short_flags( error = error.or_else(|| { Some(ParseError::UnknownFlag( sig.name.clone(), - format!("-{}", String::from_utf8_lossy(contents).to_string()), + format!("-{}", String::from_utf8_lossy(contents)), *first, )) }); @@ -302,7 +296,7 @@ fn parse_short_flags( error = error.or_else(|| { Some(ParseError::UnknownFlag( sig.name.clone(), - format!("-{}", String::from_utf8_lossy(contents).to_string()), + format!("-{}", String::from_utf8_lossy(contents)), *first, )) });