From 9221c37ffd5a18c485f100452f55654160768134 Mon Sep 17 00:00:00 2001 From: nibon7 Date: Mon, 19 Jun 2023 22:18:50 +0800 Subject: [PATCH] Apply nightly clippy fixes ``` warning: you should consider adding a `Default` implementation for `HjsonFormatter<'a>` --> crates/nu-json/src/ser.rs:700:5 | 700 | / pub fn new() -> Self { 701 | | HjsonFormatter::with_indent(b" ") 702 | | } | |_____^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#new_without_default = note: `#[warn(clippy::new_without_default)]` on by default help: try adding this | 698 + impl<'a> Default for HjsonFormatter<'a> { 699 + fn default() -> Self { 700 + Self::new() 701 + } 702 + } | warning: `nu-json` (lib) generated 1 warning warning: private item shadows public glob re-export --> crates/nu-command/src/strings/mod.rs:8:1 | 8 | mod str_; | ^^^^^^^^^ | note: the name `str_` in the type namespace is supposed to be publicly re-exported here --> crates/nu-command/src/strings/mod.rs:17:9 | 17 | pub use str_::*; | ^^^^^^^ note: but the private item here shadows it --> crates/nu-command/src/strings/mod.rs:8:1 | 8 | mod str_; | ^^^^^^^^^ = note: `#[warn(hidden_glob_reexports)]` on by default warning: incorrect NaN comparison, NaN cannot be directly compared to itself --> crates/nu-command/src/formats/to/nuon.rs:186:20 | 186 | && val != &f64::NAN | ^^^^^^^^^^^^^^^^ | = note: `#[warn(invalid_nan_comparisons)]` on by default help: use `f32::is_nan()` or `f64::is_nan()` instead | 186 - && val != &f64::NAN 186 + && !val.is_nan() | warning: `nu-command` (lib) generated 2 warnings (run `cargo clippy --fix --lib -p nu-command` to apply 1 suggestion) Finished dev [unoptimized + debuginfo] target(s) in 0.14s ``` --- crates/nu-command/src/formats/to/nuon.rs | 2 +- .../nu-command/src/strings/str_/case/mod.rs | 20 +++++++++---------- crates/nu-json/src/ser.rs | 6 ++++++ 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/crates/nu-command/src/formats/to/nuon.rs b/crates/nu-command/src/formats/to/nuon.rs index c712fa132e11c..1e15c468e90db 100644 --- a/crates/nu-command/src/formats/to/nuon.rs +++ b/crates/nu-command/src/formats/to/nuon.rs @@ -183,7 +183,7 @@ pub fn value_to_string( Value::Float { val, .. } => { // This serialises these as 'nan', 'inf' and '-inf', respectively. if &val.round() == val - && val != &f64::NAN + && !val.is_nan() && val != &f64::INFINITY && val != &f64::NEG_INFINITY { diff --git a/crates/nu-command/src/strings/str_/case/mod.rs b/crates/nu-command/src/strings/str_/case/mod.rs index 1f76caf03eb08..321ef66e45afa 100644 --- a/crates/nu-command/src/strings/str_/case/mod.rs +++ b/crates/nu-command/src/strings/str_/case/mod.rs @@ -1,13 +1,13 @@ -pub mod camel_case; -pub mod capitalize; -pub mod downcase; -pub mod kebab_case; -pub mod pascal_case; -pub mod screaming_snake_case; -pub mod snake_case; -pub mod str_; -pub mod title_case; -pub mod upcase; +mod camel_case; +mod capitalize; +mod downcase; +mod kebab_case; +mod pascal_case; +mod screaming_snake_case; +mod snake_case; +mod str_; +mod title_case; +mod upcase; pub use camel_case::SubCommand as StrCamelCase; pub use capitalize::SubCommand as StrCapitalize; diff --git a/crates/nu-json/src/ser.rs b/crates/nu-json/src/ser.rs index ba644eb466378..246a5db20994a 100644 --- a/crates/nu-json/src/ser.rs +++ b/crates/nu-json/src/ser.rs @@ -695,6 +695,12 @@ struct HjsonFormatter<'a> { braces_same_line: bool, } +impl<'a> Default for HjsonFormatter<'a> { + fn default() -> Self { + Self::new() + } +} + impl<'a> HjsonFormatter<'a> { /// Construct a formatter that defaults to using two spaces for indentation. pub fn new() -> Self {